The attached patch causes mayflower to use dynamically allocated loop devices for the rootfs readonly-base, readwrite-overlay, squashfs, and osmin loop devices, rather than /dev/loop118,119,120&121.

udev rules were updated, and two new ones added, so that /dev/live-osmin, /dev/live-squashed, /dev/live-osimg, and /dev/live-overlay links will be created by udev.

Also, the unnecessary mknod calls referencing those devices were removed.

I tested with a minimal spin under qemu, and everything appeared as it should. I could mount /dev/mapper/live-osimg-min and it looked fine.

I did another minimal spin with --skip-compression. For some reason I had to hit ctrl-c at to get past udev starting. I'm pretty sure I've seen this before and it has nothing to do with this patch. After doing that, and logging in, I verified that it correctly handled the absence of a squashfs loop device.

Comments?

-dmc
diff -Naur livecd.200709181929/creator/mayflower livecd/creator/mayflower
--- livecd.200709181929/creator/mayflower	2007-09-19 00:29:13.000000000 +0000
+++ livecd/creator/mayflower	2007-09-19 06:40:41.000000000 +0000
@@ -576,13 +576,14 @@
 fi
 
 # live cd helper function
-do_live_from_loop121() {
+do_live_from_base_loop() {
     # create a sparse file for the overlay
     dd if=/dev/null of=/overlay bs=1024 count=1 seek=$((512*1024)) 2> /dev/null
-    losetup /dev/loop119 /overlay
+    OVERLAY_LOOPDEV=\$( losetup -f )
+    losetup \$OVERLAY_LOOPDEV /overlay
 
     # set up the snapshot
-    echo 0 \`blockdev --getsize /dev/loop121\` snapshot /dev/loop121 /dev/loop119 p 8 | dmsetup create live-rw
+    echo 0 \`blockdev --getsize \$BASE_LOOPDEV\` snapshot \$BASE_LOOPDEV \$OVERLAY_LOOPDEV p 8 | dmsetup create live-rw
 
     # set up new /dev/root symlink
     rm -f /dev/root
@@ -619,9 +620,17 @@
        echo "KERNEL==\"sd[a-z][0-9]*\", PROGRAM=\"/lib/udev/vol_id -u %N\", RESULT==\"\$UUID\", SYMLINK+=\"live\"" >> /sysroot/etc/udev/rules.d/50-udev*        
     fi
 
-    # add rules for /dev/live-squashed and /dev/live-osimg
-    echo "KERNEL==\"loop120\" SYMLINK+=\"live-squashed\"" >> /sysroot/etc/udev/rules.d/50-udev*
-    echo "KERNEL==\"loop121\" SYMLINK+=\"live-osimg\"" >> /sysroot/etc/udev/rules.d/50-udev*
+    # add rules for loop devices created by this mayflower generated init
+    # i.e. /dev/live-osimg, /dev/live-osmin, /dev/live-overlay, 
+    #      and /dev/live-squashed
+    if [ -b "\$SQUASHED_LOOPDEV" ]; then
+        echo "KERNEL==\"\${SQUASHED_LOOPDEV#/dev/}\" SYMLINK+=\"live-squashed\"" >> /sysroot/etc/udev/rules.d/50-udev*
+    fi
+    if [ -b "\$OSMIN_LOOPDEV" ]; then
+        echo "KERNEL==\"\${OSMIN_LOOPDEV#/dev/}\" SYMLINK+=\"live-osmin\"" >> /sysroot/etc/udev/rules.d/50-udev*
+    fi
+    echo "KERNEL==\"\${BASE_LOOPDEV#/dev/}\" SYMLINK+=\"live-osimg\"" >> /sysroot/etc/udev/rules.d/50-udev*
+    echo "KERNEL==\"\${OVERLAY_LOOPDEV#/dev/}\" SYMLINK+=\"live-overlay\"" >> /sysroot/etc/udev/rules.d/50-udev*
 
     mount -n -o ro,remount /sysroot
 }
@@ -636,10 +645,10 @@
 fi
 
 if [ -n "\$OSMINGZ" ]; then
-    mknod /dev/loop118 b 7 118
     # decompress the delta data
     gzip -cd \$OSMINGZ > /osmin
-    losetup /dev/loop118 /osmin
+    OSMIN_LOOPDEV=\$( losetup -f )
+    losetup \$OSMIN_LOOPDEV /osmin
 fi
 
 # we might have an uncompressed embedded ext3  to use as rootfs (uncompressed live)
@@ -655,17 +664,15 @@
         echo "setting up embedded ext3 fs "
     fi
 
-    mknod /dev/loop119 b 7 119
-    mknod /dev/loop120 b 7 120
-    mknod /dev/loop121 b 7 121
     mkdir -p /dev/mapper
     mknod /dev/mapper/control c 10 63
     modprobe dm_snapshot
 
-    losetup /dev/loop121 \$EXT3FS
+    BASE_LOOPDEV=\$( losetup -f )
+    losetup \$BASE_LOOPDEV \$EXT3FS
     umount -l /sysroot
 
-    do_live_from_loop121
+    do_live_from_base_loop
 fi
 
 # we might have an embedded ext3 on squashfs to use as rootfs (compressed live)
@@ -682,9 +689,6 @@
         echo "setting up embedded squash -> ext3 fs "
     fi
 
-    mknod /dev/loop119 b 7 119
-    mknod /dev/loop120 b 7 120
-    mknod /dev/loop121 b 7 121
     mkdir -p /dev/mapper
     mknod /dev/mapper/control c 10 63
     modprobe dm_snapshot
@@ -699,24 +703,26 @@
         SQUASHED="/squashed.img"
     fi
 
-    losetup /dev/loop120 \$SQUASHED
+    SQUASHED_LOOPDEV=\$( losetup -f )
+    losetup \$SQUASHED_LOOPDEV \$SQUASHED
     mkdir -p /squashfs
-    mount -n -t squashfs -o ro /dev/loop120 /squashfs
+    mount -n -t squashfs -o ro \$SQUASHED_LOOPDEV /squashfs
 
-    losetup /dev/loop121 /squashfs/os.img
+    BASE_LOOPDEV=\$( losetup -f )
+    losetup \$BASE_LOOPDEV /squashfs/os.img
     
     umount -l /squashfs
     if [ "\$live_ram" == "0" ] ; then
         umount -l /sysroot
     fi
 
-    do_live_from_loop121
+    do_live_from_base_loop
 fi
 
 if [ -e /osmin ]; then
     # set up the devicemapper snapshot device, which will merge
     # the normal live fs image, and the delta, into a minimzied fs image
-    echo "0 \$( blockdev --getsize /dev/loop121 ) snapshot /dev/loop121 /dev/loop118 p 8" | dmsetup create --readonly live-osimg-min
+    echo "0 \$( blockdev --getsize \$BASE_LOOPDEV ) snapshot \$BASE_LOOPDEV \$OSMIN_LOOPDEV p 8" | dmsetup create --readonly live-osimg-min
 fi
 
 if [ "\$eshell" == "1" ] ; then
--
Fedora-livecd-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/fedora-livecd-list

Reply via email to