The boot parameter rd.live.overlay.readonly would seem to fit your need, but with it, a Fedora LiveOS image fails to boot completely to a graphical desktop.
The following patch to /usr/sbin/dmsquash-live-root in the initramfs achieves your objective:
commit 8850fc92a9b7eb9a6f0c20d6971094668493aea1
Date: Sat Jan 26 15:09:12 2013 -0500
Provide devices to enable booting with rd.live.overlay.readonly=1
diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh
index f302d44..0b1ed20 100755
--- a/modules.d/90dmsquash-live/dmsquash-live-root.sh
+++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh
@@ -110,18 +110,34 @@ do_live_overlay() {
umount -l /run/initramfs/overlayfs || :
fi
- if [ -z "$setup" ]; then
- if [ -n "$devspec" -a -n "$pathspec" ]; then
+ if [ -z "$setup" -o -n "$readonly_overlay" ]; then
+ if [ -n "$setup" ]; then
+ warn "Using temporary overlay."
+ elif [ -n "$devspec" -a -n "$pathspec" ]; then
warn "Unable to find persistent overlay; using temporary"
sleep 5
fi
dd if=/dev/null of=/overlay bs=1024 count=1 seek=$((512*1024)) 2> /dev/null
- losetup $OVERLAY_LOOPDEV /overlay
+ if [ -n "$setup" -a -n "$readonly_overlay" ]; then
+ RO_OVERLAY_LOOPDEV=$( losetup -f )
+ losetup $RO_OVERLAY_LOOPDEV /overlay
+ else
+ losetup $OVERLAY_LOOPDEV /overlay
+ fi
fi
# set up the snapshot
- echo 0 `blockdev --getsz $BASE_LOOPDEV` snapshot $BASE_LOOPDEV $OVERLAY_LOOPDEV p 8 | dmsetup create $readonly_overlay live-rw
+ sz=$(blockdev --getsz $BASE_LOOPDEV)
+ if [ -n "$readonly_overlay" ]; then
+ echo 0 $sz snapshot $BASE_LOOPDEV $OVERLAY_LOOPDEV p 8 | dmsetup create $readonly_overlay live-ro
+ base="/dev/mapper/live-ro"
+ over=$RO_OVERLAY_LOOPDEV
+ else
+ base=$BASE_LOOPDEV
+ over=$OVERLAY_LOOPDEV
+ fi
+ echo 0 $sz snapshot $base $over p 8 | dmsetup create live-rw
}
# live cd helper function
(Here are some instructions for changing files in the initramfs,
that I found helpful.)
Alternatively, you could merge the changes in your overlay with the script on this wiki page:
Following the merge, if the overlay file in the USB/SD device filesystem at /LiveOS/overlay-LIVE-xxxx-xxxx is deleted or renamed, a normal boot of the device will fail to find it and will generate a temporary overlay for that single, non-persistent boot.
If you need to distribute your customized image, the edit-livecd script of the the livecd-tools package was designed for rebuilding an install .iso file from a customized image.
The edit-livecd script is behind on maintenance though and fails.
The editliveos.py script is a replacement available here,
editliveos.py will run in a folder that also contains the fs.py, live.py, creator.py, and util.py files, which have been modified to support editliveos.py. (livecd-tools need not be installed.)
For instructions, run editliveos.py --help, or see this wiki section (expand the [show] frame link),