Blame SOURCES/0020-rootfs-block-add-support-for-the-rootfallback-kernel.patch

a56a5e
From 4584826e9a25fdddb876f07875423196d9fc8840 Mon Sep 17 00:00:00 2001
90b079
From: Harald Hoyer <harald@redhat.com>
90b079
Date: Mon, 7 Oct 2013 15:06:22 +0200
90b079
Subject: [PATCH] rootfs-block: add support for the rootfallback= kernel
90b079
 cmdline option
90b079
90b079
---
90b079
 dracut.cmdline.7.asc                     |  6 +++++
90b079
 modules.d/95rootfs-block/module-setup.sh |  3 ++-
90b079
 modules.d/95rootfs-block/rootfallback.sh | 46 ++++++++++++++++++++++++++++++++
90b079
 3 files changed, 54 insertions(+), 1 deletion(-)
90b079
 create mode 100755 modules.d/95rootfs-block/rootfallback.sh
90b079
90b079
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
90b079
index 09c47e8..4b2ab03 100644
90b079
--- a/dracut.cmdline.7.asc
90b079
+++ b/dracut.cmdline.7.asc
90b079
@@ -69,6 +69,12 @@ rootfstype=ext3
90b079
     force mounting _/_ and _/usr_ (if it is a separate device) read-write.
90b079
     See also ro option.
90b079
 
90b079
+**rootfallback=**_<path to blockdevice>_::
90b079
+    specify the block device to use as the root filesystem, if the normal root cannot be found.
90b079
+    This can only be a simple block device with a simple file system, for which the filesystem
90b079
+    driver is either compiled in, or added manually to the initramfs.
90b079
+    This parameter can be specified multiple times.
90b079
+
90b079
 **rd.auto** **rd.auto=1**::
90b079
     enable autoassembly of special devices like cryptoLUKS, dmraid, mdraid or lvm.
90b079
     Default is off as of dracut version >= 024.
90b079
diff --git a/modules.d/95rootfs-block/module-setup.sh b/modules.d/95rootfs-block/module-setup.sh
90b079
index f066a79..7e714eb 100755
90b079
--- a/modules.d/95rootfs-block/module-setup.sh
90b079
+++ b/modules.d/95rootfs-block/module-setup.sh
90b079
@@ -44,5 +44,6 @@ install() {
90b079
         inst_hook pre-udev 30 "$moddir/block-genrules.sh"
90b079
         inst_hook mount 99 "$moddir/mount-root.sh"
90b079
     fi
90b079
-}
90b079
 
90b079
+    inst_hook initqueue/timeout 99 "$moddir/rootfallback.sh"
90b079
+}
90b079
diff --git a/modules.d/95rootfs-block/rootfallback.sh b/modules.d/95rootfs-block/rootfallback.sh
90b079
new file mode 100755
90b079
index 0000000..246ce9a
90b079
--- /dev/null
90b079
+++ b/modules.d/95rootfs-block/rootfallback.sh
90b079
@@ -0,0 +1,46 @@
90b079
+#!/bin/sh
90b079
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
90b079
+# ex: ts=8 sw=4 sts=4 et filetype=sh
90b079
+
90b079
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
90b079
+
90b079
+for root in $(getargs rootfallback=); do
90b079
+    case "$root" in
90b079
+        block:LABEL=*|LABEL=*)
90b079
+            root="${root#block:}"
90b079
+            root="$(echo $root | sed 's,/,\\x2f,g')"
90b079
+            root="/dev/disk/by-label/${root#LABEL=}"
90b079
+            ;;
90b079
+        block:UUID=*|UUID=*)
90b079
+            root="${root#block:}"
90b079
+            root="${root#UUID=}"
90b079
+            root="$(echo $root | tr "[:upper:]" "[:lower:]")"
90b079
+            root="/dev/disk/by-uuid/${root#UUID=}"
90b079
+            ;;
90b079
+        block:PARTUUID=*|PARTUUID=*)
90b079
+            root="${root#block:}"
90b079
+            root="${root#PARTUUID=}"
90b079
+            root="$(echo $root | tr "[:upper:]" "[:lower:]")"
90b079
+            root="/dev/disk/by-partuuid/${root}"
90b079
+            ;;
90b079
+        block:PARTLABEL=*|PARTLABEL=*)
90b079
+            root="${root#block:}"
90b079
+            root="/dev/disk/by-partlabel/${root#PARTLABEL=}"
90b079
+            ;;
90b079
+    esac
90b079
+
90b079
+    if ! [ -b "$root" ]; then
90b079
+        warn "Could not find rootfallback $root"
90b079
+        continue
90b079
+    fi
90b079
+
90b079
+    if mount "$root" /sysroot; then
90b079
+        info "Mounted rootfallback $root"
90b079
+        exit 0
90b079
+    else
90b079
+        warn "Failed to mount rootfallback $root"
90b079
+        exit 1
90b079
+    fi
90b079
+done
90b079
+
90b079
+[ -e "$job" ] && rm -f "$job"