From: Laszlo Gombos Date: Fri, 18 Feb 2022 01:49:31 +0000 (-0500) Subject: fix(dmsquash-live): permanent overlay on the same drive as LiveCD .iso X-Git-Tag: 057~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a884b3afce1ebc8c6a6e5f62594ce708486a826;p=thirdparty%2Fdracut.git fix(dmsquash-live): permanent overlay on the same drive as LiveCD .iso An example kernel command line arguments for this configuration iso-scan/filename=distro.iso root=live:CDLABEL=ISO rd.live.image rd.live.overlay=/dev/sda:/overlay.img iso-scan would mount /dev/sda first and keep it mounted. The change allows detecting if the permanent overlay drive is already mounted. It also ensures that the mount is writable, as permanent overlay requires writable storage. --- diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh index fd8a858aa..950be2d3c 100755 --- a/modules.d/90dmsquash-live/dmsquash-live-root.sh +++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh @@ -129,7 +129,14 @@ do_live_overlay() { # need to know where to look for the overlay if [ -z "$setup" -a -n "$devspec" -a -n "$pathspec" -a -n "$overlay" ]; then mkdir -m 0755 -p /run/initramfs/overlayfs - mount -n -t auto "$devspec" /run/initramfs/overlayfs || : + if ismounted "$devspec"; then + devmnt=$(findmnt -e -v -n -o 'TARGET' --source "$devspec") + # We need $devspec writable for overlay storage + mount -o remount,rw "$devspec" + mount --bind "$devmnt" /run/initramfs/overlayfs + else + mount -n -t auto "$devspec" /run/initramfs/overlayfs || : + fi if [ -f /run/initramfs/overlayfs$pathspec -a -w /run/initramfs/overlayfs$pathspec ]; then OVERLAY_LOOPDEV=$(losetup -f --show ${readonly_overlay:+-r} /run/initramfs/overlayfs$pathspec) over=$OVERLAY_LOOPDEV