* [PATCH] Boot a Live USB device as read-only after persisting some changes.
@ 2013-08-12 4:46 Frederick Grose
[not found] ` <CAEcBt+WE6RKc_QBSrn8WM_Q6tcrbxS8+ZoqXhQMXzyJ7gOuDyA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Frederick Grose @ 2013-08-12 4:46 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA,
livecd-TuqUDEhatI4ANWPb/1PvSmm0pvjS0E/A,
spins-TuqUDEhatI4ANWPb/1PvSmm0pvjS0E/A
In cases where one would like to make some changes or customizations
on an installed Live USB device and then protect the device
filesystems from further persistent changes, one can boot the device
with the rd.live.overlay.readonly option. This protects the root
operating filesystem, but leaves as read-write both the home.img
filesystem, if used, (needed for encrypting the /home contents) and
the base device filesystem, such as /dev/sdc1.
The following patches adjust the boot scripts dmsquash-live-root.sh
and livesys to enable the base device filesystem, livedev, and the
home.img filesystem, if present, to be mounted read-only at boot and
stay read-only during use. Temporary overlays are created in memory
for device-mapper snapshot targets for the filesystems to handle
non-persistent storage content.
Adjust the boot command line option from rw to ro to invoke the
read-only configuration on all of the discussed filesystems.
rd.live.overlay.readonly may be used as before to add a non-persistent
overlay over an existing persistent overlay to limit further root
filesystem changes. Adjust the /syslinux/syslinux.cfg or
extlinux.conf file on the device to standardize the desired default
configuration. Adjust further, if one wishes later to make more
persistent changes.
The following patches have been tested for the common configurations
described above. Special devspec or pathspec arguments for overlay=
or persistenthome= command line options should be further tested.
A method to call for the check of a persistent home filesystem before
mounting during the next boot has also been added.
--Fred
commit a6cd70fc9df2d299ed4f347461c33e4824df62f0
Author: Frederick Grose <fgrose-agl9EP5VjmEgsBAKwltoeQ@public.gmane.org>
Date: Mon Aug 12 00:12:25 2013 -0400
Enable read-only mounting of a persistent home.img filesystem.
Enable one to call for filesystem checking of home.img before
mounting on the next boot.
diff --git a/fedora-live-base.ks b/fedora-live-base.ks
index 6c76e96..0512f67 100644
--- a/fedora-live-base.ks
+++ b/fedora-live-base.ks
@@ -116,9 +116,13 @@ mountPersistentHome() {
elif [ ! -b "\$homedev" ]; then
loopdev=\`losetup -f\`
if [ "\${homedev##/run/initramfs/live}" != "\${homedev}" ]; then
- action "Remounting live store r/w" mount -o remount,rw
/run/initramfs/live
+ if [ "\$liverw" = rw ]; then
+ action "Remounting live store r/w" mount -o remount,rw
/run/initramfs/live
+ else
+ opts="-r"
+ fi
fi
- losetup \$loopdev \$homedev
+ losetup \$opts \$loopdev \$homedev
homedev=\$loopdev
fi
@@ -130,6 +134,22 @@ mountPersistentHome() {
homedev=/dev/mapper/EncHome
fi
+ # If read-only is requested, prepare a non-persistent overlay and
snapshot target.
+ if [ "\$opts" = "-r" ]; then
+ dd if=/dev/null of=/run/initramfs/overlayfs/home_overlay bs=1024
count=1 seek=\$((512*1024)) 2> /dev/null
+ HOME_OVERLAY_LOOPDEV=\$(losetup -f)
+ losetup \$HOME_OVERLAY_LOOPDEV /run/initramfs/overlayfs/home_overlay
+ sz=\$(blockdev --getsz \$homedev)
+ echo 0 \$sz snapshot \$homedev \$HOME_OVERLAY_LOOPDEV N 8 |
dmsetup create home-rw
+ homedev=/dev/mapper/home-rw
+ fi
+
+ # Check the filesystem, if requested.
+ if [ -e /forcehomefsck ]; then
+ e2fsck -f -y -v \$homedev || e2fsck -f -y \$homedev
+ rm /forcehomefsck
+ fi
+
# and finally do the mount
mount \$mountopts \$homedev /home
# if we have /home under what's passed for persistent home, then
commit 96ff19a87c0be1eca27860aeef5434513b0e8c61
Author: Frederick Grose <fgrose-agl9EP5VjmEgsBAKwltoeQ@public.gmane.org>
Date: Mon Aug 12 00:29:27 2013 -0400
Allow read-only mounting of the base device filesystem, livedev.
Use read-only loop devices and non-persistent overlay targets.
diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh
b/modules.d/90dmsquash-live/dmsquash-live-root.sh
index 14e84e1..af0022f 100755
--- a/modules.d/90dmsquash-live/dmsquash-live-root.sh
+++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh
@@ -24,7 +24,7 @@ squash_image=$(getarg rd.live.squashimg)
getargbool 0 rd.live.ram -d -y live_ram && live_ram="yes"
getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes"
-getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay &&
readonly_overlay="--readonly" || readonly_overlay=""
+getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay &&
readonly_overlay="-r" || readonly_overlay=""
overlay=$(getarg rd.live.overlay -d overlay)
# CD/DVD media check
@@ -105,17 +105,23 @@ do_live_overlay() {
setup=""
if [ -n "$devspec" -a -n "$pathspec" -a -n "$overlay" ]; then
mkdir -m 0755 /run/initramfs/overlayfs
- mount -n -t auto $devspec /run/initramfs/overlayfs || :
- if [ -f /run/initramfs/overlayfs$pathspec -a -w
/run/initramfs/overlayfs$pathspec ]; then
- losetup $OVERLAY_LOOPDEV /run/initramfs/overlayfs$pathspec
- if [ -n "$reset_overlay" ]; then
- dd if=/dev/zero of=$OVERLAY_LOOPDEV bs=64k count=1
conv=fsync 2>/dev/null
+ mount -n -t auto -o $liverw $devspec /run/initramfs/overlayfs || :
+ if [ -f /run/initramfs/overlayfs$pathspec ]; then
+ if [ "$liverw" = ro ]; then
+ readonly_overlay='-r'
+ fi
+ losetup $readonly_overlay $OVERLAY_LOOPDEV
/run/initramfs/overlayfs$pathspec
+ if [ -w /run/initramfs/overlayfs$pathspec ]; then
+ if [ -n "$reset_overlay" ]; then
+ dd if=/dev/zero of=$OVERLAY_LOOPDEV bs=64k
count=1 conv=fsync 2>/dev/null
+ fi
fi
setup="yes"
fi
umount -l /run/initramfs/overlayfs || :
fi
+ persistent='P'
if [ -z "$setup" -o -n "$readonly_overlay" ]; then
if [ -n "$setup" ]; then
warn "Using temporary overlay."
@@ -123,6 +129,7 @@ do_live_overlay() {
warn "Unable to find persistent overlay; using temporary"
sleep 5
fi
+ persistent='N'
dd if=/dev/null of=/overlay bs=1024 count=1
seek=$((512*1024)) 2> /dev/null
if [ -n "$setup" -a -n "$readonly_overlay" ]; then
@@ -136,14 +143,14 @@ do_live_overlay() {
# set up the snapshot
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
+ echo 0 $sz snapshot $BASE_LOOPDEV $OVERLAY_LOOPDEV N 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
+ echo 0 $sz snapshot $base $over $persistent 8 | dmsetup create live-rw
}
# live cd helper function
@@ -217,7 +224,7 @@ fi
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 --getsz $BASE_LOOPDEV ) snapshot
$BASE_LOOPDEV $OSMIN_LOOPDEV p 8" | dmsetup create --readonly
live-osimg-min
+ echo "0 $( blockdev --getsz $BASE_LOOPDEV ) snapshot
$BASE_LOOPDEV $OSMIN_LOOPDEV N 8" | dmsetup create --readonly
live-osimg-min
fi
ROOTFLAGS="$(getarg rootflags)"
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Boot a Live USB device as read-only after persisting some changes.
[not found] ` <CAEcBt+WE6RKc_QBSrn8WM_Q6tcrbxS8+ZoqXhQMXzyJ7gOuDyA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-08-14 9:20 ` Harald Hoyer
[not found] ` <520B4BE5.6030003-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Harald Hoyer @ 2013-08-14 9:20 UTC (permalink / raw)
To: Frederick Grose
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA,
livecd-TuqUDEhatI4ANWPb/1PvSmm0pvjS0E/A,
spins-TuqUDEhatI4ANWPb/1PvSmm0pvjS0E/A
On 08/12/2013 06:46 AM, Frederick Grose wrote:
> commit 96ff19a87c0be1eca27860aeef5434513b0e8c61
> Author: Frederick Grose <fgrose-agl9EP5VjmEgsBAKwltoeQ@public.gmane.org>
> Date: Mon Aug 12 00:29:27 2013 -0400
>
> Allow read-only mounting of the base device filesystem, livedev.
> Use read-only loop devices and non-persistent overlay targets.
>
> diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh
> b/modules.d/90dmsquash-live/dmsquash-live-root.sh
> index 14e84e1..af0022f 100755
> --- a/modules.d/90dmsquash-live/dmsquash-live-root.sh
> +++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh
> @@ -24,7 +24,7 @@ squash_image=$(getarg rd.live.squashimg)
>
> getargbool 0 rd.live.ram -d -y live_ram && live_ram="yes"
> getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes"
> -getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay &&
> readonly_overlay="--readonly" || readonly_overlay=""
> +getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay &&
> readonly_overlay="-r" || readonly_overlay=""
> overlay=$(getarg rd.live.overlay -d overlay)
>
> # CD/DVD media check
> @@ -105,17 +105,23 @@ do_live_overlay() {
> setup=""
> if [ -n "$devspec" -a -n "$pathspec" -a -n "$overlay" ]; then
> mkdir -m 0755 /run/initramfs/overlayfs
> - mount -n -t auto $devspec /run/initramfs/overlayfs || :
> - if [ -f /run/initramfs/overlayfs$pathspec -a -w
> /run/initramfs/overlayfs$pathspec ]; then
> - losetup $OVERLAY_LOOPDEV /run/initramfs/overlayfs$pathspec
> - if [ -n "$reset_overlay" ]; then
> - dd if=/dev/zero of=$OVERLAY_LOOPDEV bs=64k count=1
> conv=fsync 2>/dev/null
> + mount -n -t auto -o $liverw $devspec /run/initramfs/overlayfs || :
> + if [ -f /run/initramfs/overlayfs$pathspec ]; then
> + if [ "$liverw" = ro ]; then
> + readonly_overlay='-r'
> + fi
> + losetup $readonly_overlay $OVERLAY_LOOPDEV
> /run/initramfs/overlayfs$pathspec
> + if [ -w /run/initramfs/overlayfs$pathspec ]; then
> + if [ -n "$reset_overlay" ]; then
> + dd if=/dev/zero of=$OVERLAY_LOOPDEV bs=64k
> count=1 conv=fsync 2>/dev/null
> + fi
> fi
> setup="yes"
> fi
> umount -l /run/initramfs/overlayfs || :
> fi
>
> + persistent='P'
> if [ -z "$setup" -o -n "$readonly_overlay" ]; then
> if [ -n "$setup" ]; then
> warn "Using temporary overlay."
> @@ -123,6 +129,7 @@ do_live_overlay() {
> warn "Unable to find persistent overlay; using temporary"
> sleep 5
> fi
> + persistent='N'
>
> dd if=/dev/null of=/overlay bs=1024 count=1
> seek=$((512*1024)) 2> /dev/null
> if [ -n "$setup" -a -n "$readonly_overlay" ]; then
> @@ -136,14 +143,14 @@ do_live_overlay() {
> # set up the snapshot
> 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
> + echo 0 $sz snapshot $BASE_LOOPDEV $OVERLAY_LOOPDEV N 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
> + echo 0 $sz snapshot $base $over $persistent 8 | dmsetup create live-rw
> }
>
> # live cd helper function
> @@ -217,7 +224,7 @@ fi
> 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 --getsz $BASE_LOOPDEV ) snapshot
> $BASE_LOOPDEV $OSMIN_LOOPDEV p 8" | dmsetup create --readonly
> live-osimg-min
> + echo "0 $( blockdev --getsz $BASE_LOOPDEV ) snapshot
> $BASE_LOOPDEV $OSMIN_LOOPDEV N 8" | dmsetup create --readonly
> live-osimg-min
> fi
>
> ROOTFLAGS="$(getarg rootflags)"
Care to resend the patch in a proper format? Your mailer seems to have wrapped
some lines.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Boot a Live USB device as read-only after persisting some changes.
[not found] ` <520B4BE5.6030003-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2013-08-14 20:38 ` fgrose-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1376512685-4713-1-git-send-email-fgrose-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-08-14 20:42 ` [Fedora-livecd-list] " fgrose-Re5JQEeQqe8AvxtiuMwx3w
1 sibling, 1 reply; 5+ messages in thread
From: fgrose-Re5JQEeQqe8AvxtiuMwx3w @ 2013-08-14 20:38 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA,
livecd-TuqUDEhatI4ANWPb/1PvSmm0pvjS0E/A,
spins-TuqUDEhatI4ANWPb/1PvSmm0pvjS0E/A
Cc: Frederick Grose
From: Frederick Grose <fgrose-agl9EP5VjmEgsBAKwltoeQ@public.gmane.org>
commit 96ff19a87c0be1eca27860aeef5434513b0e8c61
Author: Frederick Grose <fgrose-agl9EP5VjmEgsBAKwltoeQ@public.gmane.org>
Allow read-only mounting of the base device filesystem, livedev.
Use read-only loop devices and non-persistent overlay targets.
---
modules.d/90dmsquash-live/dmsquash-live-root.sh | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh
index 14e84e1..af0022f 100755
--- a/modules.d/90dmsquash-live/dmsquash-live-root.sh
+++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh
@@ -24,7 +24,7 @@ squash_image=$(getarg rd.live.squashimg)
getargbool 0 rd.live.ram -d -y live_ram && live_ram="yes"
getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes"
-getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay=""
+getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="-r" || readonly_overlay=""
overlay=$(getarg rd.live.overlay -d overlay)
# CD/DVD media check
@@ -105,17 +105,23 @@ do_live_overlay() {
setup=""
if [ -n "$devspec" -a -n "$pathspec" -a -n "$overlay" ]; then
mkdir -m 0755 /run/initramfs/overlayfs
- mount -n -t auto $devspec /run/initramfs/overlayfs || :
- if [ -f /run/initramfs/overlayfs$pathspec -a -w /run/initramfs/overlayfs$pathspec ]; then
- losetup $OVERLAY_LOOPDEV /run/initramfs/overlayfs$pathspec
- if [ -n "$reset_overlay" ]; then
- dd if=/dev/zero of=$OVERLAY_LOOPDEV bs=64k count=1 conv=fsync 2>/dev/null
+ mount -n -t auto -o $liverw $devspec /run/initramfs/overlayfs || :
+ if [ -f /run/initramfs/overlayfs$pathspec ]; then
+ if [ "$liverw" = ro ]; then
+ readonly_overlay='-r'
+ fi
+ losetup $readonly_overlay $OVERLAY_LOOPDEV /run/initramfs/overlayfs$pathspec
+ if [ -w /run/initramfs/overlayfs$pathspec ]; then
+ if [ -n "$reset_overlay" ]; then
+ dd if=/dev/zero of=$OVERLAY_LOOPDEV bs=64k count=1 conv=fsync 2>/dev/null
+ fi
fi
setup="yes"
fi
umount -l /run/initramfs/overlayfs || :
fi
+ persistent='P'
if [ -z "$setup" -o -n "$readonly_overlay" ]; then
if [ -n "$setup" ]; then
warn "Using temporary overlay."
@@ -123,6 +129,7 @@ do_live_overlay() {
warn "Unable to find persistent overlay; using temporary"
sleep 5
fi
+ persistent='N'
dd if=/dev/null of=/overlay bs=1024 count=1 seek=$((512*1024)) 2> /dev/null
if [ -n "$setup" -a -n "$readonly_overlay" ]; then
@@ -136,14 +143,14 @@ do_live_overlay() {
# set up the snapshot
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
+ echo 0 $sz snapshot $BASE_LOOPDEV $OVERLAY_LOOPDEV N 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
+ echo 0 $sz snapshot $base $over $persistent 8 | dmsetup create live-rw
}
# live cd helper function
@@ -217,7 +224,7 @@ fi
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 --getsz $BASE_LOOPDEV ) snapshot $BASE_LOOPDEV $OSMIN_LOOPDEV p 8" | dmsetup create --readonly live-osimg-min
+ echo "0 $( blockdev --getsz $BASE_LOOPDEV ) snapshot $BASE_LOOPDEV $OSMIN_LOOPDEV N 8" | dmsetup create --readonly live-osimg-min
fi
ROOTFLAGS="$(getarg rootflags)"
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Fedora-livecd-list] [PATCH] Boot a Live USB device as read-only after persisting some changes.
[not found] ` <520B4BE5.6030003-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-08-14 20:38 ` fgrose-Re5JQEeQqe8AvxtiuMwx3w
@ 2013-08-14 20:42 ` fgrose-Re5JQEeQqe8AvxtiuMwx3w
1 sibling, 0 replies; 5+ messages in thread
From: fgrose-Re5JQEeQqe8AvxtiuMwx3w @ 2013-08-14 20:42 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA,
livecd-TuqUDEhatI4ANWPb/1PvSmm0pvjS0E/A,
spins-TuqUDEhatI4ANWPb/1PvSmm0pvjS0E/A
Cc: Frederick Grose
From: Frederick Grose <fgrose@sugarlabs.org>
commit a6cd70fc9df2d299ed4f347461c33e4824df62f0
Author: Frederick Grose <fgrose@sugarlabs.org>
Enable read-only mounting of a persistent home.img filesystem.
Enable one to call for filesystem checking of home.img before
mounting on the next boot.
---
fedora-live-base.ks | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/fedora-live-base.ks b/fedora-live-base.ks
index 6c76e96..0512f67 100644
--- a/fedora-live-base.ks
+++ b/fedora-live-base.ks
@@ -116,9 +116,13 @@ mountPersistentHome() {
elif [ ! -b "\$homedev" ]; then
loopdev=\`losetup -f\`
if [ "\${homedev##/run/initramfs/live}" != "\${homedev}" ]; then
- action "Remounting live store r/w" mount -o remount,rw /run/initramfs/live
+ if [ "\$liverw" = rw ]; then
+ action "Remounting live store r/w" mount -o remount,rw /run/initramfs/live
+ else
+ opts="-r"
+ fi
fi
- losetup \$loopdev \$homedev
+ losetup \$opts \$loopdev \$homedev
homedev=\$loopdev
fi
@@ -130,6 +134,22 @@ mountPersistentHome() {
homedev=/dev/mapper/EncHome
fi
+ # If read-only is requested, prepare a non-persistent overlay and snapshot target.
+ if [ "\$opts" = "-r" ]; then
+ dd if=/dev/null of=/run/initramfs/overlayfs/home_overlay bs=1024 count=1 seek=\$((512*1024)) 2> /dev/null
+ HOME_OVERLAY_LOOPDEV=\$(losetup -f)
+ losetup \$HOME_OVERLAY_LOOPDEV /run/initramfs/overlayfs/home_overlay
+ sz=\$(blockdev --getsz \$homedev)
+ echo 0 \$sz snapshot \$homedev \$HOME_OVERLAY_LOOPDEV N 8 | dmsetup create home-rw
+ homedev=/dev/mapper/home-rw
+ fi
+
+ # Check the filesystem, if requested.
+ if [ -e /forcehomefsck ]; then
+ e2fsck -f -y -v \$homedev || e2fsck -f -y \$homedev
+ rm /forcehomefsck
+ fi
+
# and finally do the mount
mount \$mountopts \$homedev /home
# if we have /home under what's passed for persistent home, then
--
1.8.3.1
--
livecd mailing list
livecd@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/livecd
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Boot a Live USB device as read-only after persisting some changes.
[not found] ` <1376512685-4713-1-git-send-email-fgrose-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2013-08-16 8:20 ` Harald Hoyer
0 siblings, 0 replies; 5+ messages in thread
From: Harald Hoyer @ 2013-08-16 8:20 UTC (permalink / raw)
To: fgrose-Re5JQEeQqe8AvxtiuMwx3w
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA,
livecd-TuqUDEhatI4ANWPb/1PvSmm0pvjS0E/A,
spins-TuqUDEhatI4ANWPb/1PvSmm0pvjS0E/A, Frederick Grose
On 08/14/2013 10:38 PM, fgrose-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
> From: Frederick Grose <fgrose-agl9EP5VjmEgsBAKwltoeQ@public.gmane.org>
>
> commit 96ff19a87c0be1eca27860aeef5434513b0e8c61
> Author: Frederick Grose <fgrose-agl9EP5VjmEgsBAKwltoeQ@public.gmane.org>
>
> Allow read-only mounting of the base device filesystem, livedev.
> Use read-only loop devices and non-persistent overlay targets.
>
> ---
> modules.d/90dmsquash-live/dmsquash-live-root.sh | 25 ++++++++++++++++---------
> 1 file changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh
> index 14e84e1..af0022f 100755
> --- a/modules.d/90dmsquash-live/dmsquash-live-root.sh
> +++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh
> @@ -24,7 +24,7 @@ squash_image=$(getarg rd.live.squashimg)
>
> getargbool 0 rd.live.ram -d -y live_ram && live_ram="yes"
> getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes"
> -getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay=""
> +getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="-r" || readonly_overlay=""
> overlay=$(getarg rd.live.overlay -d overlay)
>
> # CD/DVD media check
> @@ -105,17 +105,23 @@ do_live_overlay() {
> setup=""
> if [ -n "$devspec" -a -n "$pathspec" -a -n "$overlay" ]; then
> mkdir -m 0755 /run/initramfs/overlayfs
> - mount -n -t auto $devspec /run/initramfs/overlayfs || :
> - if [ -f /run/initramfs/overlayfs$pathspec -a -w /run/initramfs/overlayfs$pathspec ]; then
> - losetup $OVERLAY_LOOPDEV /run/initramfs/overlayfs$pathspec
> - if [ -n "$reset_overlay" ]; then
> - dd if=/dev/zero of=$OVERLAY_LOOPDEV bs=64k count=1 conv=fsync 2>/dev/null
> + mount -n -t auto -o $liverw $devspec /run/initramfs/overlayfs || :
> + if [ -f /run/initramfs/overlayfs$pathspec ]; then
> + if [ "$liverw" = ro ]; then
> + readonly_overlay='-r'
> + fi
> + losetup $readonly_overlay $OVERLAY_LOOPDEV /run/initramfs/overlayfs$pathspec
> + if [ -w /run/initramfs/overlayfs$pathspec ]; then
> + if [ -n "$reset_overlay" ]; then
> + dd if=/dev/zero of=$OVERLAY_LOOPDEV bs=64k count=1 conv=fsync 2>/dev/null
> + fi
> fi
> setup="yes"
> fi
> umount -l /run/initramfs/overlayfs || :
> fi
>
> + persistent='P'
> if [ -z "$setup" -o -n "$readonly_overlay" ]; then
> if [ -n "$setup" ]; then
> warn "Using temporary overlay."
> @@ -123,6 +129,7 @@ do_live_overlay() {
> warn "Unable to find persistent overlay; using temporary"
> sleep 5
> fi
> + persistent='N'
>
> dd if=/dev/null of=/overlay bs=1024 count=1 seek=$((512*1024)) 2> /dev/null
> if [ -n "$setup" -a -n "$readonly_overlay" ]; then
> @@ -136,14 +143,14 @@ do_live_overlay() {
> # set up the snapshot
> 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
> + echo 0 $sz snapshot $BASE_LOOPDEV $OVERLAY_LOOPDEV N 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
> + echo 0 $sz snapshot $base $over $persistent 8 | dmsetup create live-rw
> }
>
> # live cd helper function
> @@ -217,7 +224,7 @@ fi
> 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 --getsz $BASE_LOOPDEV ) snapshot $BASE_LOOPDEV $OSMIN_LOOPDEV p 8" | dmsetup create --readonly live-osimg-min
> + echo "0 $( blockdev --getsz $BASE_LOOPDEV ) snapshot $BASE_LOOPDEV $OSMIN_LOOPDEV N 8" | dmsetup create --readonly live-osimg-min
> fi
>
> ROOTFLAGS="$(getarg rootflags)"
>
thanks! pushed
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-08-16 8:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-12 4:46 [PATCH] Boot a Live USB device as read-only after persisting some changes Frederick Grose
[not found] ` <CAEcBt+WE6RKc_QBSrn8WM_Q6tcrbxS8+ZoqXhQMXzyJ7gOuDyA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-14 9:20 ` Harald Hoyer
[not found] ` <520B4BE5.6030003-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-08-14 20:38 ` fgrose-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1376512685-4713-1-git-send-email-fgrose-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-08-16 8:20 ` Harald Hoyer
2013-08-14 20:42 ` [Fedora-livecd-list] " fgrose-Re5JQEeQqe8AvxtiuMwx3w
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.