]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Add support for in-initramfs live images with "root=live:/path/name.img"
authorWill Woods <wwoods@redhat.com>
Tue, 8 Mar 2011 23:35:17 +0000 (18:35 -0500)
committerHarald Hoyer <harald@redhat.com>
Wed, 9 Mar 2011 11:10:22 +0000 (12:10 +0100)
This allows creation of initramfs images which contain a Live system.
The primary use for this is keeping very large initramfs-based systems
(e.g. anaconda, the Fedora installer) compressed in-memory, by using a
compressed filesystem image like squashfs or btrfs.

dmsquash-live-genrules.sh will initqueue dmsquash-live-root itself
(rather than making udev rules) if the given live "device" is actually
an existing, plain file.

parse-dmsquash-live.sh will only accept paths that end in ".img".
dmsquash-live-root will only handle images named "*squashfs.img",
"*ext3fs.img", or "*btrfs.img".

modules.d/90dmsquash-live/dmsquash-live-genrules.sh
modules.d/90dmsquash-live/dmsquash-live-root
modules.d/90dmsquash-live/parse-dmsquash-live.sh

index 72695a9c4ef18d637622ae7b7251d05d19e2b026..5642d531c9b176525d6ab1bdbfad5bc33f63b84f 100755 (executable)
@@ -1,7 +1,8 @@
 #!/bin/sh
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
 # ex: ts=8 sw=4 sts=4 et filetype=sh
-if [ "${root%%:*}" = "live" ]; then
+case "$root" in
+  live:/dev/*)
     {
         printf 'KERNEL=="%s", SYMLINK+="live"\n' \
             ${root#live:/dev/} 
@@ -15,4 +16,11 @@ if [ "${root%%:*}" = "live" ]; then
             ${root#live:/dev/} 
     } >> /etc/udev/rules.d/99-live-squash.rules
     echo '[ -e /dev/root ]' > /initqueue-finished/dmsquash.sh
-fi
+  ;;
+  live:*)
+    if [ -f "${root#live:}" ]; then
+        /sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root "${root#live:}"
+        echo '[ -e /dev/root ]' > /initqueue-finished/dmsquash.sh
+    fi
+  ;;
+esac
index f8aa805ae42459d490048c81d2bb6a8cf7bcc84f..c857e48d676c2c2035aa55c7bf84c6006dfebd22 100755 (executable)
@@ -44,11 +44,19 @@ getarg rw && liverw=rw
 [ -z "$liverw" ] && liverw=ro
 # mount the backing of the live image first
 mkdir -p /dev/.initramfs/live
-mount -n -t $fstype -o $liverw $livedev /dev/.initramfs/live
-RES=$?
-if [ "$RES" != "0" ]; then
-    die "Failed to mount block device of live image"
-    exit 1
+if [ -f $livedev ]; then
+    # no mount needed - we've already got the LiveOS image in initramfs
+    case $livedev in
+        *squashfs.img) SQUASHED=$livedev ;;
+        *ext3fs.img|*btrfs.img) FSIMG=$livedev ;;
+    esac
+else
+    mount -n -t $fstype -o $liverw $livedev /dev/.initramfs/live
+    RES=$?
+    if [ "$RES" != "0" ]; then
+        die "Failed to mount block device of live image"
+        exit 1
+    fi
 fi
 
 # overlay setup helper function
index 38610fb11ce4839d7328d56c20b752f4d9f492f2..6e0db291deebf1ac278bbd58cf3e966a90b7e951 100755 (executable)
@@ -38,6 +38,8 @@ case "$liveroot" in
         rootok=1 ;;
     live:/dev/*)
         rootok=1 ;;
+    live:/*.[Ii][Mm][Gg]|/*.[Ii][Mm][Gg])
+        [ -f "${root#live:}" ] && rootok=1 ;;
 esac
 info "root was $root, liveroot is now $liveroot"