diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc index 10550eef..b5b1bae8 100644 --- a/dracut.cmdline.7.asc +++ b/dracut.cmdline.7.asc @@ -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. diff --git a/modules.d/90crypt/module-setup.sh b/modules.d/90crypt/module-setup.sh index 57074049..d8f36f4b 100755 --- a/modules.d/90crypt/module-setup.sh +++ b/modules.d/90crypt/module-setup.sh @@ -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" diff --git a/modules.d/90kernel-modules/module-setup.sh b/modules.d/90kernel-modules/module-setup.sh index 5271438d..4854ac9b 100755 --- a/modules.d/90kernel-modules/module-setup.sh +++ b/modules.d/90kernel-modules/module-setup.sh @@ -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 diff --git a/modules.d/90lvm/module-setup.sh b/modules.d/90lvm/module-setup.sh index 5b810b93..00d4e5a7 100755 --- a/modules.d/90lvm/module-setup.sh +++ b/modules.d/90lvm/module-setup.sh @@ -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 diff --git a/modules.d/90mdraid/module-setup.sh b/modules.d/90mdraid/module-setup.sh index 81c94f2d..f75f69a3 100755 --- a/modules.d/90mdraid/module-setup.sh +++ b/modules.d/90mdraid/module-setup.sh @@ -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 diff --git a/modules.d/95dasd/module-setup.sh b/modules.d/95dasd/module-setup.sh index da0f3c08..92c14f5d 100755 --- a/modules.d/95dasd/module-setup.sh +++ b/modules.d/95dasd/module-setup.sh @@ -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 diff --git a/modules.d/95udev-rules/module-setup.sh b/modules.d/95udev-rules/module-setup.sh index 4e75c0b8..7f38ed37 100755 --- a/modules.d/95udev-rules/module-setup.sh +++ b/modules.d/95udev-rules/module-setup.sh @@ -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 diff --git a/modules.d/95zfcp/module-setup.sh b/modules.d/95zfcp/module-setup.sh index b96ccd2e..9526caa4 100755 --- a/modules.d/95zfcp/module-setup.sh +++ b/modules.d/95zfcp/module-setup.sh @@ -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 } diff --git a/modules.d/98systemd/dracut-cmdline.sh b/modules.d/98systemd/dracut-cmdline.sh index 3170e756..0507e651 100755 --- a/modules.d/98systemd/dracut-cmdline.sh +++ b/modules.d/98systemd/dracut-cmdline.sh @@ -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 diff --git a/modules.d/98systemd/module-setup.sh b/modules.d/98systemd/module-setup.sh index e2efc427..9a8296af 100755 --- a/modules.d/98systemd/module-setup.sh +++ b/modules.d/98systemd/module-setup.sh @@ -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 \ diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index 33f76784..ed40b822 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -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 +} diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh index a1232eb5..2415d151 100755 --- a/modules.d/99base/init.sh +++ b/modules.d/99base/init.sh @@ -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"