Add rd.hostonly kernel command line parameters

rd.hostonly=0 will remove all configuration compiled in the initramfs
from the host on which it was build
master
Harald Hoyer 2014-06-24 18:13:28 +02:00
parent 899f5962ac
commit 5a57582050
12 changed files with 38 additions and 14 deletions

View 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.

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -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


View File

@ -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 \

View File

@ -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
}

View File

@ -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"