From 8b5ee88ff667693b2d8da85a8552ad8f5ab95127 Mon Sep 17 00:00:00 2001 From: Frederick Grose Date: Fri, 9 Oct 2015 16:56:19 -0400 Subject: [PATCH] dmsquash-live-root: Avoid an overlay for persistent, uncompressed, read-write live installations. 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. --- .../90dmsquash-live/dmsquash-live-root.sh | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh index caf473b52..c455ece62 100755 --- a/modules.d/90dmsquash-live/dmsquash-live-root.sh +++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh @@ -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 -- 2.47.2