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