]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dmsquash-live): permanent overlay on the same drive as LiveCD .iso
authorLaszlo Gombos <laszlo.gombos@gmail.com>
Fri, 18 Feb 2022 01:49:31 +0000 (20:49 -0500)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Tue, 1 Mar 2022 22:37:09 +0000 (22:37 +0000)
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.

modules.d/90dmsquash-live/dmsquash-live-root.sh

index fd8a858aaf7ee13e4bf94d9600922f3b79e8e638..950be2d3cd62c0093e18d24c0d590ba67e7cb398 100755 (executable)
@@ -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