]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Add rd.hostonly kernel command line parameters
authorHarald Hoyer <harald@redhat.com>
Tue, 24 Jun 2014 16:13:28 +0000 (18:13 +0200)
committerHarald Hoyer <harald@redhat.com>
Fri, 27 Jun 2014 11:59:44 +0000 (13:59 +0200)
rd.hostonly=0 will remove all configuration compiled in the initramfs
from the host on which it was build

12 files changed:
dracut.cmdline.7.asc
modules.d/90crypt/module-setup.sh
modules.d/90kernel-modules/module-setup.sh
modules.d/90lvm/module-setup.sh
modules.d/90mdraid/module-setup.sh
modules.d/95dasd/module-setup.sh
modules.d/95udev-rules/module-setup.sh
modules.d/95zfcp/module-setup.sh
modules.d/98systemd/dracut-cmdline.sh
modules.d/98systemd/module-setup.sh
modules.d/99base/dracut-lib.sh
modules.d/99base/init.sh

index 10550eef0d68841c5923239d1739b7902b371bba..b5b1bae8a5fc015b63dcf3efb78f0e4b07eb3666 100644 (file)
@@ -81,6 +81,11 @@ rootfstype=ext3
     enable autoassembly of special devices like cryptoLUKS, dmraid, mdraid or
     lvm. Default is off as of dracut version >= 024.
 
+**rd.hostonly=0**::
+    removes all compiled in configuration of the host system the initramfs image
+    was built on. This helps booting, if any disk layout changed, especially in
+    combination with rd.auto or other parameters specifying the layout.
+
 **rd.fstab=0**::
     do not honor special mount options for the root filesystem found in
     _/etc/fstab_ of the real root.
