|
|
712866 |
From b9c6d2b2afa94dcba7129390edb7b1a2eaf2c31c Mon Sep 17 00:00:00 2001
|
|
|
712866 |
From: Major Hayden <major@mhtx.net>
|
|
|
712866 |
Date: Mon, 4 Aug 2014 10:27:36 -0500
|
|
|
712866 |
Subject: [PATCH] Adding support for read/write filesystem images
|
|
|
712866 |
|
|
|
712866 |
A user can provide a filesystem image (rootfs.img) inside a compressed
|
|
|
712866 |
tarball and that filesystem image will be mounted read/write. This provides
|
|
|
712866 |
some benefits over a device mapper snapshot overlay, especially when the
|
|
|
712866 |
live system becomes full. The boot command line simple needs
|
|
|
712866 |
"rd.writable.fsimg" added to utilize this feature.
|
|
|
712866 |
|
|
|
712866 |
Additional documentation for this option as well as other live boot
|
|
|
712866 |
options is included.
|
|
|
712866 |
|
|
|
712866 |
Signed-off-by: Major Hayden <major@mhtx.net>
|
|
|
712866 |
(cherry picked from commit 504c0a8feca7d7ef470e4483a68cbaf9cb7df2bf)
|
|
|
712866 |
---
|
|
|
712866 |
dracut.cmdline.7.asc | 82 ++++++++++++++++++++++++-
|
|
|
712866 |
modules.d/90dmsquash-live/dmsquash-live-root.sh | 16 ++++-
|
|
|
712866 |
modules.d/90dmsquash-live/module-setup.sh | 2 +-
|
|
|
712866 |
3 files changed, 96 insertions(+), 4 deletions(-)
|
|
|
712866 |
|
|
|
712866 |
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
|
|
|
5c6c2a |
index bce86084..0493dcd8 100644
|
|
|
712866 |
--- a/dracut.cmdline.7.asc
|
|
|
712866 |
+++ b/dracut.cmdline.7.asc
|
|
|
712866 |
@@ -729,10 +729,90 @@ rd.znet=qeth,0.0.0600,0.0.0601,0.0.0602,layer2=1,portname=foo
|
|
|
712866 |
rd.znet=ctc,0.0.0600,0.0.0601,protocol=bar
|
|
|
712866 |
--
|
|
|
712866 |
|
|
|
712866 |
+Booting live images
|
|
|
712866 |
+~~~~~~~~~~~~~~~~~~~
|
|
|
712866 |
+Dracut offers multiple options for live booted images:
|
|
|
712866 |
+
|
|
|
712866 |
+=====================
|
|
|
712866 |
+squashfs with read-only filesystem image::: The system will boot with a read
|
|
|
712866 |
+only filesystem from the squashfs and apply a writable device mapper snapshot
|
|
|
712866 |
+over the read only filesystem. Using this method ensures a relatively fast
|
|
|
712866 |
+boot and lower RAM usage. Users **must be careful** to avoid writing too many
|
|
|
712866 |
+blocks to the snapshot volume. Once the blocks of the snapshot are exhaused,
|
|
|
712866 |
+the live filesystem becomes unusable and requires a reboot.
|
|
|
712866 |
++
|
|
|
712866 |
+The filesystem structure is expected to be:
|
|
|
712866 |
++
|
|
|
712866 |
+[listing]
|
|
|
712866 |
+--
|
|
|
712866 |
+squashfs.img | Squashfs downloaded via network
|
|
|
712866 |
+ !(mount)
|
|
|
712866 |
+ /LiveOS
|
|
|
712866 |
+ |- ext3fs.img | Filesystem image to mount read-only
|
|
|
712866 |
+ !(mount)
|
|
|
712866 |
+ /bin | Live filesystem
|
|
|
712866 |
+ /boot |
|
|
|
712866 |
+ /dev |
|
|
|
712866 |
+ ... |
|
|
|
712866 |
+--
|
|
|
712866 |
++
|
|
|
712866 |
+Dracut uses this method of live booting by default. No additional command line
|
|
|
712866 |
+options are required other than **root=live:<URL>** to specify the location
|
|
|
712866 |
+of your squashed filesystem.
|
|
|
712866 |
++
|
|
|
712866 |
+writable filesystem image::: The system will retrieve a compressed filesystem
|
|
|
712866 |
+image, connect it to a loopback device, and mount it as a writable volume. More
|
|
|
712866 |
+RAM is required during boot but the live filesystem is easier to manage if it
|
|
|
712866 |
+becomes full. Users can make a filesystem image of any size and that size will
|
|
|
712866 |
+be maintained when the system boots.
|
|
|
712866 |
++
|
|
|
712866 |
+The filesystem structure is expected to be:
|
|
|
712866 |
++
|
|
|
712866 |
+[listing]
|
|
|
712866 |
+--
|
|
|
712866 |
+rootfs.tgz | Compressed tarball containing fileystem image
|
|
|
712866 |
+ !(unpack)
|
|
|
712866 |
+ /rootfs.img | Filesystem image
|
|
|
712866 |
+ !(mount)
|
|
|
712866 |
+ /bin | Live filesystem
|
|
|
712866 |
+ /boot |
|
|
|
712866 |
+ /dev |
|
|
|
712866 |
+ ... |
|
|
|
712866 |
+--
|
|
|
712866 |
++
|
|
|
712866 |
+To use this boot option, ensure that **rd.writable_fsimg=1** is in your kernel
|
|
|
712866 |
+command line and add the **root=live:<URL>** to specify the location
|
|
|
712866 |
+of your compressed filesystem image tarball.
|
|
|
712866 |
+=====================
|
|
|
712866 |
+
|
|
|
712866 |
+**root=**live:__<url>__::
|
|
|
712866 |
+Boots a live image retrieved from __<url>__. Valid handlers: __http, httpd, ftp, tftp__.
|
|
|
712866 |
++
|
|
|
712866 |
+[listing]
|
|
|
712866 |
+.Example
|
|
|
712866 |
+--
|
|
|
712866 |
+root=live:http://example.com/liveboot.img
|
|
|
712866 |
+root=live:ftp://ftp.example.com/liveboot.img
|
|
|
712866 |
+--
|
|
|
712866 |
+
|
|
|
712866 |
+**rd.live.debug=**1::
|
|
|
712866 |
+Enables debug output from the live boot process.
|
|
|
712866 |
+
|
|
|
712866 |
+**rd.live.dir=**__<path>__::
|
|
|
712866 |
+Specifies the directory within the squashfs where the ext3fs.img or rootfs.img
|
|
|
712866 |
+can be found. By default, this is __LiveOS__.
|
|
|
712866 |
+
|
|
|
712866 |
+**rd.writable.fsimg=**1::
|
|
|
712866 |
+Enables writable filesystem support. The system will boot with a fully
|
|
|
712866 |
+writable filesystem without snapshots __(see notes above about available live boot options)__.
|
|
|
712866 |
+You can use the **rootflags** option to set mount options for the live
|
|
|
712866 |
+filesystem as well __(see documentation about rootflags in the **Standard** section above)__.
|
|
|
712866 |
+
|
|
|
712866 |
+
|
|
|
712866 |
Plymouth Boot Splash
|
|
|
712866 |
~~~~~~~~~~~~~~~~~~~~
|
|
|
712866 |
**plymouth.enable=0**::
|
|
|
712866 |
- disable the plymouth bootsplash completly.
|
|
|
712866 |
+ disable the plymouth bootsplash completely.
|
|
|
712866 |
|
|
|
712866 |
**rd.plymouth=0**::
|
|
|
712866 |
disable the plymouth bootsplash only for the initramfs.
|
|
|
712866 |
diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh
|
|
|
5c6c2a |
index 5705e8df..c6c02c74 100755
|
|
|
712866 |
--- a/modules.d/90dmsquash-live/dmsquash-live-root.sh
|
|
|
712866 |
+++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh
|
|
|
712866 |
@@ -4,6 +4,8 @@
|
|
|
712866 |
|
|
|
712866 |
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
|
|
712866 |
|
|
|
712866 |
+command -v unpack_archive >/dev/null || . /lib/img-lib.sh
|
|
|
712866 |
+
|
|
|
712866 |
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
712866 |
|
|
|
712866 |
if getargbool 0 rd.live.debug -n -y rdlivedebug; then
|
|
|
712866 |
@@ -26,6 +28,7 @@ getargbool 0 rd.live.ram -d -y live_ram && live_ram="yes"
|
|
|
712866 |
getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes"
|
|
|
712866 |
getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay=""
|
|
|
712866 |
overlay=$(getarg rd.live.overlay -d overlay)
|
|
|
712866 |
+getargbool 0 rd.writable.fsimg -d -y writable_fsimg && writable_fsimg="yes"
|
|
|
712866 |
|
|
|
712866 |
# CD/DVD media check
|
|
|
712866 |
[ -b $livedev ] && fs=$(blkid -s TYPE -o value $livedev)
|
|
|
712866 |
@@ -180,9 +183,18 @@ fi
|
|
|
712866 |
|
|
|
712866 |
if [ -n "$FSIMG" ] ; then
|
|
|
712866 |
BASE_LOOPDEV=$( losetup -f )
|
|
|
712866 |
- losetup -r $BASE_LOOPDEV $FSIMG
|
|
|
712866 |
|
|
|
712866 |
- do_live_from_base_loop
|
|
|
712866 |
+ if [ -n "$writable_fsimg" ] ; then
|
|
|
712866 |
+ # mount the provided fileysstem read/write
|
|
|
712866 |
+ echo "Unpacking live filesystem (may take some time)"
|
|
|
712866 |
+ unpack_archive $FSIMG /tmp/fsimg/
|
|
|
712866 |
+ losetup $BASE_LOOPDEV /tmp/fsimg/rootfs.img
|
|
|
712866 |
+ echo "0 $( blockdev --getsize $BASE_LOOPDEV ) linear $BASE_LOOPDEV 0" | dmsetup create live-rw
|
|
|
712866 |
+ else
|
|
|
712866 |
+ # mount the filesystem read-only and add a dm snapshot for writes
|
|
|
712866 |
+ losetup -r $BASE_LOOPDEV $FSIMG
|
|
|
712866 |
+ do_live_from_base_loop
|
|
|
712866 |
+ fi
|
|
|
712866 |
fi
|
|
|
712866 |
|
|
|
712866 |
# we might have an embedded fs image on squashfs (compressed live)
|
|
|
712866 |
diff --git a/modules.d/90dmsquash-live/module-setup.sh b/modules.d/90dmsquash-live/module-setup.sh
|
|
|
5c6c2a |
index c6d1f9d5..f52717de 100755
|
|
|
712866 |
--- a/modules.d/90dmsquash-live/module-setup.sh
|
|
|
712866 |
+++ b/modules.d/90dmsquash-live/module-setup.sh
|
|
|
712866 |
@@ -11,7 +11,7 @@ check() {
|
|
|
712866 |
depends() {
|
|
|
712866 |
# if dmsetup is not installed, then we cannot support fedora/red hat
|
|
|
712866 |
# style live images
|
|
|
712866 |
- echo dm rootfs-block
|
|
|
712866 |
+ echo dm rootfs-block img-lib
|
|
|
712866 |
return 0
|
|
|
712866 |
}
|
|
|
712866 |
|