Mike Dickson wrote:
Is there any chance of getting a current version of RHEL into the Live
CD + Persistence game?
Were you ever able to test those patches I sent you a couple months back
(on fedora)? (and for the most part, posted to this list)
For me, they do basically work in trivial testing scenarios.
The main problem I have mustering any enjoyment developing them is the
utter grossness of what it takes to patch the standard /etc/rc.d/init.d
halt and functions file. (which is needed to defer unmounting of
persistence device until after readonly remounting of rootfs).
I do have an alternate distribution method of the feature, which makes
it more of a proof of concept "live iso patch" to the official f8
livecd, but it's still the same code and mechanism.
The same fragility may still apply to my method that I mentioned months
ago, i.e. that it may become unrecoverably corrupted if not shutdown
cleanly. But I suspect that if I can make the distribution of it as
easy as a 'patch' to apply to the f8 livecd, and get some testers, that
that problem can be solved (pure speculation).
My time estimates are usually overly ambitious, but I'll try to get that
iso-patch posted in a couple hours.
And as I responded long ago to the original criticism of the ugliness of
the halt&functions patching- I totally agree, and am open to suggestions.
Attached is the last patch I sent Mike, which is pretty close to what I
last posted to this list. It's still useful if anyone is interested in
trying to understand the method I'm using. The main thing to simplify
reading it, is
a) ignore the 'overlay=auto' code path. It's a nice feature, but
complexity that should wait for the future when the base case is well
understood, tested and stable. The base case being
b) assume the only use of the patch is with the modified
livecd-iso-to-disk. I.e. the new usage would be
livecd-iso-to-disk --overlay-size-mb 128 /path/to/f8.iso /dev/sdb1
which would initialize a 128M persistence file and cause the bootloader
on the liveusb to use it. I.e. the syslinux append line goes from
root=UUID=abcd-1234
to
root=UUID=abcd-1234 overlay=UUID=abcd-1234
Then, try to ignore the horrendously ugly selinux magic act required to
patch halt&functions, and just look at the contents of the halt.patch
and functions.patch.
-dmc
diff -Naur livecd.git.20071015/config/livecd-fedora-minimal.ks livecd/config/livecd-fedora-minimal.ks
--- livecd.git.20071015/config/livecd-fedora-minimal.ks 2007-10-16 02:06:46.000000000 -0500
+++ livecd/config/livecd-fedora-minimal.ks 2007-10-16 02:09:02.000000000 -0500
@@ -18,5 +18,7 @@
chkconfig
authconfig
rootfiles
+# temporary for persistence/overlay
+patch
%end
diff -Naur livecd.git.20071015/creator/etc_rc.d_init.d_functions.patch livecd/creator/etc_rc.d_init.d_functions.patch
--- livecd.git.20071015/creator/etc_rc.d_init.d_functions.patch 1969-12-31 18:00:00.000000000 -0600
+++ livecd/creator/etc_rc.d_init.d_functions.patch 2007-10-16 02:09:02.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.git.20071015/creator/etc_rc.d_init.d_halt.patch livecd/creator/etc_rc.d_init.d_halt.patch
--- livecd.git.20071015/creator/etc_rc.d_init.d_halt.patch 1969-12-31 18:00:00.000000000 -0600
+++ livecd/creator/etc_rc.d_init.d_halt.patch 2007-10-16 04:33:03.000000000 -0500
@@ -0,0 +1,66 @@
+--- etc_rc.d_init.d_halt.orig 2007-09-26 02:52:18.000000000 -0500
++++ etc_rc.d_init.d_halt 2007-10-16 04:32:49.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
+@@ -196,6 +196,45 @@
+ fstab-decode mount -n -o ro,remount $line
+ done
+
++#
++# LiveOS persistent overlay teardown
++#
++
++# to cleanly unmount the overlayfs, the following procedure works:
++
++# SELinux seems to interfere with the subsequent losetup call
++if [ -x /usr/sbin/getenforce ]; then
++ if [ "x$( /usr/sbin/getenforce )" == "xEnforcing" ]; then
++ /usr/sbin/setenforce Permissive
++ fi
++fi
++
++# 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 /dev/live-overlay-readonly p 8" live-rw
++dmsetup resume live-rw
++
++# now the read-write overlay device can be torn down
++losetup -d /dev/live-overlay
++
++# finally, remount the overlayfs read-only
++if [ ! -L /dev/live-overlay-host ]; then
++ overlayfs_fstype=tmpfs
++ overlayfs_dev=none
++else
++ overlayfs_fstype="$( /lib/udev/vol_id --type /dev/live-overlay-host )"
++ overlayfs_dev=/dev/live-overlay-host
++fi
++mount -n -t ${overlayfs_fstype} -o remount,ro ${overlayfs_dev} /mnt/overlayfs
++overlay_unmount_failed="$?"
++if (($overlay_unmount_failed)); then
++ echo "LiveOS: WARNING: overlay filesystem remount readonly failed"
++fi
++
++#
++# END of LiveOS persistent overlay teardown
++#
++
+ # Now halt or reboot.
+ echo $"$message"
+ if [ -f /fastboot ]; then
diff -Naur livecd.git.20071015/creator/findoverlay livecd/creator/findoverlay
--- livecd.git.20071015/creator/findoverlay 1969-12-31 18:00:00.000000000 -0600
+++ livecd/creator/findoverlay 2007-10-16 02:09:02.000000000 -0500
@@ -0,0 +1,223 @@
+#!/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/overlay-${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/overlay-${LIVEOS_SAFELABEL}-${LIVEOS_UUID}"
+elif ( echo $pathspec | grep -v -q "/" ); then
+ # no leading slash implies prepending of default
+ pathspec="/LiveOS/overlay-${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
+
+ # 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
+ echo "findoverlay: failed to find usable overlay image, setting up non-persistenct ram overlay"
+ # ugly way to emphasize this failure case to the user
+ # todo: perhaps better to just fail with error message, and have user
+ # reboot either without overlay or figure out the problem.
+ sleep 11
+ overlayfs_dev=/dev/null
+ pathspec=/overlay
+ 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
+ dd if=/dev/null of=/mnt/overlayfs/overlay bs=1024 count=1 seek=$((512*1024))
+fi
+
+fodebug "setting up overlay file"
+losetup ${loopdev} /mnt/overlayfs${pathspec}
+OVERLAY_READONLY_LOOPDEV=$( losetup -f )
+losetup -r ${OVERLAY_READONLY_LOOPDEV} /mnt/overlayfs${pathspec}
+echo "KERNEL==\"${overlayfs_dev#/dev/}\" SYMLINK+=\"live-overlay-host\"" >> /overlay.udevrules
+echo "KERNEL==\"${OVERLAY_READONLY_LOOPDEV#/dev/}\" SYMLINK+=\"live-overlay-readonly\"" >> /overlay.udevrules
+
+
diff -Naur livecd.git.20071015/creator/isotostick.sh livecd/creator/isotostick.sh
--- livecd.git.20071015/creator/isotostick.sh 2007-10-16 02:06:46.000000000 -0500
+++ livecd/creator/isotostick.sh 2007-10-16 02:09:02.000000000 -0500
@@ -141,8 +141,13 @@
exit 1
fi
+overlaysizemb=0
while [ $# -gt 2 ]; do
case $1 in
+ --overlay-size-mb)
+ overlaysizemb=$2
+ shift
+ ;;
--noverify)
noverify=1
;;
@@ -223,6 +228,16 @@
# adjust label and fstype
sed -i -e "s/CDLABEL=[^ ]*/$USBLABEL/" -e "s/rootfstype=[^ ]*/rootfstype=$USBFS/" $USBMNT/$SYSLINUXPATH/isolinux.cfg
+if (($overlaysizemb)); then
+ echo "Initializing persistent overlay file"
+ overlayuuid="$( /lib/udev/vol_id -u $USBDEV )"
+ overlayfilename="overlay-$( /lib/udev/vol_id -l $USBDEV )-$( /lib/udev/vol_id -u $USBDEV )"
+ dd if=/dev/null of=$USBMNT/LiveOS/$overlayfilename \
+ count=1 bs=1M seek=$overlaysizemb
+ sed -i -e "s/liveimg/liveimg rw overlay=UUID=${overlayuuid}/" \
+ $USBMNT/$SYSLINUXPATH/isolinux.cfg
+fi
+
echo "Installing boot loader"
if [ "$USBFS" = "vfat" -o "$USBFS" = "msdos" ]; then
# syslinux expects the config to be named syslinux.cfg
diff -Naur livecd.git.20071015/creator/livecd-creator livecd/creator/livecd-creator
--- livecd.git.20071015/creator/livecd-creator 2007-10-16 02:06:46.000000000 -0500
+++ livecd/creator/livecd-creator 2007-10-16 02:36:30.000000000 -0500
@@ -874,6 +874,10 @@
def createInitramfs(self):
mpath = "/usr/lib/livecd-creator/mayflower"
+ # dmc overlay stuff
+ fopath = "/usr/lib/livecd-creator/findoverlay"
+ fppath = "/usr/lib/livecd-creator/etc_rc.d_init.d_functions.patch"
+ hppath = "/usr/lib/livecd-creator/etc_rc.d_init.d_halt.patch"
# look to see if we're running from a git tree; in which case,
# we should use the git mayflower too
@@ -883,12 +887,47 @@
"mayflower")
if os.path.exists(f):
mpath = f
+ # dmc overlay stuff
+ f = os.path.join(os.path.abspath(os.path.dirname(__file__)),
+ "findoverlay")
+ if os.path.exists(f):
+ fopath = f
+ f = os.path.join(os.path.abspath(os.path.dirname(__file__)),
+ "etc_rc.d_init.d_halt.patch")
+ if os.path.exists(f):
+ hppath = f
+ f = os.path.join(os.path.abspath(os.path.dirname(__file__)),
+ "etc_rc.d_init.d_functions.patch")
+ if os.path.exists(f):
+ fppath = f
# Create initramfs
if not os.path.isfile(mpath):
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,))
+
+ #
+ # dmc overlay stuff: copy findoverlay and live tool to target,
+ # as well as /etc/rc.d/init.d/ halt and functions patches
+ #
+ if not os.path.isfile(fopath):
+ raise InstallationError("livecd-creator not correctly installed : "+
+ "/usr/lib/livecd-creator/findoverlay not found")
+ shutil.copy(fopath, "%s/install_root/sbin/findoverlay" %(self.build_dir,))
+
+ if not os.path.isfile(fppath):
+ raise InstallationError("livecd-creator not correctly installed : "+
+ "/usr/lib/livecd-creator/etc_rc.d_init.d_functions.patch not found")
+ shutil.copy(fppath, "%s/install_root/tmp/etc_rc.d_init.d_functions.patch" %(self.build_dir,))
+
+ if not os.path.isfile(hppath):
+ raise InstallationError("livecd-creator not correctly installed : "+
+ "/usr/lib/livecd-creator/etc_rc.d_init.d_halt.patch not found")
+ shutil.copy(hppath, "%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')
@@ -900,6 +939,8 @@
if "=firewire" in self._modules:
mcfg.write('MODULES+="firewire-sbp2 firewire-ohci "\n')
mcfg.write('MODULES+="sbp2 ohci1394 ieee1394 "\n')
+ # dmc overlay stuff
+ mcfg.write('MODULES+="vfat "\n')
self._modules.remove("=firewire")
mcfg.write('MODULES+="%s "\n' %(string.join(self._modules),))
mcfg.close()
@@ -908,7 +949,11 @@
"/boot/livecd-initramfs-%s.img" %(ver,),
ver], preexec_fn=self.run_in_root),
self.getKernelVersions().values())
- for f in ("/sbin/mayflower", "/etc/mayflower.conf"):
+ # dmc overlay stuff: added latter 3 files
+ 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.git.20071015/creator/mayflower livecd/creator/mayflower
--- livecd.git.20071015/creator/mayflower 2007-10-16 02:06:46.000000000 -0500
+++ livecd/creator/mayflower 2007-10-16 03:41:27.000000000 -0500
@@ -80,6 +80,21 @@
cp /bin/dd bin
cp /bin/cut 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/sed bin
+# end overlay stuff
+
+
# we explicitly load these, so should be sure they're present
MODULES="loop dm_snapshot "
@@ -260,6 +275,7 @@
live_ram=0
check_iso=0
live_locale=""
+overlay=""
# Parse kernel commandline options
#
@@ -289,6 +305,12 @@
live_locale=*)
live_locale=\${o#live_locale=}
;;
+ overlay)
+ overlay=auto
+ ;;
+ overlay=*)
+ overlay=\${o#overlay=}
+ ;;
check)
check_iso=1
;;
@@ -592,10 +614,23 @@
# 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
+ OVERLAY_READONLY_LOOPDEV=\$( losetup -f )
+ losetup -r \$OVERLAY_READONLY_LOOPDEV /mnt/overlayfs/overlay
+ echo "KERNEL==\"\${OVERLAY_READONLY_LOOPDEV#/dev/}\" SYMLINK+=\"live-overlay-readonly\"" >> /overlay.udevrules
+ fi
# set up the snapshot
echo 0 \`blockdev --getsize \$BASE_LOOPDEV\` snapshot \$BASE_LOOPDEV \$OVERLAY_LOOPDEV p 8 | dmsetup create live-rw
@@ -605,6 +640,7 @@
ln -s /dev/mapper/live-rw /dev/root
mount -n -t ext3 /dev/mapper/live-rw /sysroot
+
# here you can modify the rw ext3 fs for testing if you don't want to
# respin the entire rootfs (which takes ages). Example
#
@@ -652,6 +688,11 @@
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*
+ cat /overlay.udevrules >> /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
}
@@ -743,6 +784,52 @@
echo "0 \$( blockdev --getsize \$BASE_LOOPDEV ) snapshot \$BASE_LOOPDEV \$OSMIN_LOOPDEV p 8" | dmsetup create --readonly live-osimg-min
fi
+#
+# if not previously applied, apply a patch to the shutdown scripts so
+# they don't try to unmount the live overlay filesystem before the rootfs
+#
+# this is horrendously ugly on multiple levels.
+#
+# technically all the selinux crap should be conditional upon both
+# the presence of /sysroot/etc/selinux/config and its contents grep
+# matching ^SELINUX=enforcing or ^SELINUX=permissive
+#
+# But ALL of this if clause will be ripped out
+if [ ! -f /sysroot/etc/rc.d/init.d/halt.applied.liveos.patch -a -x /sysroot/usr/bin/patch ]; then
+
+ mount -n -o remount,rw /sysroot
+ pushd /sysroot/var/tmp >> /sysroot/var/log/LiveOS.log 2>&1
+ mkdir /selinux >> /sysroot/var/log/LiveOS.log 2>&1
+ mkdir /tmp >> /sysroot/var/log/LiveOS.log 2>&1
+ mkdir -p /etc/selinux/targeted >> /sysroot/var/log/LiveOS.log 2>&1
+ /sysroot/bin/cp -av /sysroot/etc/selinux/targeted/policy /etc/selinux/targeted >> /sysroot/var/log/LiveOS.log 2>&1
+ mount -n -t selinuxfs selinuxfs /selinux >> /sysroot/var/log/LiveOS.log 2>&1
+ /sysroot/usr/sbin/load_policy >> /sysroot/var/log/LiveOS.log 2>&1
+ /sysroot/usr/sbin/setenforce Permissive >> /sysroot/var/log/LiveOS.log 2>&1
+
+ echo "LiveOS initramfs patching /etc/rc.d/init.d/halt" >> /sysroot/var/log/LiveOS.log
+ /sysroot/bin/mv /sysroot/etc/rc.d/init.d/halt ./etc_rc.d_init.d_halt >> /sysroot/var/log/LiveOS.log 2>&1
+ /sysroot/bin/mv /etc/etc_rc.d_init.d_halt.patch /sysroot/etc/rc.d/init.d/halt.applied.liveos.patch >> /sysroot/var/log/LiveOS.log 2>&1
+ /sysroot/usr/bin/patch < /sysroot/etc/rc.d/init.d/halt.applied.liveos.patch >> /sysroot/var/log/LiveOS.log 2>&1
+ /sysroot/bin/mv ./etc_rc.d_init.d_halt /sysroot/etc/rc.d/init.d/halt >> /sysroot/var/log/LiveOS.log 2>&1
+ /sysroot/usr/bin/chcon --user system_u --role object_r --type initrc_exec_t /sysroot/etc/rc.d/init.d/functions >> /sysroot/var/log/LiveOS.log 2>&1
+
+ echo "LiveOS initramfs patching /etc/rc.d/init.d/functions" >> /sysroot/var/log/LiveOS.log
+ /sysroot/bin/mv /sysroot/etc/rc.d/init.d/functions ./etc_rc.d_init.d_functions >> /sysroot/var/log/LiveOS.log 2>&1
+ /sysroot/bin/mv /etc/etc_rc.d_init.d_functions.patch /sysroot/etc/rc.d/init.d/functions.applied.liveos.patch >> /sysroot/var/log/LiveOS.log 2>&1
+ /sysroot/usr/bin/patch < /sysroot/etc/rc.d/init.d/functions.applied.liveos.patch >> /sysroot/var/log/LiveOS.log 2>&1
+ /sysroot/bin/mv ./etc_rc.d_init.d_functions /sysroot/etc/rc.d/init.d/functions >> /sysroot/var/log/LiveOS.log 2>&1
+ /sysroot/usr/bin/chcon --user system_u --role object_r --type bin_t /sysroot/etc/rc.d/init.d/functions >> /sysroot/var/log/LiveOS.log 2>&1
+
+ # oh how I loathe SELinux, let me count the ways...
+ /sysroot/usr/bin/chcon --user system_u --role object_r --type etc_t /sysroot/etc/fstab >> /sysroot/var/log/LiveOS.log 2>&1
+
+ umount -n -t selinuxfs /selinux
+ popd >> /sysroot/var/log/LiveOS.log 2>&1
+ mount -n -o remount,ro /sysroot
+fi
+
+
if [ "\$eshell" == "1" ] ; then
echo "Shell requested on kernel commandline."
echo "Rootfs is mounted ro on /sysroot. Exit to continue booting."
diff -Naur livecd.git.20071015/livecd-tools.spec livecd/livecd-tools.spec
--- livecd.git.20071015/livecd-tools.spec 2007-10-16 02:06:46.000000000 -0500
+++ livecd/livecd-tools.spec 2007-10-16 02:09:02.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.git.20071015/Makefile livecd/Makefile
--- livecd.git.20071015/Makefile 2007-10-16 02:06:46.000000000 -0500
+++ livecd/Makefile 2007-10-16 02:09:02.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
[email protected]
https://www.redhat.com/mailman/listinfo/fedora-livecd-list