The attached patch implements the solution recently discussed, to avoid
wasting 1.2M of ram during LiveOS sessions, during the non-install times
when the 1.2M of ram for the minimized filesystem overlay is not
actually needed.

This implementation involves putting osmin in its own squashfs, and
copying that 12kb image to ram, as opposed to an alternative of putting
osmin in the same squashfs as the main system image.  I chose to
implement the seperate version, because it guarantees that the install
will remain one long ~2G seekless cdrom read.

This is seperate from the filesystem layout patchset I posted, but
straightforward merging would need to be done if they are both applied.


diff -Naur livecd.200709230129/creator/isotostick.sh livecd.squashedOsmin/creator/isotostick.sh
--- livecd.200709230129/creator/isotostick.sh	2007-09-23 06:29:24.000000000 +0000
+++ livecd.squashedOsmin/creator/isotostick.sh	2007-09-23 06:39:32.000000000 +0000
@@ -208,8 +208,8 @@
 elif [ -f $CDMNT/ext3fs.img ]; then
     cp $CDMNT/ext3fs.img $USBMNT/LiveOS/ext3fs.img || exitclean 
 fi
-if [ -f $CDMNT/osmin.gz ]; then
-    cp $CDMNT/osmin.gz $USBMNT/LiveOS/osmin.gz || exitclean
+if [ -f $CDMNT/osmin.squashfs.img ]; then
+    cp $CDMNT/osmin.squashfs.img $USBMNT/LiveOS/osmin.squashfs.img || exitclean
 fi
 
 cp $CDMNT/isolinux/* $USBMNT/$SYSLINUXPATH
diff -Naur livecd.200709230129/creator/livecd-creator livecd.squashedOsmin/creator/livecd-creator
--- livecd.200709230129/creator/livecd-creator	2007-09-23 06:29:24.000000000 +0000
+++ livecd.squashedOsmin/creator/livecd-creator	2007-09-23 06:34:08.000000000 +0000
@@ -1000,7 +1000,7 @@
     #
     def genMinInstDelta(self):
         # create the sparse file for the minimized overlay
-        fd = os.open("%s/out/osmin" %(self.build_dir,),
+        fd = os.open("%s/data/osmin" %(self.build_dir,),
                      os.O_WRONLY | os.O_CREAT)
         off = long(64L * 1024L * 1024L)
         os.lseek(fd, off, 0)
@@ -1012,7 +1012,7 @@
         osloop.loopsetup()
 
         # associate overlay with loop device
-        minloop = LoopbackMount("%s/out/osmin" %(self.build_dir,), "None")
+        minloop = LoopbackMount("%s/data/osmin" %(self.build_dir,), "None")
         minloop.loopsetup()
 
         # create a snapshot device
@@ -1057,16 +1057,16 @@
         minloop.lounsetup()
 
         # truncate the unused excess portion of the sparse file
-        fd = os.open("%s/out/osmin" %(self.build_dir,), os.O_WRONLY )
+        fd = os.open("%s/data/osmin" %(self.build_dir,), os.O_WRONLY )
         os.ftruncate(fd, minInstDeltaDataLength * 512)
         os.close(fd)
 
-        # the delta data is *extremely* compressible (e.g. 1.2M->7kb)
-        rc = subprocess.call(["/usr/bin/gzip", "osmin"],
-                             cwd="%s/out" %(self.build_dir,),
-                             env={"PWD": "%s/out" %(self.build_dir,)})
-        if rc != 0:
-            raise InstallationError("Could not compress genMinInstDelta data")
+        ret = subprocess.call(["/sbin/mksquashfs", "osmin",
+                               "../out/osmin.squashfs.img"],
+                              cwd="%s/data" %(self.build_dir,),
+                              env={"PWD": "%s/data" %(self.build_dir,)})
+        if ret != 0:
+                raise InstallationError("mksquashfs exited with error (%d)" %(ret,))
 
     def package(self):
         self.createSquashFS()
diff -Naur livecd.200709230129/creator/mayflower livecd.squashedOsmin/creator/mayflower
--- livecd.200709230129/creator/mayflower	2007-09-23 06:29:24.000000000 +0000
+++ livecd.squashedOsmin/creator/mayflower	2007-09-23 07:19:14.000000000 +0000
@@ -626,6 +626,9 @@
     if [ -b "\$SQUASHED_LOOPDEV" ]; then
         echo "KERNEL==\"\${SQUASHED_LOOPDEV#/dev/}\" SYMLINK+=\"live-squashed\"" >> /sysroot/etc/udev/rules.d/50-udev*
     fi
+    if [ -b "\$OSMIN_SQUASHED_LOOPDEV" ]; then
+        echo "KERNEL==\"\${OSMIN_SQUASHED_LOOPDEV#/dev/}\" SYMLINK+=\"live-squashed-osmin\"" >> /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
@@ -641,17 +644,22 @@
 done
 
 # we might have a genMinInstDelta delta file for anaconda to take advantage of
-if [ -e /sysroot/LiveOS/osmin.gz ]; then
-    OSMINGZ=/sysroot/LiveOS/osmin.gz
-elif [ -e /sysroot/osmin.gz ]; then
-    OSMINGZ=/sysroot/osmin.gz
+if [ -e /sysroot/LiveOS/osmin.squashfs.img ]; then
+    OSMINSQFS=/sysroot/LiveOS/osmin.squashfs.img
+elif [ -e /sysroot/osmin.squashfs.img ]; then
+    OSMINSQFS=/sysroot/osmin.squashfs.img
 fi
 
-if [ -n "\$OSMINGZ" ]; then
+if [ -n "\$OSMINSQFS" ]; then
     # decompress the delta data
-    gzip -cd \$OSMINGZ > /osmin
+    dd if=\$OSMINSQFS of=/osmin.squashfs.img 2> /dev/null
+    OSMIN_SQUASHED_LOOPDEV=\$( losetup -f )
+    losetup \$OSMIN_SQUASHED_LOOPDEV /osmin.squashfs.img
+    mkdir -p /squashfs.osmin
+    mount -n -t squashfs -o ro \$OSMIN_SQUASHED_LOOPDEV /squashfs.osmin
     OSMIN_LOOPDEV=\$( losetup -f )
-    losetup \$OSMIN_LOOPDEV /osmin
+    losetup \$OSMIN_LOOPDEV /squashfs.osmin/osmin
+    umount -l /squashfs.osmin
 fi
 
 # we might have an uncompressed embedded ext3  to use as rootfs (uncompressed live)
@@ -722,7 +730,7 @@
     do_live_from_base_loop
 fi
 
-if [ -e /osmin ]; then
+if [ -b "\$OSMIN_LOOPDEV" ]; 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 \$BASE_LOOPDEV ) snapshot \$BASE_LOOPDEV \$OSMIN_LOOPDEV p 8" | dmsetup create --readonly live-osimg-min

--
Fedora-livecd-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/fedora-livecd-list

Reply via email to