Douglas McClendon wrote:
Here is another update to my devicemapper-snapshot based LiveOS persistence implementation.

Actually... _here_ it is.

-dmc

diff -Naur livecd.200709260026/config/livecd-fedora-7-desktop.ks livecd.overlay/config/livecd-fedora-7-desktop.ks
--- livecd.200709260026/config/livecd-fedora-7-desktop.ks	2007-09-22 17:34:53.000000000 -0500
+++ livecd.overlay/config/livecd-fedora-7-desktop.ks	2007-09-26 05:25:44.000000000 -0500
@@ -126,6 +126,30 @@
 
 touch /.liveimg-configured
 
+
+# overlay: temporary *ugly* hack
+if [ ! -f /etc/rc.d/init.d/functions.overlaypatched ]; then
+    if [ -f /var/tmp/etc_rc.d_init.d_functions.patch ]; then
+        pushd /var/tmp
+        cp /etc/rc.d/init.d/functions ./etc_rc.d_init.d_functions
+        patch < etc_rc.d_init.d_functions.patch
+        cp ./etc_rc.d_init.d_functions /etc/rc.d/init.d/functions 
+        popd
+        touch /etc/rc.d/init.d/functions.overlaypatched
+    fi
+fi 
+if [ ! -f /etc/rc.d/init.d/halt.overlaypatched ]; then
+    if [ -f /var/tmp/etc_rc.d_init.d_halt.patch ]; then
+        pushd /var/tmp
+        cp /etc/rc.d/init.d/halt ./etc_rc.d_init.d_halt
+        patch < etc_rc.d_init.d_halt.patch
+        cp ./etc_rc.d_init.d_halt /etc/rc.d/init.d/halt 
+        popd
+        touch /etc/rc.d/init.d/halt.overlaypatched
+    fi
+fi 
+
+
 # mount live image
 if [ -b /dev/live ]; then
    mkdir -p /mnt/live
