]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dmsquash-live-root: Avoid an overlay for persistent, uncompressed, read-write live... 97/head
authorFrederick Grose <fgrose@sugarlabs.org>
Fri, 9 Oct 2015 20:56:19 +0000 (16:56 -0400)
committerFrederick Grose <fgrose@sugarlabs.org>
Sat, 21 Nov 2015 04:38:12 +0000 (23:38 -0500)
Persistent, uncompressed live installations can avoid overlays with a new rd.live.overlay=none flag.
Non-persistent rd.live.ram boots can also take advantage of persistent home.img filesystems.

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

index caf473b52834cd31b525d88f56b5f9dca9acbee5..c455ece62032cb4e086a37a56cb1a80ee2984b9a 100755 (executable)
@@ -203,14 +203,10 @@ fi
 # we might have an embedded fs image on squashfs (compressed live)
 if [ -e /run/initramfs/live/${live_dir}/${squash_image} ]; then
     SQUASHED="/run/initramfs/live/${live_dir}/${squash_image}"
-fi
-
-if [ -e "$SQUASHED" ] ; then
-    if [ -n "$live_ram" ] ; then
+    if [ -n "$live_ram" ]; then
         echo "Copying live image to RAM..."
         echo "(this may take a few minutes)"
         dd if=$SQUASHED of=/run/initramfs/squashed.img bs=512 2> /dev/null
-        umount -n /run/initramfs/live
         echo "Done copying live image to RAM."
         SQUASHED="/run/initramfs/squashed.img"
     fi
@@ -220,24 +216,32 @@ if [ -e "$SQUASHED" ] ; then
     mkdir -m 0755 -p /run/initramfs/squashfs
     mount -n -t squashfs -o ro $SQUASHED_LOOPDEV /run/initramfs/squashfs
 
-fi
-
-# we might have an embedded fs image to use as rootfs (uncompressed live)
-if [ -e /run/initramfs/live/${live_dir}/ext3fs.img ]; then
-    FSIMG="/run/initramfs/live/${live_dir}/ext3fs.img"
-elif [ -e /run/initramfs/live/${live_dir}/rootfs.img ]; then
-    FSIMG="/run/initramfs/live/${live_dir}/rootfs.img"
-elif [ -f /run/initramfs/squashfs/LiveOS/ext3fs.img ]; then
-    FSIMG="/run/initramfs/squashfs/LiveOS/ext3fs.img"
-elif [ -f /run/initramfs/squashfs/LiveOS/rootfs.img ]; then
-    FSIMG="/run/initramfs/squashfs/LiveOS/rootfs.img"
+    if [ -f /run/initramfs/squashfs/LiveOS/ext3fs.img ]; then
+        FSIMG="/run/initramfs/squashfs/LiveOS/ext3fs.img"
+    elif [ -f /run/initramfs/squashfs/LiveOS/rootfs.img ]; then
+        FSIMG="/run/initramfs/squashfs/LiveOS/rootfs.img"
+    fi
+else
+    # we might have an embedded fs image to use as rootfs (uncompressed live)
+    if [ -e /run/initramfs/live/${live_dir}/ext3fs.img ]; then
+        FSIMG="/run/initramfs/live/${live_dir}/ext3fs.img"
+    elif [ -e /run/initramfs/live/${live_dir}/rootfs.img ]; then
+        FSIMG="/run/initramfs/live/${live_dir}/rootfs.img"
+    fi
+    if [ -n "$live_ram" ]; then
+        echo 'Copying live image to RAM...'
+        echo '(this may take a few minutes)'
+        dd if=$FSIMG of=/run/initramfs/rootfs.img bs=512 2> /dev/null
+        echo 'Done copying live image to RAM.'
+        FSIMG='/run/initramfs/rootfs.img'
+    fi
 fi
 
 if [ -n "$FSIMG" ] ; then
     BASE_LOOPDEV=$( losetup -f )
 
     if [ -n "$writable_fsimg" ] ; then
-        # mount the provided fileysstem read/write
+        # mount the provided filesystem read/write
         echo "Unpacking live filesystem (may take some time)"
         mkdir /run/initramfs/fsimg/
         if [ -n "$SQUASHED" ]; then
@@ -245,8 +249,13 @@ if [ -n "$FSIMG" ] ; then
         else
             unpack_archive $FSIMG /run/initramfs/fsimg/
         fi
-        losetup $BASE_LOOPDEV /run/initramfs/fsimg/rootfs.img
-        echo "0 $( blockdev --getsize $BASE_LOOPDEV ) linear $BASE_LOOPDEV 0" | dmsetup create live-rw
+        FSIMG = /run/initramfs/fsimg/rootfs.img
+    fi
+    if [ -n "$writable_fsimg" ] || [ -z "$SQUASHED" -a -n "$live_ram" ] ||
+       [ "$overlay" = none -o "$overlay" = None -o "$overlay" = NONE ]; then
+        losetup $BASE_LOOPDEV $FSIMG
+        sz=$(blockdev --getsz $BASE_LOOPDEV)
+        echo 0 $sz linear $BASE_LOOPDEV 0 | dmsetup create live-rw
     else
         # mount the filesystem read-only and add a dm snapshot for writes
         losetup -r $BASE_LOOPDEV $FSIMG