index 570740491790e42ee4de3bce76b484a8bfa35f91..d8f36f4bf382454a09dc3c33b3e9ff6281080ce1 100755 (executable)
@@ -82,6 +82,7 @@ install() {
                 fi
             done
         done < /etc/crypttab > $initdir/etc/crypttab
+        mark_hostonly /etc/crypttab
     fi
 
     inst_simple "$moddir/crypt-lib.sh" "/lib/dracut-crypt-lib.sh"
index 5271438d182587648c415b43015d3f82f0bee561..4854ac9b0a7e9220b4fe5fc68966158124352926 100755 (executable)
@@ -79,7 +79,7 @@ installkernel() {
 # called by dracut
 install() {
     inst_multiple -o /lib/modprobe.d/*.conf
-    [[ $hostonly ]] && inst_multiple -o /etc/modprobe.d/*.conf /etc/modprobe.conf
+    [[ $hostonly ]] && inst_multiple -H -o /etc/modprobe.d/*.conf /etc/modprobe.conf
     if ! dracut_module_included "systemd"; then
         inst_hook cmdline 01 "$moddir/parse-kernel.sh"
     fi
index 5b810b9373eabd97810f58ca496e2767c8085d9c..00d4e5a723a461cee9e9d1c211134bb2c0ea503a 100755 (executable)
@@ -59,7 +59,7 @@ install() {
 
     if [[ $hostonly ]] || [[ $lvmconf = "yes" ]]; then
         if [ -f /etc/lvm/lvm.conf ]; then
-            inst_simple /etc/lvm/lvm.conf
+            inst_simple -H /etc/lvm/lvm.conf
             # FIXME: near-term hack to establish read-only locking;
             # use command-line lvm.conf editor once it is available
             sed -i -e 's/\(^[[:space:]]*\)locking_type[[:space:]]*=[[:space:]]*[[:digit:]]/\1locking_type = 4/' ${initdir}/etc/lvm/lvm.conf
index 81c94f2d365c2dea922b1c1868c56cf2eca7aee1..f75f69a3948545e5cd95fa9ece23c64535cc5771 100755 (executable)
@@ -107,16 +107,16 @@ install() {
 
     if [[ $hostonly ]] || [[ $mdadmconf = "yes" ]]; then
         if [ -f /etc/mdadm.conf ]; then
-            inst /etc/mdadm.conf
+            inst -H /etc/mdadm.conf
         else
-            [ -f /etc/mdadm/mdadm.conf ] && inst /etc/mdadm/mdadm.conf /etc/mdadm.conf
+            [ -f /etc/mdadm/mdadm.conf ] && inst -H /etc/mdadm/mdadm.conf /etc/mdadm.conf
         fi
         if [ -d /etc/mdadm.conf.d ]; then
             local f
             inst_dir /etc/mdadm.conf.d
             for f in /etc/mdadm.conf.d/*.conf; do
                 [ -f "$f" ] || continue
-                inst "$f"
+                inst -H "$f"
             done
         fi
     fi
index da0f3c08897ad9c1f6119c8b4a9f96a5dbf34815..92c14f5dec5266745dc71008073a5a603541f963 100755 (executable)
@@ -21,7 +21,7 @@ install() {
     inst_hook cmdline 30 "$moddir/parse-dasd.sh"
     inst_multiple dasdinfo dasdconf.sh normalize_dasd_arg
     if [[ $hostonly ]]; then
-        inst /etc/dasd.conf
+        inst -H /etc/dasd.conf
     fi
     inst_rules 56-dasd.rules
     inst_rules 59-dasd.rules
index 4e75c0b8070e3804197261261ba7cf6bdbd11fbb..7f38ed378e9060362bed32506cbfeae9fd0a26da 100755 (executable)
@@ -45,12 +45,8 @@ install() {
     # eudev rules
     inst_rules 80-drivers-modprobe.rules
 
-    for _i in \
-        ${systemdutildir}/network/*.link \
-        ${hostonly:+/etc/systemd/network/*.link} \
-        ; do
-        [[ -e "$_i" ]] && inst "$_i"
-    done
+    inst_multiple -o ${systemdutildir}/network/*.link
+    [[ $hostonly ]] && inst_multiple -H -o /etc/systemd/network/*.link
 
     {
         for i in cdrom tape dialout floppy; do
index b96ccd2e61b72a3705f435ca0159c04841234b71..9526caa48bcabc39d88704a09b7881644d6360fa 100755 (executable)
@@ -31,6 +31,6 @@ install() {
     inst_rules 56-zfcp.rules
 
     if [[ $hostonly ]]; then
-        inst_simple /etc/zfcp.conf
+        inst_simple -H /etc/zfcp.conf
     fi
 }
index 3170e756569c8f44a691c2614f3c0a5be63d6aa0..0507e6517158db4704e678c770a748a19a227cac 100755 (executable)
@@ -10,6 +10,10 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 [ -f /etc/initrd-release ] && . /etc/initrd-release
 [ -n "$VERSION" ] && info "dracut-$VERSION"
 
+if ! getargbool 1 'rd.hostonly'; then
+    remove_hostonly_files
+fi
+
 getargbool 0 rd.udev.log-priority=info -d rd.udev.info -d -n -y rdudevinfo && echo 'udev_log="info"' >> /etc/udev/udev.conf
 getargbool 0 rd.udev.log-priority=debug -d rd.udev.debug -d -n -y rdudevdebug && echo 'udev_log="debug"' >> /etc/udev/udev.conf
 
index e2efc427c7e9f68a4ce7b282c385b0c296a2675a..9a8296af1ff0e9868237802707753b7cffec89ae 100755 (executable)
@@ -152,7 +152,7 @@ install() {
     [[ $_mods ]] && instmods $_mods
 
     if [[ $hostonly ]]; then
-        inst_multiple -o \
+        inst_multiple -H -o \
             /etc/systemd/journald.conf \
             /etc/systemd/system.conf \
             /etc/hostname \
index 33f76784ca1c6a61d12632e2890711bc1e9e89c2..ed40b822f2ee03346ff4aaef905f42babd712467 100755 (executable)
@@ -884,6 +884,8 @@ wait_for_dev()
 
     _name="$(str_replace "$1" '/' '\x2f')"
 
+    type mark_hostonly >/dev/null 2>&1 && mark_hostonly "$hookdir/initqueue/finished/devexists-${_name}.sh"
+
     [ -e "${PREFIX}$hookdir/initqueue/finished/devexists-${_name}.sh" ] && return 0
 
     printf '[ -e "%s" ]\n' $1 \
@@ -898,6 +900,7 @@ wait_for_dev()
         if ! [ -L ${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device ]; then
             [ -d ${PREFIX}/etc/systemd/system/initrd.target.wants ] || mkdir -p ${PREFIX}/etc/systemd/system/initrd.target.wants
             ln -s ../${_name}.device ${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device
+            type mark_hostonly >/dev/null 2>&1 && mark_hostonly /etc/systemd/system/initrd.target.wants/${_name}.device
             _needreload=1
         fi
 
@@ -907,6 +910,7 @@ wait_for_dev()
                 echo "[Unit]"
                 echo "JobTimeoutSec=0"
             } > ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf
+            type mark_hostonly >/dev/null 2>&1 && mark_hostonly /etc/systemd/system/${_name}.device.d/timeout.conf
             _needreload=1
         fi
 
@@ -1243,3 +1247,13 @@ show_memstats()
             ;;
     esac
 }
+
+remove_hostonly_files() {
+    rm -fr /etc/cmdline /etc/cmdline.d/*.conf
+    if [ -f /lib/dracut/hostonly-files ]; then
+        while read line; do
+            [ -e "$line" ] || continue
+            rm -f "$line"
+        done < /lib/dracut/hostonly-files
+    fi
+}
index a1232eb5a40d721c814b70786290abd62365dcc3..2415d1518ff238250ce05549a348ed937d62bc00 100755 (executable)
@@ -112,6 +112,10 @@ fi
 
 source_conf /etc/conf.d
 
+if ! getargbool 1 'rd.hostonly'; then
+    remove_hostonly_files
+fi
+
 # run scriptlets to parse the command line
 make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab'
 getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"