diff -Naur livecd.200709260026/creator/etc_rc.d_init.d_functions.patch livecd.overlay/creator/etc_rc.d_init.d_functions.patch
--- livecd.200709260026/creator/etc_rc.d_init.d_functions.patch	1969-12-31 18:00:00.000000000 -0600
+++ livecd.overlay/creator/etc_rc.d_init.d_functions.patch	2007-09-26 02:56:09.000000000 -0500
@@ -0,0 +1,20 @@
+--- etc_rc.d_init.d_functions.orig	2007-09-26 02:51:09.000000000 -0500
++++ etc_rc.d_init.d_functions	2007-09-26 02:51:51.000000000 -0500
+@@ -76,7 +76,7 @@
+ 	local remaining sig=
+ 	local retry=3
+ 
+-	remaining=$(LC_ALL=C awk "/^#/ {next} $1" "$2" | sort -r)
++	remaining=$(LC_ALL=C awk "/^#/ {next} $1" "$2" | grep -v overlayfs | sort -r)
+ 	while [ -n "$remaining" -a "$retry" -gt 0 ]; do
+ 		if [ "$retry" -eq 3 ]; then
+ 			action "$3" fstab-decode umount $5 $remaining
+@@ -84,7 +84,7 @@
+ 			action "$4" fstab-decode umount $5 $remaining
+ 		fi
+ 		sleep 2
+-		remaining=$(LC_ALL=C awk "/^#/ {next} $1" "$2" | sort -r)
++		remaining=$(LC_ALL=C awk "/^#/ {next} $1" "$2" | grep -v overlayfs | sort -r)
+ 		[ -z "$remaining" ] && break
+ 		fstab-decode /sbin/fuser -k -m $sig $remaining >/dev/null
+ 		sleep 5
diff -Naur livecd.200709260026/creator/etc_rc.d_init.d_halt.patch livecd.overlay/creator/etc_rc.d_init.d_halt.patch
--- livecd.200709260026/creator/etc_rc.d_init.d_halt.patch	1969-12-31 18:00:00.000000000 -0600
+++ livecd.overlay/creator/etc_rc.d_init.d_halt.patch	2007-09-26 05:19:52.000000000 -0500
@@ -0,0 +1,84 @@
+--- etc_rc.d_init.d_halt.orig	2007-09-26 02:52:18.000000000 -0500
++++ etc_rc.d_init.d_halt	2007-09-26 05:19:18.000000000 -0500
+@@ -130,7 +130,7 @@
+ 
+ # Try to unmount tmpfs filesystems to avoid swapping them in.  Ignore failures.
+ tmpfs=$(awk '$2 ~ /^\/($|proc|dev)/ { next; }
+-	     $3 == "tmpfs" { print $2; }' /proc/mounts | sort -r)
++	     $3 == "tmpfs" { print $2; }' /proc/mounts | grep -v overlayfs | sort -r)
+ [ -n "$tmpfs" ] && fstab-decode umount $tmpfs 2>/dev/null
+ 
+ # Turn off swap, then unmount file systems.
+@@ -181,7 +181,7 @@
+ # Try all file systems other than root, essential filesystems and RAM disks,
+ # one last time.
+ awk '$2 !~ /\/(|dev|proc|selinux)$/ && $1 !~ /^\/dev\/ram/ { print $2 }' \
+-    /proc/mounts | sort -r | \
++    /proc/mounts | grep -v overlayfs | sort -r | \
+   while read line; do
+     fstab-decode umount -f $line
+ done
+@@ -190,12 +190,63 @@
+    /sbin/halt.local
+ fi
+ 
++#
++# LiveOS persistent overlay teardown preperation
++#
++if [ -f /var/tmp/.overlay.info.dontdeleteme ]; then
++    unmount_overlayfs=1
++    # read overlayfs info
++    overlay_inuse_file=$( < /var/tmp/.overlay.info.dontdeleteme )
++    source $overlay_inuse_file
++    # note: /var/run would seem to be more appropriate than /var/tmp, but
++    #       it wasn't used because the file is created before rc.sysinit
++    #       wipes /var/run.
++    rm -f /var/tmp/.overlay.info.dontdeleteme 
++else
++    unmount_overlayfs=0
++fi
++
++
+ # Remount read only anything that's left mounted.
+ # echo $"Remounting remaining filesystems readonly"
+ mount | awk '{ print $3 }' | while read line; do
+     fstab-decode mount -n -o ro,remount $line
+ done
+ 
++#
++# LiveOS persistent overlay teardown
++#
++if (($unmount_overlayfs)); then
++    # to cleanly unmount the overlayfs, the following procedure works:
++
++    # slap SELinux down, to permit subsequent losetup call
++    if [ -x /usr/sbin/getenforce ]; then
++	if [ "x$( /usr/sbin/getenforce )" == "xEnforcing" ]; then
++	    /usr/sbin/setenforce Permissive
++	fi
++    fi
++
++    liveos_root_overlay_readonly_loopdev=$( losetup -f )
++    /sbin/losetup -r ${liveos_root_overlay_readonly_loopdev} \
++	/mnt/overlayfs${overlayfs_path}
++
++    # next, replace the devicemapper live-rw snapshot table, with a new
++    # table that has the read-only loop device instead
++    dmsetup load --table "0 $( blockdev --getsize /dev/live-osimg ) snapshot /dev/live-osimg $liveos_root_overlay_readonly_loopdev p 8" live-rw
++    dmsetup resume live-rw
++
++    # now the read-write overlay device can be torn down
++    losetup -d /dev/live-overlay
++
++    # remove the .inuse file, as the overlay file has now been cleanly torn
++    # down. (at least as far as writing to it is concerned) 
++    rm -v -f $overlay_inuse_file
++
++    # finally, remount the overlayfs read-only
++    # TODO: support ntfs (-n does not work, perhaps other issues also)
++    mount -n -t ${overlayfs_fstype} -o remount,ro ${overlayfs_dev} /mnt/overlayfs
++fi
++
+ # Now halt or reboot.
+ echo $"$message"
+ if [ -f /fastboot ]; then
diff -Naur livecd.200709260026/creator/findoverlay livecd.overlay/creator/findoverlay
--- livecd.200709260026/creator/findoverlay	1969-12-31 18:00:00.000000000 -0600
+++ livecd.overlay/creator/findoverlay	2007-09-26 05:17:51.000000000 -0500
@@ -0,0 +1,310 @@
+#!/bin/bash
+#
+# findoverlay - set up persistence overlay loop device (/dev/live-overlay)
+#
+# Copyright 2007 Douglas McClendon <[EMAIL PROTECTED]>
+#
+# Licensed under the GPLv2. See the file COPYING for details. 
+#
+
+# the overlay option value is pulled by init's parsing of /proc/cmdline
+loopdev=$1
+overlay=$2
+quiet=$3
+
+function fodebug {
+    if ((!${quiet})); then
+	echo "findoverlay: $*"
+    fi
+}
+
+fodebug "starting..."
+
+# get the (safe)label and uuid of the live media
+# /dev/root is still the cdrom/usb at this point in time
+LIVEOS_SAFELABEL=$( vol_id -l /dev/root )
+LIVEOS_UUID=$( vol_id -u /dev/root )
+
+fodebug "LiveOS SAFELABEL-UUID is ${LIVEOS_SAFELABEL}-${LIVEOS_UUID}"
+
+# calculate pathspec from overlay option, i.e. stuff following the ':'
+if ( echo $overlay | grep -q ":" ); then
+    # pathspec specified, extract
+    pathspec=$( echo $overlay | sed -e 's/^.*://' )
+else
+    # no pathspec specified, set default
+    pathspec="/LiveOS/Persistence-${LIVEOS_SAFELABEL}-${LIVEOS_UUID}"
+fi
+
+# handle special formats of pathspec
+if [ "x${pathspec}" == "x" -o "${pathspec}" == "auto" ]; then
+    # empty or auto pathspec specified, set to default
+    pathspec="/LiveOS/Persistence-${LIVEOS_SAFELABEL}-${LIVEOS_UUID}"
+elif ( echo $pathspec | grep -v -q "/" ); then
+    # no leading slash implies prepending of default
+    pathspec="/LiveOS/Persistence-${LIVEOS_SAFELABEL}-${LIVEOS_UUID}-${pathspec}"
+fi
+
+fodebug "calculated pathspec is ${pathspec}"
+
+# calculate devspec from overlay option, i.e. stuff preceding the ':'
+devspec=$( echo $overlay | sed -e 's/:.*$//' )
+if [ ! -n "$devspec" ]; then
+    # no devspec, revert to default of auto
+    devspec="auto"
+fi
+
+fodebug "calculated devspec is ${devspec}"
+
+# load filesystem modules that may be required for overlay
+# TODO: only load these conditionally if vol_id detects a fs that needs them
+#       or find out if they are autoloaded autmatically 
+
+# for typical vfat on usbstick
+# testing autoload
+#modprobe vfat
+# for typical ntfs on usbstick or host disk
+#modprobe fuse
+# for typical ext3
+# assumption: ext3 is already loaded
+
+# check if devspec is auto
+numcandidates=0
+candidates=""
+if [ "$devspec" == "auto" ]; then
+    # if devspec is auto, search all possible devices, for now that means:
+    # /dev/sd* /dev/scd* /dev/sr*
+    devices="$( find /dev -name "sd*" -print 2> /dev/null ) $( find /dev -name "scd*" -print 2> /dev/null ) $( find /dev -name "sr*" -print 2> /dev/null)"
+    fodebug "found devices are $devices"
+    mkdir /testmount
+    for device in $devices; do
+	fodebug "about to test readonly on device $device"
+	devro=$( blockdev --getro $device 2> /dev/null )
+	if (($?)); then
+	    devusable=0
+	else
+	    if (( $devro )); then
+		devusable=0
+	    else
+		devusable=1
+	    fi
+	fi
+	if (( $devusable )); then 
+	    blockdev --setro $device
+	    fodebug "about to test mount device $device"
+	    fstype=$( vol_id -t $device )
+	    if  [ "$fstype" == "vfat" ]; then
+		mountcom="mount -n -t vfat -o ro"
+# ntfs currently unsupported
+#	    elif [ "$fstype" == "ntfs" ]; then
+#		mountcom="mount.ntfs-3g -t ntfs -o ro"
+	    elif  [ "$fstype" == "ext3" ]; then
+		mountcom="mount -n -t ext3 -o ro"
+	    else
+		fodebug "unsupported filesystem found, trying auto"
+		mountcom="mount -n -t auto -o ro"
+	    fi
+	    if ( $mountcom $device /testmount > /dev/null 2>&1 ); then
+		fodebug "about to look for /testmount/${pathspec} on $device"
+		if [ -f /testmount/${pathspec} ]; then
+		    fodebug "found /testmount/${pathspec} on $device"
+		    numcandidates=$(( $numcandidates + 1 ))
+		    candidates="$candidates $device"
+		    fodebug "numcandidates is now $numcandidates"
+		    fodebug "candidates is now $candidates"
+		fi
+		fodebug "about to unmount device $device"
+		umount /testmount
+	    fi
+	    blockdev --setrw $device
+	fi
+    done
+    rmdir /testmount
+    
+    # if more than one possible overlay images were found, the user must
+    # be prompted.  This input mechanism is pretty simplistic.  Hopefully
+    # there will be some slick gdm/X gui at some point.
+    if [ $numcandidates -gt 1 ]; then
+	xdone=0
+	while (( ! $xdone )); do
+	    echo -en "\n\n\nfindoverlay: multiple overlay images found, plese select one:\n\n\n"
+	    echo -en "choices:\n\n"
+	    echo -en "0: ignore overlay images, create fresh overlay in ram\n"
+	    candidatenum=1
+	    for candidate in $candidates; do
+		cfslabel="$( /sbin/vol_id -L $candidate )"
+		cuuid="$( /sbin/vol_id -u $candidate )"
+		cfstype="$( /sbin/vol_id -t $candidate )"
+		echo -en "${candidatenum}: ${candidate} LABEL=${cfslabel} FSTYPE=${cfstype} UUID=${cuuid}\n"
+		candidatenum=$(( $candidatenum + 1 ))
+	    done
+	    echo -en "\n\nchoice? (60 second timeout, default: 0)"
+	    read -t 60 choice
+
+	    candidatenum=1
+	    for candidate in $candidates; do
+		if [ $choice -eq $candidatenum ]; then
+		    pdev=$candidate
+		fi
+		candidatenum=$(( $candidatenum + 1 ))
+	    done
+
+	    if (( ! $choice )); then
+		pdev=tmpfs
+		xdone=1
+	    elif ( blockdev $pdev > /dev/null 2>&1 ); then
+		xdone=1
+	    else
+		echo -en "\n\nInvalid Choice - Please Choose Again\n\n"
+	    fi
+	done
+    elif [ $numcandidates -eq 0 ]; then
+	pdev=""
+    else
+	pdev=$candidates
+    fi
+else
+    # specific devspec given
+    
+    # normalize devicename
+    #
+    # devspec may be of the following forms:
+    #
+    # /dev/sda1             # normalized form
+    # sda1
+    # LABEL=MyLABEL
+    # UUID=MyUUID
+    if ( echo $devspec | grep -q "^UUID=" ); then
+	cuuid=$( echo $devspec | sed -e 's/^UUID=//' )
+	pdev=$( findfs UUID=${cuuid} )
+    elif ( echo $devspec | grep -q "^LABEL=" ); then
+	clabel=$( echo $devspec | sed -e 's/^LABEL=//' )
+	pdev=$( findfs LABEL=${clabel} )
+    elif ( echo $devspec | grep -q '/' ); then
+	pdev=$devspec
+    else
+	pdev="/dev/${devspec}"
+    fi
+fi
+
+# now that we have the normalized reference to the persistence device
+# set it up
+fodebug "pdev is xx $pdev xx"
+# remove leading and trailing whitespace, perhaps unnecessary
+pdev=$( echo $pdev | sed -e 's/^\s*//' | sed -e 's/\s*$//' )
+fodebug "now pdev is xx $pdev xx"
+pmounted=0
+if ( blockdev $pdev > /dev/null 2>&1 ); then
+    fodebug "about to mount persistence device $pdev"
+    mount -n -t auto $pdev /mnt/overlayfs
+    ofstype="$( /sbin/vol_id -t $pdev )"
+    pmounted=1
+fi
+
+if [ -w "/mnt/overlayfs${pathspec}" ]; then
+    fodebug "setting up overlay file"
+    losetup ${loopdev} /mnt/overlayfs${pathspec}
+    echo "overlayfs_dev=${pdev}" > /mnt/overlayfs${pathspec}.inuse
+    echo "overlayfs_fstype=${ofstype}" >> /mnt/overlayfs${pathspec}.inuse
+    echo "overlayfs_path=${pathspec}" >> /mnt/overlayfs${pathspec}.inuse
+    echo "/mnt/overlayfs${pathspec}.inuse" > /overlay.info
+else
+    echo "findoverlay: failed to find usable overlay image, setting up non-persistenct ram overlay"
+    # ugly way to emphasize this failure case to the user
+    sleep 7
+    mount -n -t tmpfs -o mode=0755 none /mnt/overlayfs  
+    dd if=/dev/null of=/mnt/overlayfs/overlay bs=1024 count=1 seek=$((512*1024)) 2> /dev/null
+    losetup ${loopdev} /mnt/overlayfs/overlay
+fi
+
+
+# TODO: while mount scanning find a way to determine if the filesystem was 
+#       not cleanly unmounted.  If so, IGNORE IT as it may be part of a 
+#       hibernated OS !!
+#
+#       However, If the overlay file has a kin file with the suffix .inuse, 
+#       this is evidence that that the overlay device was not unmounted 
+#       cleanly.  In _this_ case, look at the filesystem(???) and determine 
+#       whether or not the most recent mount of the filesystem is more recent
+#       than the inuse file.  *If and only if* NOT, then it is safe to assume
+#       that the filesystem is not part of a hibernated OS, and rather was
+#       most recently used as a persistence device that failed to be
+#       shutdown cleanly, thus it is safe to fsck the overlayfs, and then 
+#       fsck the overlay-rootfs
+
+# TODO: since ext3 is impossible to truly mount readonly*, and since 
+#       similar issues may exist in other fs (ntfs???),  it may be useful
+#       to have a function called really_mount_readonly() which does a 
+#       blockdev --setro, then does a devicemapper snapshot to ram, then 
+#       does a mount of the snapshotted device, then checks for existence of 
+#       overlay and .inuse files.
+#
+#       Given the above function, if a persistence file is detected, but the 
+#       above above inuse/recent-mount-stamp test fails, give the user a 30-60
+#       second timeout option to force an fsck and mount of the uncleanly 
+#       mounted overlayfs, defaulting to not using it.
+#
+# * this is verified.  After taking an uncleanly unmounted ext3fs, and doing
+#   a blockdev --setro, trying to mount ro as ext3 gets
+#   "EXT3-fs: INFO: recovery required on readonly filesystem"
+#   "EXT3-fs: write access unavailable, connot proceed"
+#   and what is worse, is trying to mount ro as ext2 gets
+#   "EXT2-fs: sdb1: couldn't mount becuase of unsupported optional features (4)"
+#
+
+
+# TODO: handle nfs/network(fuse-httpfs?) persistence devices.  This will
+#       require the ability to set up the network here, which is probably
+#       not trivial.
+
+# TODO: handle fsck'ing the rootfs if need be correctly?  Or does the right
+#       thing just happen.  I know that trying to use a persistence file
+#       from something that got unmounted uncleanly, seems to cause problems
+#       VERY quickly.  This may be a fatal flaw...  (or at least require
+#       some work).  Perhaps the issue has something to do with not using
+#       sync behavior on the overlay file, or a bug that can be fixed with
+#       devmapper.  More testing should flush this issue out.  
+#
+#       The problem I am seeing is immediate errors after the initial 
+#       read-write mount of the base+overlay snapshot live-rw device.
+#       I.e. I get dropped to emergency shell in mayflower init, due to 
+#       failure to "mv /overlay.info /sysroot/var/tmp/.overlay.info.dontdeleteme"
+#       The error message reads
+#       
+#       EXT3-fs error (device dm-0): htree_dirblock_to_tree: bad entry in directory #65537: rec_len % 4 != 0 - offset=0, inode=1008746032, rec_len=14677, name_len=48
+#
+#      and the error repeats as I try to do anything.  I was able to
+#      remount it readonly, but unable to even do ls /sysroot/sbin
+#
+#      I then proceeded to use dm to create a mounted version of just the
+#      base ext3fs, so that I could use that fsck.ext3 on the base+overlay.
+#      after fixing a bazillion things, the overlay storage didn't blow up,
+#      and I did see my old test data files under /sysroot/root, however
+#      an ls of /sysroot/usr yielded just 10 timezone entries.  I.e. 
+#      massive data corruption.
+#
+#      I am thinking there may be a fatal flaw here.
+#
+#      Thoughts I have involve...  opening the persistence device with O_SYNC
+#      or O_DIRECT or something.  Unfortunately that may well kill flash 
+#      drives that don't like frequent writes.  A workaround on top of that
+#      might be markmc's dm-snapshot merge.  I.e. open a ram snapshot on top
+#      of the existing snapshot, and then just remerge it once every 5
+#      minutes or something.  Or perhaps some dm/ext3 guru can look at the 
+#      above output and think about the setup and yield a better fix.
+#      Certainly it looks like the present code is unusable, as a cord yank
+#      seems like it could create this situation.
+#
+#      Alternate persistence implementations could involve unionfs (there
+#      are many varieties, and could quite possibly be acceptable in this
+#      scenario).  Or perhaps just good integration of seperate filesystems
+#      getting mounted automatically at boot time, with some sort of 
+#      autostartish mechanism to inject things into the boot process.
+#
+#      Or perhaps markmc-dmsnapshot-merging only on clean shutdown.
+#
+#      Or perhaps I screwed up above, and should have fsck'd the overlayfs?
+#
+#      Are there perhaps some strange interactions with journaling and
+#      snapshot overlays?
+#
\ No newline at end of file
diff -Naur livecd.200709260026/creator/livecd-creator livecd.overlay/creator/livecd-creator
--- livecd.200709260026/creator/livecd-creator	2007-09-25 20:54:18.000000000 -0500
+++ livecd.overlay/creator/livecd-creator	2007-09-26 05:38:48.000000000 -0500
@@ -854,6 +854,31 @@
             raise InstallationError("livecd-creator not correctly installed : "+
                                     "/usr/lib/livecd-creator/mayflower not found")
         shutil.copy(mpath, "%s/install_root/sbin/mayflower" %(self.build_dir,))
+
+        #
+        # overlay: copy findoverlay and live tool to target, as well as
+        #          /etc/rc.d/init.d/ halt and functions patches
+        #
+        if not os.path.isfile("/usr/lib/livecd-creator/findoverlay"):
+            raise InstallationError("livecd-creator not correctly installed : "+
+                                    "/usr/lib/livecd-creator/findoverlay not found")
+        shutil.copy("/usr/lib/livecd-creator/findoverlay",
+                        "%s/install_root/sbin/findoverlay" %(self.build_dir,))
+
+        # TODO: this patch process is not elegant, find a better way
+        if not os.path.isfile("/usr/lib/livecd-creator/etc_rc.d_init.d_functions.patch"):
+            raise InstallationError("livecd-creator not correctly installed : "+
+                                    "/usr/lib/livecd-creator/etc_rc.d_init.d_functions.patch not found")
+        shutil.copy("/usr/lib/livecd-creator/etc_rc.d_init.d_functions.patch",
+                        "%s/install_root/tmp/etc_rc.d_init.d_functions.patch" %(self.build_dir,))
+        if not os.path.isfile("/usr/lib/livecd-creator/etc_rc.d_init.d_halt.patch"):
+            raise InstallationError("livecd-creator not correctly installed : "+
+                                    "/usr/lib/livecd-creator/etc_rc.d_init.d_halt.patch not found")
+        shutil.copy("/usr/lib/livecd-creator/etc_rc.d_init.d_halt.patch",
+                        "%s/install_root/tmp/etc_rc.d_init.d_halt.patch" %(self.build_dir,))
+        
+
+
         # modules we want to support for booting
         mcfg = open(self.build_dir + "/install_root/etc/mayflower.conf", "a")
         mcfg.write('MODULES+="squashfs ext3 ext2 vfat msdos "\n')
@@ -862,12 +887,17 @@
         mcfg.write('MODULES+="sr_mod sd_mod ide-cd "\n')
         mcfg.write('MODULES+="=ata "\n')
         mcfg.write('MODULES+="sym53c8xx aic7xxx "\n')
+        # overlay/persistence
+        mcfg.write('MODULES+="vfat "\n')
         mcfg.close()
 
         subprocess.call(["/sbin/mayflower", "-f", "/boot/livecd-initramfs.img",
                         self.get_kernel_version()],
                         preexec_fn=self.run_in_root)
-        for f in ("/sbin/mayflower", "/etc/mayflower.conf"):
+        for f in ("/sbin/mayflower", "/etc/mayflower.conf",
+                  "/sbin/findoverlay",
+                  "/tmp/etc_rc.d_init.d_functions.patch",
+                  "/tmp/etc_rc.d_init.d_halt.patch"):
             os.unlink("%s/install_root/%s" %(self.build_dir, f))
 
     def relabelSystem(self):
diff -Naur livecd.200709260026/creator/mayflower livecd.overlay/creator/mayflower
--- livecd.200709260026/creator/mayflower	2007-09-25 20:54:18.000000000 -0500
+++ livecd.overlay/creator/mayflower	2007-09-26 05:43:25.000000000 -0500
@@ -79,6 +79,26 @@
 cp /sbin/dmsetup sbin
 cp /bin/dd bin
 
+
+#
+# overlay: tools needed by findoverlay
+#
+cp /sbin/findoverlay sbin
+# this patch percolation is a temporary *ugly* hack
+cp /tmp/etc_rc.d_init.d_functions.patch etc
+cp /tmp/etc_rc.d_init.d_halt.patch etc
+cp /lib/udev/vol_id sbin
+cp /sbin/findfs sbin
+cp /usr/bin/find bin
+
+cp /bin/rmdir bin
+cp /bin/sed bin
+cp /bin/mv bin
+cp /bin/cp bin
+cp /bin/touch bin
+# end overlay stuff
+
+
 # we explicitly load these, so should be sure they're present
 MODULES="loop dm_snapshot "
 
@@ -259,6 +279,7 @@
 live_ram=0
 check_iso=0
 live_locale=""
+overlay=""
 
 # Parse kernel commandline options
 #
@@ -288,6 +309,12 @@
     live_locale=*)
         live_locale=\${o#live_locale=}
         ;;
+    overlay)
+        overlay=auto
+        ;;
+    overlay=*)
+        overlay=\${o#overlay=}
+        ;;
     check)
         check_iso=1
         ;;
@@ -578,10 +605,20 @@
 
 # live cd helper function
 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
+
     OVERLAY_LOOPDEV=\$( losetup -f )
-    losetup \$OVERLAY_LOOPDEV /overlay
+
+    # create a sparse file for the overlay
+    # overlay: if non-ram overlay searching is desired, do it,
+    #              otherwise, create traditional overlay in ram
+    mkdir -p /mnt/overlayfs
+    if [ "x\${overlay}" != "x" ]; then
+        /sbin/findoverlay "\$OVERLAY_LOOPDEV" "\$overlay" $opt_verbose
+    else
+        mount -n -t tmpfs -o mode=0755 none /mnt/overlayfs
+        dd if=/dev/null of=/mnt/overlayfs/overlay bs=1024 count=1 seek=$((512*1024)) 2> /dev/null
+        losetup \$OVERLAY_LOOPDEV /mnt/overlayfs/overlay
+    fi
 
     # set up the snapshot
     echo 0 \`blockdev --getsize \$BASE_LOOPDEV\` snapshot \$BASE_LOOPDEV \$OVERLAY_LOOPDEV p 8 | dmsetup create live-rw
@@ -591,6 +628,13 @@
     ln -s /dev/mapper/live-rw /dev/root
 
     mount -n -t ext3 /dev/mapper/live-rw /sysroot
+
+    if [ -f /overlay.info ]; then
+        /bin/mv /overlay.info /sysroot/var/tmp/.overlay.info.dontdeleteme
+        /bin/mv /etc/etc_rc.d_init.d_functions.patch /sysroot/var/tmp/
+        /bin/mv /etc/etc_rc.d_init.d_halt.patch /sysroot/var/tmp/
+    fi
+
     # here you can modify the rw ext3 fs for testing if you don't want to
     # respin the entire rootfs (which takes ages). Example
     #
@@ -636,6 +680,10 @@
     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*
 
+    # move overlay mount
+    mkdir -p /sysroot/mnt/overlayfs
+    mount -n --move /mnt/overlayfs /sysroot/mnt/overlayfs
+
     mount -n -o ro,remount /sysroot
 }
 
diff -Naur livecd.200709260026/livecd-tools.spec livecd.overlay/livecd-tools.spec
--- livecd.200709260026/livecd-tools.spec	2007-09-25 20:54:18.000000000 -0500
+++ livecd.overlay/livecd-tools.spec	2007-09-26 05:31:00.000000000 -0500
@@ -51,6 +51,9 @@
 %{_bindir}/livecd-iso-to-disk
 %dir /usr/lib/livecd-creator
 /usr/lib/livecd-creator/mayflower
+/usr/lib/livecd-creator/findoverlay
+/usr/lib/livecd-creator/etc_rc.d_init.d_halt.patch
+/usr/lib/livecd-creator/etc_rc.d_init.d_functions.patch
 %dir %{_datadir}/livecd-tools
 %{_datadir}/livecd-tools/*
 
diff -Naur livecd.200709260026/Makefile livecd.overlay/Makefile
--- livecd.200709260026/Makefile	2007-09-25 20:54:18.000000000 -0500
+++ livecd.overlay/Makefile	2007-09-26 02:47:44.000000000 -0500
@@ -12,6 +12,9 @@
 	$(INSTALL_PROGRAM) -D creator/livecd-creator $(DESTDIR)/usr/bin/livecd-creator
 	$(INSTALL_PROGRAM) -D creator/isotostick.sh $(DESTDIR)/usr/bin/livecd-iso-to-disk
 	$(INSTALL_PROGRAM) -D creator/mayflower $(DESTDIR)/usr/lib/livecd-creator/mayflower
+	$(INSTALL_PROGRAM) -D creator/findoverlay $(DESTDIR)/usr/lib/livecd-creator/findoverlay
+	$(INSTALL_PROGRAM) -D creator/etc_rc.d_init.d_halt.patch $(DESTDIR)/usr/lib/livecd-creator/etc_rc.d_init.d_halt.patch
+	$(INSTALL_PROGRAM) -D creator/etc_rc.d_init.d_functions.patch $(DESTDIR)/usr/lib/livecd-creator/etc_rc.d_init.d_functions.patch
 	$(INSTALL_DATA) -D AUTHORS $(DESTDIR)/usr/share/doc/livecd-tools-$(VERSION)/AUTHORS
 	$(INSTALL_DATA) -D COPYING $(DESTDIR)/usr/share/doc/livecd-tools-$(VERSION)/COPYING
 	$(INSTALL_DATA) -D README $(DESTDIR)/usr/share/doc/livecd-tools-$(VERSION)/README
--
Fedora-livecd-list mailing list
Fedora-livecd-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-livecd-list

Reply via email to