-((nil . ((sh-basic-offset . 4)
- (indent-tabs-mode . nil)
- )))
+;;; Directory Local Variables
+;;; For more information see (info "(emacs) Directory Variables")
+
+((sh-mode
+ (indent-tabs-mode)
+ (sh-basic-offset . 4)))
+
dracut.sh:
- restorecon final image file
- fail hard, if we find modules and modules.dep is missing
+- support --tmpdir as a relative path
+- add default path for --uefi
dracut-functions.sh:
- fix check_vol_slaves() volume group name stripping
--silent
--kerneldir
--firmwaredirs
+- fallback to non-hostonly mode if lsmod fails
lsinitrd:
- new option "--unpack"
- break at switch_root only for bare rd.break
- add rd.emergency=[reboot|poweroff|halt]
specifies what action to execute in case of a critical failure
+- rd.memdebug=4 gives information, about kernel module memory consumption
+ during loading
dmsquash-live:
- fixed livenet-generator execution flag
people swap keyboards sometimes and should be able to enter their disk password
- add usb-storage
To save the rdsosreport.txt to a USB stick, the usb-storage module is needed.
+- add xennet
+- add nvme
systemd:
- add /etc/machine-info
- support for iBFT IPv6
- support macaddr in brackets [] (commit 740c46c0224a187d6b5a42b4aa56e173238884cc)
- use arping2, if available
+- support multiple default gateways from DHCP server
nbd:
- add systemd generator
plymouth:
- also trigger the acpi subsystem
+syslog:
+- add imjournal.so to read systemd journal
+- move start from udev to initqueue/online
+
+caps:
+- make it a non default module
+
+livenet:
+- support nfs:// urls in livenet-generator
+
+nfs:
+- install all nfs modules non-hostonly
+
dracut-044
==========
creation:
dracut is an initramfs infrastructure.
+CentOS CI: [![Build Status](https://ci.centos.org/job/dracut-push-master/badge/icon)](https://ci.centos.org/job/dracut-push-master/)
+
asciidoc \
mdadm \
lvm2 \
+dmraid \
cryptsetup \
nfs-utils \
nbd \
tar \
wget \
rpm-build \
-dash \
${NULL}
TEST-04-FULL-SYSTEMD: systemd >= 187
#
export LC_MESSAGES=C
+if [[ "$EUID" = "0" ]]; then
+ export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,xattr,links -dfr"
+else
+ export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr"
+fi
+
# is_func <command>
# Check whether $1 is a function.
is_func() {
**--uefi**::
Instead of creating an initramfs image, dracut will create an UEFI executable,
- which can be executed by an UEFI BIOS.
+ which can be executed by an UEFI BIOS. The default output filename is
+ _<EFI>/EFI/Linux/linux-$kernel$-<MACHINE_ID>-<BUILD_ID>.efi_. <EFI> might be
+ _/efi_, _/boot_ or _/boot/efi_ depending on where the ESP partition is mounted.
+ The <BUILD_ID> is taken from BUILD_ID in _/usr/lib/os-release_ or if it exists
+ _/etc/os-release_ and is left out, if BUILD_ID is non-existant or empty.
+
+**--no-machineid**::
+ affects the default output filename of **--uefi** and will discard the <MACHINE_ID>
+ part.
**--uefi-stub _<FILE>_**::
Specifies the UEFI stub loader, which will load the attached kernel, initramfs and
_/run/initramfs/init.log_.
If "quiet" is set, it also logs to the console.
-**rd.memdebug=[0-3]**::
- Print memory usage info at various points, set the verbose level from 0 to 3.
+**rd.memdebug=[0-4]**::
+ Print memory usage info at various points, set the verbose level from 0 to 4.
+
Higher level means more debugging output:
+
1 - partial /proc/meminfo
2 - /proc/meminfo
3 - /proc/meminfo + /proc/slabinfo
+ 4 - /proc/meminfo + /proc/slabinfo + tracekomem
+ NOTE: tracekomem is a shell script utilizing kernel trace to track
+ the rough total memory consumption of kernel modules during
+ loading. It may override other trace configurations.
----
**rd.break**::
method. This is supported by dracut, but not recommended.
**rd.nfs.domain=**__<NFSv4 domain name>__::
- Set the NFSv4 domain name. Will overwrite the settings in _/etc/idmap.conf_.
+ Set the NFSv4 domain name. Will override the settings in _/etc/idmap.conf_.
**rd.net.dhcp.retry=**__<cnt>__::
If this option is set, dracut will try to connect via dhcp <cnt> times before failing.
Description
-----------
_dracut.conf_ is loaded during the initialisation phase of dracut. Command line
-parameter will overwrite any values set here.
+parameter will override any values set here.
_*.conf_ files are read from /usr/lib/dracut/dracut.conf.d and
/etc/dracut.conf.d. Files with the same name in /etc/dracut.conf.d will replace
files in /usr/lib/dracut/dracut.conf.d.
-The files are then read in alphanumerical order and will overwrite parameters
+The files are then read in alphanumerical order and will override parameters
set in _/etc/dracut.conf_. Each line specifies an attribute and a value. A '#'
indicates the beginning of a comment; following characters, up to the end of the
line are not interpreted.
-dracut command line options will overwrite any values set here.
+dracut command line options will override any values set here.
Configuration files must have the extension .conf; other extensions are ignored.
_/etc/dracut.conf.d/_.
_/etc/dracut.conf.d/_::
- Any _/etc/dracut.conf.d/*.conf_ file can overwrite the values in
+ Any _/etc/dracut.conf.d/*.conf_ file can override the values in
_/etc/dracut.conf_. The configuration files are read in alphanumerical
order.
inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh
----
-The _pase-instmodpost.sh_ parses the kernel command line for a argument
+The _parse-instmodpost.sh_ parses the kernel command line for a argument
rd.driver.post, blacklists the module from being autoloaded and installs the
hook _insmodpost.sh_ in the _initqueue/settled_.
--long kernel-image: \
--long no-hostonly-i18n \
--long hostonly-i18n \
+ --long no-machineid \
-- "$@")
if (( $? != 0 )); then
uefi_stub_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--kernel-image)
kernel_image_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
+ --no-machineid)
+ machine_id_l="no";;
--) shift; break;;
*) # should not even reach this point
fi
fi
-if ! [[ $outfile ]]; then
- [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
-
- if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
- outfile="/boot/${MACHINE_ID}/$kernel/initrd"
- else
- outfile="/boot/initramfs-$kernel.img"
- fi
-fi
-
-unset LC_MESSAGES
-unset LC_CTYPE
export LC_ALL=C
export LANG=C
+unset LC_MESSAGES
+unset LC_CTYPE
unset LD_LIBRARY_PATH
unset LD_PRELOAD
unset GREP_OPTIONS
[[ $loginstall_l ]] && loginstall="$loginstall_l"
[[ $uefi_stub_l ]] && uefi_stub="$uefi_stub_l"
[[ $kernel_image_l ]] && kernel_image="$kernel_image_l"
+[[ $machine_id_l ]] && machine_id="$machine_id_l"
+
+if ! [[ $outfile ]]; then
+ if [[ $machine_id != "no" ]]; then
+ [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
+ fi
+
+ if [[ $uefi == "yes" ]]; then
+ BUILD_ID=$(cat /etc/os-release /usr/lib/os-release \
+ | while read -r line || [[ $line ]]; do \
+ [[ $line =~ BUILD_ID\=* ]] && eval "$line" && echo "$BUILD_ID" && break; \
+ done)
+ if [[ -d /efi ]] && mountpoint -q /efi; then
+ efidir=/efi
+ else
+ efidir=/boot/EFI
+ if [[ -d /boot/efi/EFI ]] && mountpoint -q /boot/efi; then
+ efidir=/boot/efi/EFI
+ fi
+ fi
+ mkdir -p "$efidir/Linux"
+ outfile="$efidir/Linux/linux-$kernel${MACHINE_ID:+-${MACHINE_ID}}${BUILD_ID:+-${BUILD_ID}}.efi"
+ else
+ if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
+ outfile="/boot/${MACHINE_ID}/$kernel/initrd"
+ else
+ outfile="/boot/initramfs-$kernel.img"
+ fi
+ fi
+fi
# eliminate IFS hackery when messing with fw_dir
export DRACUT_FIRMWARE_PATH=${fw_dir// /:}
[[ $reproducible == yes ]] && DRACUT_REPRODUCIBLE=1
-readonly TMPDIR="$tmpdir"
+readonly TMPDIR="$(realpath -e "$tmpdir")"
+[ -d "$TMPDIR" ] || {
+ printf "%s\n" "dracut: Invalid tmpdir '$tmpdir'." >&2
+ exit 1
+}
readonly DRACUT_TMPDIR="$(mktemp -p "$TMPDIR/" -d -t dracut.XXXXXX)"
[ -d "$DRACUT_TMPDIR" ] || {
printf "%s\n" "dracut: mktemp -p '$TMPDIR/' -d -t dracut.XXXXXX failed." >&2
for _d in $hookdirs; do
mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$_d
done
- if [[ "$UID" = "0" ]]; then
+ if [[ "$EUID" = "0" ]]; then
[ -c ${initdir}/dev/null ] || mknod ${initdir}/dev/null c 1 3
[ -c ${initdir}/dev/kmsg ] || mknod ${initdir}/dev/kmsg c 1 11
[ -c ${initdir}/dev/console ] || mknod ${initdir}/dev/console c 5 1
+ [ -c ${initdir}/dev/random ] || mknod ${initdir}/dev/random c 1 8
+ [ -c ${initdir}/dev/urandom ] || mknod ${initdir}/dev/urandom c 1 9
fi
fi
mkdir -m 0755 -p "$object_destdir"
chmod --reference="$objectname" "$object_destdir"
fi
- cp --reflink=auto --sparse=auto -fa -t "$object_destdir" "$objectname"/*
+ $DRACUT_CP -t "$object_destdir" "$objectname"/*
else
- cp --reflink=auto --sparse=auto -fa -t "$destdir" "$objectname"
+ $DRACUT_CP -t "$destdir" "$objectname"
fi
done
fi
[[ -f $f ]] && inst_simple "$f"
done
if ! ldconfig -r "$initdir"; then
- if [[ $UID = 0 ]]; then
+ if [[ $EUID = 0 ]]; then
derror "ldconfig exited ungracefully"
else
derror "ldconfig might need uid=0 (root) for chroot()"
fi
PRELINK_BIN="$(command -v prelink)"
-if [[ $UID = 0 ]] && [[ $PRELINK_BIN ]]; then
+if [[ $EUID = 0 ]] && [[ $PRELINK_BIN ]]; then
if [[ $DRACUT_FIPS_MODE ]]; then
dinfo "*** Installing prelink files ***"
inst_multiple -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf /etc/prelink.cache
mkdir -p $_dest_dir
for table in $acpi_table_dir/*.aml; do
dinfo " Adding ACPI table: $table"
- cp -a $table $_dest_dir
+ $DRACUT_CP $table $_dest_dir
create_early_cpio="yes"
done
fi
fi
fi
-[[ "$UID" != 0 ]] && cpio_owner_root="-R 0:0"
+[[ "$EUID" != 0 ]] && cpio_owner_root="-R 0:0"
if [[ $create_early_cpio = yes ]]; then
echo 1 > "$early_cpio_dir/d/early_cpio"
%if 0%{?fedora} || 0%{?rhel} > 6
Requires: util-linux >= 2.21
Requires: systemd >= 219
+Requires: systemd-udev >= 219
Requires: procps-ng
Conflicts: grubby < 8.23
Conflicts: initscripts < 8.63-1
static bool arg_hostonly = false;
static char *destrootdir = NULL;
static char *kerneldir = NULL;
+static size_t kerneldirlen = 0;
static char **firmwaredirs = NULL;
static char **pathdirs;
static char *logdir = NULL;
if (ret == 0) {
struct timeval tv[2];
if (fchown(dest_desc, sb.st_uid, sb.st_gid) != 0)
- if(fchown(dest_desc, (uid_t) - 1, sb.st_gid) != 0)
- log_error("Failed to chown %s: %m", dst);
+ if(fchown(dest_desc, (uid_t) - 1, sb.st_gid) != 0) {
+ if (geteuid() == 0)
+ log_error("Failed to chown %s: %m", dst);
+ else
+ log_info("Failed to chown %s: %m", dst);
+ }
+
tv[0].tv_sec = sb.st_atime;
tv[0].tv_usec = 0;
tv[1].tv_sec = sb.st_mtime;
normal_copy:
pid = fork();
if (pid == 0) {
- execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,timestamps", "-fL", src, dst,
- NULL);
+ if (geteuid() == 0)
+ execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,xattr,timestamps", "-fL", src, dst,
+ NULL);
+ else
+ execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,timestamps", "-fL", src, dst,
+ NULL);
_exit(EXIT_FAILURE);
}
while (waitpid(pid, &ret, 0) < 0) {
if (errno != EINTR) {
ret = -1;
- log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %s", src,
- dst);
+ if (geteuid() == 0)
+ log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps -fL %s %s", src,
+ dst);
+ else
+ log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %s", src,
+ dst);
break;
}
}
break;
case ARG_KERNELDIR:
kerneldir = strdup(optarg);
+ if ((strncmp("/lib/modules/", kerneldir, 13) != 0)
+ && (strncmp("/usr/lib/modules/", kerneldir, 17) != 0)) {
+ char *p;
+ p = strstr(kerneldir, "/lib/modules/");
+ if (p != NULL)
+ kerneldirlen = p - kerneldir;
+ }
break;
case ARG_FIRMWAREDIRS:
firmwaredirs = strv_split(optarg, ":");
return 1;
}
- log_debug("dracut_install '%s'", path);
- ret = dracut_install(path, path, false, false, true);
+ log_debug("dracut_install '%s' '%s'", path, &path[kerneldirlen]);
+
+ ret = dracut_install(path, &path[kerneldirlen], false, false, true);
if (ret == 0) {
log_debug("dracut_install '%s' OK", kmod_module_get_name(mod));
} else if (!arg_optional) {
kmod_list_foreach(itr, modlist) {
mod = kmod_module_get_module(itr);
path = kmod_module_get_path(mod);
+
name = kmod_module_get_name(mod);
if (arg_mod_filter_noname && (regexec(&mod_filter_noname, name, 0, NULL, 0) == 0)) {
kmod_module_unref(mod);
continue;
}
- ret = dracut_install(path, path, false, false, true);
+ ret = dracut_install(path, &path[kerneldirlen], false, false, true);
if (ret == 0) {
- log_debug("dracut_install '%s' OK", kmod_module_get_name(mod));
+ log_debug("dracut_install '%s' '%s' OK", path, &path[kerneldirlen]);
install_firmware(mod);
} else {
- log_error("dracut_install '%s' ERROR", kmod_module_get_name(mod));
+ log_error("dracut_install '%s' '%s' ERROR", path, &path[kerneldirlen]);
}
kmod_module_unref(mod);
}
int i;
ctx = kmod_new(kerneldir, NULL);
-
if (arg_hostonly) {
err = kmod_module_new_from_loaded(ctx, &loaded_list);
if (err < 0) {
inst_multiple -o prelink
inst_simple /etc/system-fips
+ [ -c ${initdir}/dev/random ] || mknod ${initdir}/dev/random c 1 8 \
+ || {
+ dfatal "Cannot create /dev/random"
+ dfatal "To create an initramfs with fips support, dracut has to run as root"
+ return 1
+ }
+ [ -c ${initdir}/dev/urandom ] || mknod ${initdir}/dev/urandom c 1 9 \
+ || {
+ dfatal "Cannot create /dev/random"
+ dfatal "To create an initramfs with fips support, dracut has to run as root"
+ return 1
+ }
}
-
for _src in $(eval echo ${kbddir}/{${KBDSUBDIRS}}); do
inst_dir "$_src"
- cp --reflink=auto --sparse=auto -prfL -t "${initdir}/${_src}" "$_src"/*
+ $DRACUT_CP -L -t "${initdir}/${_src}" "$_src"/*
done
# remove unnecessary files
# point-to-point connection => set explicit route to gateway
echo ip route add $gw dev $netif > /tmp/net.$netif.gw
fi
- echo ip route replace default via $gw dev $netif >> /tmp/net.$netif.gw
+
+ echo "$gw" | {
+ IFS=' ' read -r main_gw other_gw
+ echo ip route replace default via $main_gw dev $netif >> /tmp/net.$netif.gw
+ if [ -n "$other_gw" ] ; then
+ for g in $other_gw; do
+ echo ip route add default via $g dev $netif >> /tmp/net.$netif.gw
+ done
+ fi
+ }
fi
if getargbool 1 rd.peerdns; then
# check, if we need VLAN's for this interface
if [ -z "$DO_VLAN_PHY" ] && [ -e /tmp/vlan.${netif}.phy ]; then
+ unset DO_VLAN
NO_AUTO_DHCP=yes DO_VLAN_PHY=yes ifup "$netif"
modprobe -b -q 8021q
for i in /tmp/vlan.*.${netif}; do
[ -e "$i" ] || continue
- read vlanname < "$i"
+ unset vlanname
+ unset phydevice
+ . "$i"
if [ -n "$vlanname" ]; then
linkup "$phydevice"
ip link add dev "$vlanname" link "$phydevice" type vlan id "$(get_vid $vlanname)"
exit 0
fi
+# Check, if interface is VLAN interface
+if ! [ -e /tmp/vlan.${netif}.phy ]; then
+ for i in /tmp/vlan.${netif}.*; do
+ [ -e "$i" ] || continue
+ export DO_VLAN=yes
+ break
+ done
+fi
+
+
# bridge this interface?
if [ -z "$NO_BRIDGE_MASTER" ]; then
for i in /tmp/bridge.*.info; do
rm -f /tmp/net.${netif}.did-setup
else
[ -e /tmp/net.${netif}.did-setup ] && exit 0
+ [ -z "$DO_VLAN" ] && \
[ -e /sys/class/net/$netif/address ] && \
[ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && exit 0
fi
if [ $ret -eq 0 ]; then
> /tmp/net.${netif}.up
- if [ -e /sys/class/net/${netif}/address ]; then
+ if [ -z "$DO_VLAN" ] && [ -e /sys/class/net/${netif}/address ]; then
> /tmp/net.$(cat /sys/class/net/${netif}/address).up
fi
unset bridgeslaves
unset bridgename
. "$i"
- IFACES="$IFACES ${bridgeslaves%% *}"
+ RAW_IFACES="$RAW_IFACES $bridgeslaves"
MASTER_IFACES="$MASTER_IFACES $bridgename"
done
unset bondname
. "$i"
# It is enough to fire up only one
- IFACES="$IFACES ${bondslaves%% *}"
+ RAW_IFACES="$RAW_IFACES $bondslaves"
MASTER_IFACES="$MASTER_IFACES ${bondname}"
done
- if [ -e /tmp/team.info ]; then
- . /tmp/team.info
- IFACES="$IFACES ${teamslaves}"
+ for i in /tmp/team.*.info; do
+ [ -e "$i" ] || continue
+ unset teamslaves
+ unset teammaster
+ . "$i"
+ RAW_IFACES="$RAW_IFACES ${teamslaves}"
MASTER_IFACES="$MASTER_IFACES ${teammaster}"
- fi
+ done
- for j in /tmp/vlan.*.phy; do
- [ -e "$j" ] || continue
+ for i in /tmp/vlan.*.phy; do
+ [ -e "$i" ] || continue
unset phydevice
- . "$j"
- for i in /tmp/vlan.*.${phydevice}; do
- [ -e "$i" ] || continue
+ . "$i"
+ RAW_IFACES="$RAW_IFACES $phydevice"
+ for j in /tmp/vlan.*.${phydevice}; do
+ [ -e "$j" ] || continue
unset vlanname
- . "$i"
- IFACES="$IFACES $phydevice"
+ . "$j"
MASTER_IFACES="$MASTER_IFACES ${vlanname}"
done
done
+ MASTER_IFACES="$(trim "$MASTER_IFACES")"
+ RAW_IFACES="$(trim "$RAW_IFACES")"
+
if [ -z "$IFACES" ]; then
[ -e /tmp/net.ifaces ] && read IFACES < /tmp/net.ifaces
fi
runcmd="RUN+=\"/sbin/initqueue --name ifup-\$env{INTERFACE} --unique --onetime $ifup\""
# We have some specific interfaces to handle
- if [ -n "$IFACES" ]; then
+ if [ -n "${RAW_IFACES}${IFACES}" ]; then
echo 'SUBSYSTEM!="net", GOTO="net_end"'
echo 'ACTION!="add|change|move", GOTO="net_end"'
- for iface in $IFACES; do
+ for iface in $IFACES $RAW_IFACES; do
case "$iface" in
??:??:??:??:??:??) # MAC address
cond="ATTR{address}==\"$iface\""
done
echo 'LABEL="net_end"'
- if [ -n "$MASTER_IFACES" ]; then
- wait_ifaces=$MASTER_IFACES
- else
- wait_ifaces=$IFACES
- fi
-
- for iface in $wait_ifaces; do
+ for iface in $IFACES; do
if [ "$bootdev" = "$iface" ] || [ "$NEEDNET" = "1" ]; then
echo "[ -f /tmp/net.${iface}.did-setup ]" >$hookdir/initqueue/finished/wait-$iface.sh
fi
ip addr flush dev $netif
echo "#empty" > /etc/resolv.conf
rm -f -- /tmp/net.$netif.did-setup
- [ -e /sys/class/net/$netif/address ] && \
+ [ -z "$DO_VLAN" ] && \
+ [ -e /sys/class/net/$netif/address ] && \
rm -f -- /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
# TODO: send "offline" uevent?
}
local netif="$1" f="" gw_ip="" netroot_ip="" iface="" IFACES=""
local _p
[ -e /tmp/net.$netif.did-setup ] && return
- [ -e /sys/class/net/$netif/address ] && \
+ [ -z "$DO_VLAN" ] && \
+ [ -e /sys/class/net/$netif/address ] && \
[ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && return
[ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
[ -z "$IFACES" ] && IFACES="$netif"
unset layer2
> /tmp/net.$netif.did-setup
- [ -e /sys/class/net/$netif/address ] && \
+ [ -z "$DO_VLAN" ] && \
+ [ -e /sys/class/net/$netif/address ] && \
> /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
}
# vlan=<vlanname>:<phydevice>
#
-# return if vlan already parsed
-[ -n "$vlanname" ] && return
-
-# Check if vlan parameter is valid
-if getarg vlan= >/dev/null ; then
- :
-fi
-
parsevlan() {
local v=${1}:
set --
esac
}
-unset vlanname phydevice
-
-if getarg vlan >/dev/null; then
- # Read vlan= parameters if they exist
- vlan="$(getarg vlan=)"
+for vlan in $(getargs vlan=); do
+ unset vlanname
+ unset phydevice
if [ ! "$vlan" = "vlan" ]; then
- parsevlan "$(getarg vlan=)"
+ parsevlan "$vlan"
fi
- echo "$phydevice" > /tmp/vlan.${phydevice}.phy
- echo "$vlanname" > /tmp/vlan.${vlanname}.${phydevice}
- return
-fi
+ echo "phydevice=\"$phydevice\"" > /tmp/vlan.${phydevice}.phy
+ {
+ echo "vlanname=\"$vlanname\""
+ echo "phydevice=\"$phydevice\""
+ } > /tmp/vlan.${vlanname}.${phydevice}
+done
unset slave
unset ethname
unset vlan
+ unset vlanname
+ unset phydevice
[ -e /tmp/bond.${netif}.info ] && . /tmp/bond.${netif}.info
[ -e /tmp/bridge.${netif}.info ] && . /tmp/bridge.${netif}.info
{
echo "# Generated by dracut initrd"
echo "NAME=\"$netif\""
- interface_bind "$netif" "$macaddr"
+ [ -z "$vlan" ] && interface_bind "$netif" "$macaddr"
echo "ONBOOT=yes"
echo "NETBOOT=yes"
echo "UUID=\"$uuid\""
if [ -n "$vlan" ] ; then
{
echo "TYPE=Vlan"
- echo "NAME=\"$netif\""
+ echo "DEVICE=\"$netif\""
echo "VLAN=yes"
echo "PHYSDEV=\"$phydevice\""
} >> /tmp/ifcfg/ifcfg-$netif
check() {
local _rootdev
# if cryptsetup is not installed, then we cannot support encrypted devices.
- require_binaries cryptsetup || return 1
+ require_any_binary $systemdutildir/systemd-cryptsetup cryptsetup || return 1
[[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in "${host_fs_types[@]}"; do
[[ $_cryptconf ]] && printf "%s\n" "$_cryptconf" >> "${initdir}/etc/cmdline.d/90crypt.conf"
fi
- inst_multiple cryptsetup rmdir readlink umount
- inst_script "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
- inst_script "$moddir"/probe-keydev.sh /sbin/probe-keydev
- inst_hook cmdline 10 "$moddir/parse-keydev.sh"
inst_hook cmdline 30 "$moddir/parse-crypt.sh"
if ! dracut_module_included "systemd"; then
+ inst_multiple cryptsetup rmdir readlink umount
+ inst_script "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
+ inst_script "$moddir"/probe-keydev.sh /sbin/probe-keydev
+ inst_hook cmdline 10 "$moddir/parse-keydev.sh"
inst_hook cleanup 30 "$moddir/crypt-cleanup.sh"
fi
=drivers/net/phy \
=drivers/net/team \
=drivers/net/ethernet \
- ecb arc4 bridge stp llc ipv6 bonding 8021q af_packet virtio_net
+ ecb arc4 bridge stp llc ipv6 bonding 8021q af_packet virtio_net xennet
hostonly="" instmods iscsi_ibft crc32c iscsi_boot_sysfs
}
if [ "$status" != "activating" ] && ! systemctl is-failed "$netroot_enc" >/dev/null 2>&1; then
systemd-run --no-block --service-type=oneshot --remain-after-exit --quiet \
--description="Login iSCSI Target $iscsi_target_name" \
+ -p 'DefaultDependencies=no' \
--unit="$netroot_enc" -- \
$(command -v iscsistart) \
-i "$iscsi_initiator" -t "$iscsi_target_name" \
local _i
local _nsslibs
inst_multiple -o portmap rpcbind rpc.statd mount.nfs \
- mount.nfs4 umount rpc.idmapd sed /etc/netconfig
+ mount.nfs4 umount rpc.idmapd sed /etc/netconfig chmod
inst_multiple /etc/services /etc/nsswitch.conf /etc/rpc /etc/protocols /etc/idmapd.conf
if [[ $hostonly_cmdline == "yes" ]]; then
inst "$moddir/nfsroot.sh" "/sbin/nfsroot"
inst "$moddir/nfs-lib.sh" "/lib/nfs-lib.sh"
mkdir -m 0755 -p "$initdir/var/lib/nfs/rpc_pipefs"
- mkdir -m 0755 -p "$initdir/var/lib/rpcbind"
+ mkdir -m 0770 -p "$initdir/var/lib/rpcbind"
mkdir -m 0755 -p "$initdir/var/lib/nfs/statd/sm"
# Rather than copy the passwd file in, just set a user for rpcbind
# file
chmod 770 "$initdir/var/lib/rpcbind"
grep -q '^rpc:' /etc/passwd \
- && grep -q '^rpc:' /etc/group \
- && chown rpc:rpc "$initdir/var/lib/rpcbind"
+ && grep -q '^rpc:' /etc/group
dracut_need_initqueue
}
root="$fstype"
echo '[ -e $NEWROOT/proc ]' > $hookdir/initqueue/finished/nfsroot.sh
+
+mkdir -p /var/lib/rpcbind
+chown rpc:rpc /var/lib/rpcbind
+chmod 770 /var/lib/rpcbind
inst_simple /etc/ssh/ssh_config
sed -i -e 's/\(^[[:space:]]*\)ProxyCommand/\1# ProxyCommand/' ${initdir}/etc/ssh/ssh_config
while read key val || [ -n "$key" ]; do
- [[ $key != "GlobalKnownHostsFile" ]] && continue
- inst_simple "$val"
- break
+ if [[ $key == "GlobalKnownHostsFile" ]]; then
+ inst_simple "$val"
+ # Copy customized UserKnowHostsFile
+ elif [[ $key == "UserKnownHostsFile" ]]; then
+ # Make sure that ~/foo will be copied as /root/foo in kdump's initramfs
+ if str_starts "$val" "~/"; then
+ val="/root/${val#"~/"}"
+ fi
+ inst_simple "$val"
+ fi
done < /etc/ssh/ssh_config
fi
if [ -d ${_terminfodir} ]; then
for i in "l/linux" "v/vt100" "v/vt102" "v/vt220"; do
inst_dir "$_terminfodir/${i%/*}"
- cp --reflink=auto --sparse=auto -prfL -t "${initdir}/${_terminfodir}/${i%/*}" "$_terminfodir/$i"
+ $DRACUT_CP -L -t "${initdir}/${_terminfodir}/${i%/*}" "$_terminfodir/$i"
done
fi
}
export rflags
export fstype
-make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab'
+make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab' '4+:komem'
# run scriptlets to parse the command line
getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
source_hook cmdline
source_conf /etc/conf.d
-make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab'
+make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
# pre pivot scripts are sourced just before we doing cleanup and switch over
# to the new root.
getarg 'rd.break=pre-mount' 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
source_conf /etc/conf.d
-make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab'
+make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
# pre pivot scripts are sourced just before we doing cleanup and switch over
# to the new root.
getarg 'rd.break=pre-pivot' 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
source_hook pre-pivot
+cleanup_trace_mem
# pre pivot cleanup scripts are sourced just before we switch over to the new root.
getarg 'rd.break=cleanup' 'rdbreak=cleanup' && emergency_shell -n cleanup "Break cleanup"
source_hook cleanup
source_conf /etc/conf.d
-make_trace_mem "hook pre-trigger" "1:shortmem" "2+:mem" "3+:slab"
+make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
source_hook pre-trigger
[ "${1%*"$2"}" != "$1" ]
}
+trim() {
+ local var="$*"
+ var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
+ var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
+ printf "%s" "$var"
+}
+
if [ -z "$DRACUT_SYSTEMD" ]; then
warn() {
setmemdebug() {
if [ -z "$DEBUG_MEM_LEVEL" ]; then
- export DEBUG_MEM_LEVEL=$(getargnum 0 0 3 rd.memdebug)
+ export DEBUG_MEM_LEVEL=$(getargnum 0 0 4 rd.memdebug)
fi
}
setmemdebug
+cleanup_trace_mem()
+{
+ # tracekomem based on kernel trace needs cleanup after use.
+ if [ "$DEBUG_MEM_LEVEL" -eq 4 ]; then
+ tracekomem --cleanup
+ fi
+}
+
# parameters: msg [trace_level:trace]...
make_trace_mem()
{
iomem)
cat /proc/iomem
;;
+ komem)
+ tracekomem
+ ;;
esac
}
fi
# run scriptlets to parse the command line
-make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab'
+make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab' '4+:komem'
getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
source_hook cmdline
udevproperty "hookdir=$hookdir"
-make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab'
+make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
getarg 'rd.break=pre-trigger' -d 'rdbreak=pre-trigger' && emergency_shell -n pre-trigger "Break before pre-trigger"
source_hook pre-trigger
# pre-mount happens before we try to mount the root filesystem,
# and happens once.
-make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab'
+make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
getarg 'rd.break=pre-mount' -d 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
source_hook pre-mount
# pre pivot scripts are sourced just before we doing cleanup and switch over
# to the new root.
-make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab'
+make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
getarg 'rd.break=pre-pivot' -d 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
source_hook pre-pivot
make_trace_mem "hook cleanup" '1:shortmem' '2+:mem' '3+:slab'
+cleanup_trace_mem
# pre pivot cleanup scripts are sourced just before we switch over to the new root.
getarg 'rd.break=cleanup' -d 'rdbreak=cleanup' && emergency_shell -n cleanup "Break cleanup"
source_hook cleanup
--- /dev/null
+#!/bin/sh
+
+# Try to find out kernel modules with large total memory allocation during loading.
+# For large slab allocation, it will fall into buddy, also not trace "mm_page_free"
+# considering large free is quite rare for module_init, thus saving tons of events
+# to avoid trace data overwritten.
+#
+# Therefore, tracing "mm_page_alloc"alone should be enough for the purpose.
+
+# "sys/kernel/tracing" has the priority if exists.
+get_trace_base() {
+ # trace access through debugfs would be obsolete if "/sys/kernel/tracing" is available.
+ if [ -d "/sys/kernel/tracing" ]; then
+ echo "/sys/kernel"
+ else
+ echo "/sys/kernel/debug"
+ fi
+}
+
+# We want to enable these trace events.
+get_want_events() {
+ echo "module:module_put module:module_load kmem:mm_page_alloc"
+}
+
+get_event_filter() {
+ echo "comm == systemd-udevd || comm == modprobe || comm == insmod"
+}
+
+is_trace_ready() {
+ local trace_base want_events current_events
+
+ trace_base=$(get_trace_base)
+ ! [ -f "$trace_base/tracing/trace" ] && return 1
+
+ [ "$(cat $trace_base/tracing/tracing_on)" -eq 0 ] && return 1
+
+ # Also check if trace events were properly setup.
+ want_events=$(get_want_events)
+ current_events=$(echo $(cat $trace_base/tracing/set_event))
+ [ "$current_events" != "$want_events" ] && return 1
+
+ return 0
+}
+
+prepare_trace() {
+ local trace_base
+
+ trace_base=$(get_trace_base)
+ # old debugfs interface case.
+ if ! [ -d "$trace_base/tracing" ]; then
+ mount none -t debugfs $trace_base
+ # new tracefs interface case.
+ elif ! [ -f "$trace_base/tracing/trace" ]; then
+ mount none -t tracefs "$trace_base/tracing"
+ fi
+
+ if ! [ -f "$trace_base/tracing/trace" ]; then
+ echo "WARN: Mount trace failed for kernel module memory analyzing."
+ return 1
+ fi
+
+ # Active all the wanted trace events.
+ echo "$(get_want_events)" > $trace_base/tracing/set_event
+
+ # There are three kinds of known applications for module loading:
+ # "systemd-udevd", "modprobe" and "insmod".
+ # Set them as the global events filter.
+ # NOTE: Some kernel may not support this format of filter, anyway
+ # the operation will fail and it doesn't matter.
+ echo "$(get_event_filter)" > $trace_base/tracing/events/kmem/filter 2>&1
+ echo "$(get_event_filter)" > $trace_base/tracing/events/module/filter 2>&1
+
+ # Set the number of comm-pid if supported.
+ if [ -f "$trace_base/tracing/saved_cmdlines_size" ]; then
+ # Thanks to filters, 4096 is big enough(also well supported).
+ echo 4096 > $trace_base/tracing/saved_cmdlines_size
+ fi
+
+ # Enable and clear trace data for the first time.
+ echo 1 > $trace_base/tracing/tracing_on
+ echo > $trace_base/tracing/trace
+ echo "Prepare trace success."
+ return 0
+}
+
+order_to_pages()
+{
+ local pages=1
+ local order=$1
+
+ while [ "$order" != 0 ]; do
+ order=$((order-1))
+ pages=$(($pages*2))
+ done
+
+ echo $pages
+}
+
+parse_trace_data() {
+ local module_name tmp_eval pages
+
+ cat "$(get_trace_base)/tracing/trace" | while read pid cpu flags ts function args
+ do
+ # Skip comment lines
+ if [ "$pid" = "#" ]; then
+ continue
+ fi
+
+ pid=${pid##*-}
+ function=${function%:}
+ if [ "$function" = "module_load" ]; then
+ # One module is being loaded, save the task pid for tracking.
+ # Remove the trailing after whitespace, there may be the module flags.
+ module_name=${args%% *}
+ # Mark current_module to track the task.
+ eval current_module_$pid="$module_name"
+ tmp_eval=$(eval echo '${module_loaded_'${module_name}'}')
+ if [ -n "$tmp_eval" ]; then
+ echo "WARN: \"$module_name\" was loaded multiple times!"
+ fi
+ eval unset module_loaded_$module_name
+ eval nr_alloc_pages_$module_name=0
+ continue
+ fi
+
+ module_name=$(eval echo '${current_module_'${pid}'}')
+ if [ -z "$module_name" ]; then
+ continue
+ fi
+
+ # Once we get here, the task is being tracked(is loading a module).
+ if [ "$function" = "module_put" ]; then
+ # Mark the module as loaded when the first module_put event happens after module_load.
+ tmp_eval=$(eval echo '${nr_alloc_pages_'${module_name}'}')
+ echo "$tmp_eval pages consumed by \"$module_name\""
+ eval module_loaded_$module_name=1
+ # Module loading finished, so untrack the task.
+ eval unset current_module_$pid
+ eval unset nr_alloc_pages_$module_name
+ continue
+ fi
+
+ if [ "$function" = "mm_page_alloc" ]; then
+ # Get order first, then convert to actual pages.
+ pages=$(echo $args | sed -e 's/.*order=\([0-9]*\) .*/\1/')
+ pages=$(order_to_pages "$pages")
+ tmp_eval=$(eval echo '${nr_alloc_pages_'${module_name}'}')
+ eval nr_alloc_pages_$module_name="$(($tmp_eval+$pages))"
+ fi
+ done
+}
+
+cleanup_trace() {
+ local trace_base
+
+ if is_trace_ready; then
+ trace_base=$(get_trace_base)
+ echo 0 > $trace_base/tracing/tracing_on
+ echo > $trace_base/tracing/trace
+ echo > $trace_base/tracing/set_event
+ echo 0 > $trace_base/tracing/events/kmem/filter
+ echo 0 > $trace_base/tracing/events/module/filter
+ fi
+}
+
+show_usage() {
+ echo "Find out kernel modules with large memory consumption during loading based on trace."
+ echo "Usage:"
+ echo "1) run it first to setup trace."
+ echo "2) run again to parse the trace data if any."
+ echo "3) run with \"--cleanup\" option to cleanup trace after use."
+}
+
+if [ "$1" = "--help" ]; then
+ show_usage
+ exit 0
+fi
+
+if [ "$1" = "--cleanup" ]; then
+ cleanup_trace
+ exit 0
+fi
+
+if is_trace_ready ; then
+ echo "tracekomem - Rough memory consumption by loading kernel modules (larger value with better accuracy)"
+ parse_trace_data
+else
+ prepare_trace
+fi
+
+exit $?
inst_script "$moddir/initqueue.sh" "/sbin/initqueue"
inst_script "$moddir/loginit.sh" "/sbin/loginit"
inst_script "$moddir/rdsosreport.sh" "/sbin/rdsosreport"
+ inst_script "$moddir/memtrace-ko.sh" "/sbin/tracekomem"
[ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib
mkdir -m 0755 -p ${initdir}/lib/dracut
check:
@[ "$$EUID" == "0" ] || { echo "'check' must be run as root! Please use 'sudo'."; exit 1; }
- @for i in TEST-[0-9]*; do \
+ @{ ret=0; \
+ for i in TEST-[0-9]*; do \
[ -d $$i ] || continue ; \
[ -f $$i/Makefile ] || continue ; \
if [ -n "$$TESTS" ]; then t=$${i##TEST-}; t=$${t%%-*}; [ "$${TESTS#*$$t*}" != "$$TESTS" ] || continue; fi; \
if [ -n "$$SKIP" ]; then t=$${i##TEST-}; t=$${t%%-*}; [ "$${SKIP#*$$t*}" != "$$SKIP" ] && continue; fi; \
- $(MAKE) -C $$i all ; \
- done
+ $(MAKE) -C $$i all ; ret=$$((ret + $$?)); \
+ done; exit $$ret; }
clean:
@for i in TEST-[0-9]*; do \
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/result \
- -m 256M -smp 2 -nographic \
+ -m 256M -smp 2 -nographic \
-net none \
-watchdog i6300esb -watchdog-action poweroff \
-no-reboot \
- -append "panic=1 root=LABEL=dracut rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 rd.shell=0 $DEBUGFAIL" \
+ -append "panic=1 root=LABEL=dracut rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 rd.shell=0 $DEBUGFAIL rd.memdebug=4" \
-initrd $TESTDIR/initramfs.testing || return 1
grep -F -m 1 -q dracut-root-block-success $TESTDIR/result || return 1
}
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
- -m 256M -smp 2 -nographic -net none \
+ -m 256M -smp 2 -nographic -net none \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1
test_run() {
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
- -m 256M -smp 2 -nographic \
+ -m 256M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 root=LABEL=dracut rw loglevel=77 systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug init=/sbin/init rd.shell=0 $DEBUGFAIL" \
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
- -m 256M -smp 2 -nographic -net none \
+ -m 256M -smp 2 -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
-drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
-drive format=raw,index=2,media=disk,file=$TESTDIR/result \
- -m 256M -smp 2 -nographic \
+ -m 256M -smp 2 -nographic \
-net none \
-watchdog i6300esb -watchdog-action poweroff \
-no-reboot \
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
-drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
- -m 256M -smp 2 -nographic -net none \
+ -m 256M -smp 2 -nographic -net none \
-append "root=/dev/dracut/root rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs || return 1
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
-drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
-drive format=raw,index=2,media=disk,file=$TESTDIR/result \
- -m 256M -smp 2 -nographic \
+ -m 256M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 root=LABEL=dracut $client_opts rd.retry=3 console=ttyS0,115200n81 selinux=0 $DEBUGOUT rd.shell=0 $DEBUGFAIL" \
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
-drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
- -m 256M -smp 2 -nographic -net none \
+ -m 256M -smp 2 -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs || return 1
DISKIMAGE=$TESTDIR/TEST-10-RAID-root.img
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$DISKIMAGE \
- -m 256M -smp 2 -nographic \
+ -m 256M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 root=/dev/dracut/root rd.auto rw rd.retry=10 console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$DISKIMAGE \
- -m 256M -smp 2 -nographic -net none \
+ -m 256M -smp 2 -nographic -net none \
-append "root=/dev/cannotreach rw rootfstype=ext2 console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $DISKIMAGE || return 1
test_run() {
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
- -m 256M -smp 2 -nographic \
+ -m 256M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
- $testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M -smp 2 -nographic -net none \
+ $testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M -smp 2 -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
cp --sparse=always --reflink=auto $TESTDIR/disk3.img $TESTDIR/disk3.img.new
$testdir/run-qemu \
- -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M -nographic -smp 2 \
+ -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M -nographic -smp 2 \
-drive format=raw,index=2,media=disk,file=$TESTDIR/disk2.img.new \
-drive format=raw,index=3,media=disk,file=$TESTDIR/disk3.img.new \
-net none \
-drive format=raw,index=1,media=disk,file=$TESTDIR/disk1.img \
-drive format=raw,index=2,media=disk,file=$TESTDIR/disk2.img \
-drive format=raw,index=3,media=disk,file=$TESTDIR/disk3.img \
- -m 256M -smp 2 -nographic -net none \
+ -m 256M -smp 2 -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/check-success.img \
- -m 256M -smp 2 -nographic \
+ -m 256M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 root=/dev/dracut/root rw rd.auto rd.retry=20 console=ttyS0,115200n81 selinux=0 rd.debug rootwait $LUKSARGS rd.shell=0 $DEBUGFAIL" \
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/check-success.img \
- -m 256M -smp 2 -nographic \
+ -m 256M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 root=/dev/dracut/root rw quiet rd.auto rd.retry=20 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/check-success.img \
- -m 256M -smp 2 -nographic \
+ -m 256M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 root=/dev/dracut/root rw quiet rd.auto rd.retry=10 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL rd.luks.uuid=failme" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
- $testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M -smp 2 -nographic -net none \
+ $testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M -smp 2 -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/disk1 \
-drive format=raw,index=2,media=disk,file=$TESTDIR/disk2 \
- -m 256M -nographic \
+ -m 256M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 $* root=LABEL=root rw debug rd.retry=5 rd.debug console=ttyS0,115200n81 selinux=0 rd.info rd.shell=0 $DEBUGFAIL" \
DISKIMAGE=$TESTDIR/TEST-15-BTRFSRAID-root.img
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$DISKIMAGE \
- -m 256M -smp 2 -nographic \
+ -m 256M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 root=LABEL=root rw rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$DISKIMAGE \
- -m 256M -smp 2 -nographic -net none \
+ -m 256M -smp 2 -nographic -net none \
-append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
-boot order=d \
-drive format=raw,bps=1000000,index=0,media=disk,file="$TESTDIR"/livecd.iso \
-drive format=raw,index=1,media=disk,file="$TESTDIR"/root.img \
- -m 256M -smp 2 \
+ -m 256M -smp 2 \
-nographic \
-net none \
-no-reboot \
# "$testdir"/run-qemu \
# -drive format=raw,bps=1000000,index=0,media=disk,file="$TESTDIR"/livecd.iso \
# -drive format=raw,index=1,media=disk,file="$TESTDIR"/root.img \
- # -m 256M -smp 2 \
+ # -m 256M -smp 2 \
# -net none \
# -append "root=live:CDLABEL=LiveCD live quiet rhgb selinux=0 rd.live.check" \
# -initrd "$TESTDIR"/initramfs.testing
test_run() {
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
- -m 256M -smp 2 -nographic \
+ -m 256M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
- $testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M -smp 2 -nographic -net none \
+ $testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M -smp 2 -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
fsck -a $TESTDIR/server.ext3 || return 1
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext3 \
- -m 256M -smp 2 \
+ -m 256M -smp 2 \
-display none \
-net socket,listen=127.0.0.1:12320 \
-net nic,macaddr=52:54:00:12:34:56,model=e1000 \
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/client.img \
- -m 256M -smp 2 -nographic \
+ -m 256M -smp 2 -nographic \
-net nic,macaddr=$mac,model=e1000 \
-net socket,connect=127.0.0.1:12320 \
-watchdog i6300esb -watchdog-action poweroff \
-drive format=raw,index=1,media=disk,file=$TESTDIR/root.ext3 \
-drive format=raw,index=2,media=disk,file=$TESTDIR/iscsidisk2.img \
-drive format=raw,index=3,media=disk,file=$TESTDIR/iscsidisk3.img \
- -m 512M -smp 2 \
+ -m 512M -smp 2 \
-display none \
-serial $SERIAL \
-net nic,macaddr=52:54:00:12:34:56,model=e1000 \
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/client.img \
- -m 512M -smp 2 -nographic \
+ -m 512M -smp 2 -nographic \
-net nic,macaddr=52:54:00:12:34:00,model=e1000 \
-net nic,macaddr=52:54:00:12:34:01,model=e1000 \
-net socket,connect=127.0.0.1:12330 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/client.img \
-drive format=raw,index=2,media=disk,file=$TESTDIR/iscsidisk2.img \
-drive format=raw,index=3,media=disk,file=$TESTDIR/iscsidisk3.img \
- -smp 2 -m 256M -nographic -net none \
+ -smp 2 -m 256M -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/client.img || return 1
-drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/nbd.ext2 \
-drive format=raw,index=2,media=disk,file=$TESTDIR/encrypted.ext2 \
- -m 256M -smp 2 \
+ -m 256M -smp 2 \
-display none \
-net nic,macaddr=52:54:00:12:34:56,model=e1000 \
-net socket,listen=127.0.0.1:12340 \
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/flag.img \
- -m 512M -smp 2 \
+ -m 512M -smp 2 \
-nographic \
-net nic,macaddr=$mac,model=e1000 \
-net socket,connect=127.0.0.1:12340 \
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/flag.img \
-drive format=raw,index=1,media=disk,file=$TESTDIR/encrypted.ext2 \
- -m 256M -smp 2\
+ -m 256M -smp 2\
-nographic -net none \
-append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
fsck -a "$TESTDIR"/server.ext3 || return 1
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file="$TESTDIR"/server.ext3 \
- -m 512M -smp 2 \
+ -m 512M -smp 2 \
-display none \
-net socket,listen=127.0.0.1:12350 \
-net nic,macaddr=52:54:01:12:34:56,model=e1000 \
return 1
fi
- $testdir/run-qemu -drive format=raw,index=0,media=disk,file="$TESTDIR"/client.img -m 512M -smp 2 -nographic \
+ $testdir/run-qemu -drive format=raw,index=0,media=disk,file="$TESTDIR"/client.img -m 512M -smp 2 -nographic \
-net socket,connect=127.0.0.1:12350 \
-net nic,macaddr=52:54:00:12:34:$mac1,model=e1000 \
-net nic,macaddr=52:54:00:12:34:$mac2,model=e1000 \
--- /dev/null
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hda", SYMLINK+="sda"
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hda*", SYMLINK+="sda$env{MINOR}"
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdb", SYMLINK+="sdb"
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdb*", SYMLINK+="sdb$env{MINOR}"
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdc", SYMLINK+="sdc"
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdc*", SYMLINK+="sdc$env{MINOR}"
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdd", SYMLINK+="sdd"
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdd*", SYMLINK+="sdd$env{MINOR}"
--- /dev/null
+all:
+ @$(MAKE) -s --no-print-directory -C ../.. all
+ @V=$(V) basedir=../.. testdir=../ ./test.sh --all
+setup:
+ @$(MAKE) --no-print-directory -C ../.. all
+ @basedir=../.. testdir=../ ./test.sh --setup
+clean:
+ @basedir=../.. testdir=../ ./test.sh --clean
+run:
+ @basedir=../.. testdir=../ ./test.sh --run
--- /dev/null
+#!/bin/sh
+exec >/dev/console 2>&1
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+strstr() { [ "${1#*$2*}" != "$1" ]; }
+CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
+export TERM=linux
+export PS1='initramfs-test:\w\$ '
+stty sane
+echo "made it to the rootfs! Powering down."
+
+(
+ echo OK
+ ip -o -4 address show scope global | while read n if rest; do echo $if;done
+ for i in /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-*; do
+ echo $i
+ grep -v 'UUID=' $i
+ done
+ echo EOF
+) > /dev/sda
+
+strstr "$CMDLINE" "rd.shell" && sh -i
+poweroff -f
--- /dev/null
+ddns-update-style none;
+
+use-host-decl-names true;
+
+subnet 192.168.50.0 netmask 255.255.255.0 {
+ option subnet-mask 255.255.255.0;
+ option routers 192.168.50.1;
+ next-server 192.168.50.1;
+ server-identifier 192.168.50.1;
+ option domain-name-servers 192.168.50.1;
+ option domain-search "example.com";
+ option domain-name "other.com";
+ option root-path "nfs:192.168.50.1:/nfs/client";
+ range 192.168.50.10 192.168.50.100;
+}
+
+subnet 192.168.51.0 netmask 255.255.255.0 {
+ option subnet-mask 255.255.255.0;
+ option routers 192.168.51.1;
+ next-server 192.168.51.1;
+ server-identifier 192.168.51.1;
+ option domain-name-servers 192.168.51.1;
+ option domain-search "example.com";
+ option domain-name "other.com";
+ option root-path "nfs:192.168.51.1:/nfs/client";
+ range 192.168.51.10 192.168.51.100;
+}
--- /dev/null
+/nfs/client 192.168.50.0/24(rw,insecure,no_subtree_check,no_root_squash)
--- /dev/null
+#!/bin/sh
+getarg rd.shell || poweroff -f
+getarg failme && poweroff -f
--- /dev/null
+127.0.0.1 localhost
+192.168.50.1 server
+192.168.50.100 client-if1
+192.168.50.101 client-if2
+192.168.50.102 client-if3
--- /dev/null
+#!/bin/sh
+exec </dev/console >/dev/console 2>&1
+set -x
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+export TERM=linux
+export PS1='nfstest-server:\w\$ '
+stty sane
+echo "made it to the rootfs!"
+echo server > /proc/sys/kernel/hostname
+
+wait_for_if_link() {
+ local cnt=0
+ local li
+ while [ $cnt -lt 600 ]; do
+ li=$(ip -o link show dev $1 2>/dev/null)
+ [ -n "$li" ] && return 0
+ sleep 0.1
+ cnt=$(($cnt+1))
+ done
+ return 1
+}
+
+wait_for_if_up() {
+ local cnt=0
+ local li
+ while [ $cnt -lt 200 ]; do
+ li=$(ip -o link show up dev $1)
+ [ -n "$li" ] && return 0
+ sleep 0.1
+ cnt=$(($cnt+1))
+ done
+ return 1
+}
+
+wait_for_route_ok() {
+ local cnt=0
+ while [ $cnt -lt 200 ]; do
+ li=$(ip route show)
+ [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
+ sleep 0.1
+ cnt=$(($cnt+1))
+ done
+ return 1
+}
+
+linkup() {
+ wait_for_if_link $1 2>/dev/null\
+ && ip link set $1 up 2>/dev/null\
+ && wait_for_if_up $1 2>/dev/null
+}
+
+modprobe -b -q 8021q
+>/dev/watchdog
+ip addr add 127.0.0.1/8 dev lo
+linkup lo
+ip link set dev eth0 name ens3
+ip addr add 192.168.50.1/24 dev ens3
+linkup ens3
+>/dev/watchdog
+ip link set dev eth1 name ens4
+ip link add dev ens4.1 link ens4 type vlan id 1
+ip link add dev ens4.2 link ens4 type vlan id 2
+ip link add dev ens4.3 link ens4 type vlan id 3
+ip link add dev ens4.4 link ens4 type vlan id 4
+ip addr add 192.168.54.1/24 dev ens4.1
+ip addr add 192.168.55.1/24 dev ens4.2
+ip addr add 192.168.56.1/24 dev ens4.3
+ip addr add 192.168.57.1/24 dev ens4.4
+linkup ens4
+ip link set dev eth2 name ens5
+ip addr add 192.168.51.1/24 dev ens5
+linkup ens5
+ip link set dev eth3 name ens6
+linkup ens6
+>/dev/watchdog
+modprobe af_packet
+> /dev/watchdog
+modprobe sunrpc
+>/dev/watchdog
+mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs
+>/dev/watchdog
+[ -x /sbin/portmap ] && portmap
+>/dev/watchdog
+[ -x /sbin/rpcbind ] && rpcbind
+>/dev/watchdog
+modprobe nfsd
+>/dev/watchdog
+mount -t nfsd nfsd /proc/fs/nfsd
+>/dev/watchdog
+exportfs -r
+>/dev/watchdog
+rpc.nfsd
+>/dev/watchdog
+rpc.mountd
+>/dev/watchdog
+rpc.idmapd
+>/dev/watchdog
+exportfs -r
+>/dev/watchdog
+>/var/lib/dhcpd/dhcpd.leases
+>/dev/watchdog
+chmod 777 /var/lib/dhcpd/dhcpd.leases
+>/dev/watchdog
+dhcpd -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases ens3 ens5
+#echo -n 'V' > /dev/watchdog
+#sh -i
+#tcpdump -i ens3
+# Wait forever for the VM to die
+echo "Serving NFS mounts"
+while :; do
+ sleep 10
+ >/dev/watchdog
+done
+mount -n -o remount,ro /
+poweroff -f
--- /dev/null
+#!/bin/bash
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+TEST_DESCRIPTION="root filesystem on NFS with bridging/bonding/vlan"
+KVERSION=${KVERSION-$(uname -r)}
+
+# Uncomment this to debug failures
+#DEBUGFAIL="rd.shell rd.break"
+#DEBUGFAIL="rd.shell rd.break rd.debug"
+#SERIAL="tcp:127.0.0.1:9999"
+
+run_server() {
+ # Start server first
+ echo "MULTINIC TEST SETUP: Starting DHCP/NFS server"
+
+ fsck -a "$TESTDIR"/server.ext3 || return 1
+ $testdir/run-qemu \
+ -hda "$TESTDIR"/server.ext3 \
+ -m 512M -smp 2 \
+ -display none \
+ -net socket,vlan=0,listen=127.0.0.1:12350 \
+ -net socket,vlan=1,listen=127.0.0.1:12351 \
+ -net socket,vlan=2,listen=127.0.0.1:12352 \
+ -net socket,vlan=3,listen=127.0.0.1:12353 \
+ -net nic,vlan=0,macaddr=52:54:01:12:34:56,model=e1000 \
+ -net nic,vlan=1,macaddr=52:54:01:12:34:57,model=e1000 \
+ -net nic,vlan=2,macaddr=52:54:01:12:34:58,model=e1000 \
+ -net nic,vlan=3,macaddr=52:54:01:12:34:59,model=e1000 \
+ ${SERIAL:+-serial "$SERIAL"} \
+ ${SERIAL:--serial file:"$TESTDIR"/server.log} \
+ -watchdog i6300esb -watchdog-action poweroff \
+ -kernel /boot/vmlinuz-"$KVERSION" \
+ -no-reboot \
+ -append "panic=1 loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0 rd.debug" \
+ -initrd "$TESTDIR"/initramfs.server \
+ -pidfile "$TESTDIR"/server.pid -daemonize || return 1
+ chmod 644 -- "$TESTDIR"/server.pid || return 1
+
+ # Cleanup the terminal if we have one
+ tty -s && stty sane
+
+ echo Sleeping 10 seconds to give the server a head start
+ sleep 10
+}
+
+client_test() {
+ local test_name="$1"
+ local do_vlan13="$2"
+ local cmdline="$3"
+ local check="$4"
+ local CONF
+
+ echo "CLIENT TEST START: $test_name"
+
+ [ "$do_vlan13" != "yes" ] && unset do_vlan13
+
+ # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
+ if ! dd if=/dev/zero of="$TESTDIR"/client.img bs=1M count=1; then
+ echo "Unable to make client sda image" 1>&2
+ return 1
+ fi
+
+ $testdir/run-qemu -hda "$TESTDIR"/client.img -m 256M -smp 2 -nographic \
+ -net socket,vlan=0,connect=127.0.0.1:12350 \
+ ${do_vlan13:+-net socket,vlan=1,connect=127.0.0.1:12351} \
+ -net socket,vlan=2,connect=127.0.0.1:12352 \
+ ${do_vlan13:+-net socket,vlan=3,connect=127.0.0.1:12353} \
+ -net nic,vlan=0,macaddr=52:54:00:12:34:01,model=e1000 \
+ -net nic,vlan=0,macaddr=52:54:00:12:34:02,model=e1000 \
+ -net nic,vlan=1,macaddr=52:54:00:12:34:03,model=e1000 \
+ -net nic,vlan=2,macaddr=52:54:00:12:34:04,model=e1000 \
+ -net nic,vlan=3,macaddr=52:54:00:12:34:05,model=e1000 \
+ -watchdog i6300esb -watchdog-action poweroff \
+ -kernel /boot/vmlinuz-"$KVERSION" \
+ -no-reboot \
+ -append "panic=1 $cmdline rd.debug $DEBUGFAIL rd.retry=5 rw console=ttyS0,115200n81 selinux=0 init=/sbin/init" \
+ -initrd "$TESTDIR"/initramfs.testing
+
+ {
+ read OK
+ if [[ "$OK" != "OK" ]]; then
+ echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
+ return 1
+ fi
+
+ while read line; do
+ [[ $line == END ]] && break
+ CONF+="$line "
+ done
+ } < "$TESTDIR"/client.img || return 1
+
+ if [[ "$check" != "$CONF" ]]; then
+ echo "Expected: '$check'"
+ echo
+ echo
+ echo "Got: '$CONF'"
+ echo "CLIENT TEST END: $test_name [FAILED - BAD CONF]"
+ return 1
+ fi
+
+ echo "CLIENT TEST END: $test_name [OK]"
+ return 0
+}
+
+
+test_run() {
+ if ! run_server; then
+ echo "Failed to start server" 1>&2
+ return 1
+ fi
+ test_client || { kill_server; return 1; }
+}
+
+test_client() {
+ client_test "Multiple VLAN" \
+ "yes" \
+ "
+vlan=vlan0001:ens4
+vlan=vlan2:ens4
+vlan=ens4.3:ens4
+vlan=ens4.0004:ens4
+ip=ens3:dhcp
+ip=192.168.54.101::192.168.54.1:24:test:vlan0001:none
+ip=192.168.55.102::192.168.55.1:24:test:vlan2:none
+ip=192.168.56.103::192.168.56.1:24:test:ens4.3:none
+ip=192.168.57.104::192.168.57.1:24:test:ens4.0004:none
+rd.neednet=1
+root=nfs:192.168.50.1:/nfs/client bootdev=ens3
+" \
+ 'ens3 ens4.0004 ens4.3 vlan0001 vlan2 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens3 # Generated by dracut initrd NAME="ens3" DEVICE="ens3" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Ethernet /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4.0004 # Generated by dracut initrd NAME="ens4.0004" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.57.104" PREFIX="24" GATEWAY="192.168.57.1" TYPE=Vlan DEVICE="ens4.0004" VLAN=yes PHYSDEV="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4.3 # Generated by dracut initrd NAME="ens4.3" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.56.103" PREFIX="24" GATEWAY="192.168.56.1" TYPE=Vlan DEVICE="ens4.3" VLAN=yes PHYSDEV="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-vlan0001 # Generated by dracut initrd NAME="vlan0001" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.54.101" PREFIX="24" GATEWAY="192.168.54.1" TYPE=Vlan DEVICE="vlan0001" VLAN=yes PHYSDEV="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-vlan2 # Generated by dracut initrd NAME="vlan2" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.55.102" PREFIX="24" GATEWAY="192.168.55.1" TYPE=Vlan DEVICE="vlan2" VLAN=yes PHYSDEV="ens4" EOF ' \
+ || return 1
+
+ client_test "Multiple Bonds" \
+ "yes" \
+ "
+bond=bond0:ens4,ens5
+bond=bond1:ens6,ens7
+ip=bond0:dhcp
+ip=bond1:dhcp
+rd.neednet=1
+root=nfs:192.168.50.1:/nfs/client bootdev=bond0
+" \
+ 'bond0 bond1 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-bond0 # Generated by dracut initrd NAME="bond0" DEVICE="bond0" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp BONDING_OPTS="" NAME="bond0" TYPE=Bond /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-bond1 # Generated by dracut initrd NAME="bond1" DEVICE="bond1" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp BONDING_OPTS="" NAME="bond1" TYPE=Bond /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4 # Generated by dracut initrd NAME="ens4" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond0" DEVICE="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5 # Generated by dracut initrd NAME="ens5" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond0" DEVICE="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens6 # Generated by dracut initrd NAME="ens6" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond1" DEVICE="ens6" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens7 # Generated by dracut initrd NAME="ens7" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond1" DEVICE="ens7" EOF ' \
+ || return 1
+
+ client_test "Multiple Bridges" \
+ "no" \
+ "
+bridge=br0:ens4,ens5
+bridge=br1:ens6,ens7
+ip=br0:dhcp
+ip=br1:dhcp
+rd.neednet=1
+root=nfs:192.168.50.1:/nfs/client bootdev=br0
+" \
+ 'br0 br1 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-br0 # Generated by dracut initrd NAME="br0" DEVICE="br0" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Bridge NAME="br0" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-br1 # Generated by dracut initrd NAME="br1" DEVICE="br1" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Bridge NAME="br1" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4 # Generated by dracut initrd NAME="ens4" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br0" DEVICE="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5 # Generated by dracut initrd NAME="ens5" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br0" DEVICE="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens6 # Generated by dracut initrd NAME="ens6" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br1" DEVICE="ens6" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens7 # Generated by dracut initrd NAME="ens7" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br1" DEVICE="ens7" EOF ' \
+ || return 1
+
+ kill_server
+ return 0
+}
+
+test_setup() {
+ # Make server root
+ dd if=/dev/null of="$TESTDIR"/server.ext3 bs=1M seek=60
+ mke2fs -j -F -- "$TESTDIR"/server.ext3
+ mkdir -- "$TESTDIR"/mnt
+ mount -o loop -- "$TESTDIR"/server.ext3 "$TESTDIR"/mnt
+
+ (
+ export initdir="$TESTDIR"/mnt
+ . "$basedir"/dracut-init.sh
+
+ (
+ cd "$initdir";
+ mkdir -p -- dev sys proc run etc var/run tmp var/lib/{dhcpd,rpcbind}
+ mkdir -p -- var/lib/nfs/{v4recovery,rpc_pipefs}
+ chmod 777 -- var/lib/rpcbind var/lib/nfs
+ )
+
+ for _f in modules.builtin.bin modules.builtin; do
+ [[ $srcmods/$_f ]] && break
+ done || {
+ dfatal "No modules.builtin.bin and modules.builtin found!"
+ return 1
+ }
+
+ for _f in modules.builtin.bin modules.builtin modules.order; do
+ [[ $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f"
+ done
+
+ inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
+ dmesg mkdir cp ping exportfs \
+ modprobe rpc.nfsd rpc.mountd showmount tcpdump \
+ /etc/services sleep mount chmod
+ for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
+ [ -f "${_terminfodir}"/l/linux ] && break
+ done
+ inst_multiple -o "${_terminfodir}"/l/linux
+ type -P portmap >/dev/null && inst_multiple portmap
+ type -P rpcbind >/dev/null && inst_multiple rpcbind
+ [ -f /etc/netconfig ] && inst_multiple /etc/netconfig
+ type -P dhcpd >/dev/null && inst_multiple dhcpd
+ [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
+ instmods nfsd sunrpc ipv6 lockd af_packet 8021q
+ inst_simple /etc/os-release
+ inst ./server-init.sh /sbin/init
+ inst ./hosts /etc/hosts
+ inst ./exports /etc/exports
+ inst ./dhcpd.conf /etc/dhcpd.conf
+ inst_multiple /etc/nsswitch.conf /etc/rpc /etc/protocols
+
+ inst_multiple rpc.idmapd /etc/idmapd.conf
+
+ inst_libdir_file 'libnfsidmap_nsswitch.so*'
+ inst_libdir_file 'libnfsidmap/*.so*'
+ inst_libdir_file 'libnfsidmap*.so*'
+
+ _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
+ | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
+ _nsslibs=${_nsslibs#|}
+ _nsslibs=${_nsslibs%|}
+
+ inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'
+
+ inst /etc/nsswitch.conf /etc/nsswitch.conf
+ inst /etc/passwd /etc/passwd
+ inst /etc/group /etc/group
+
+ cp -a -- /etc/ld.so.conf* "$initdir"/etc
+ ldconfig -r "$initdir"
+ dracut_kernel_post
+ )
+
+ # Make client root inside server root
+ (
+ export initdir="$TESTDIR"/mnt/nfs/client
+ . "$basedir"/dracut-init.sh
+ inst_multiple sh shutdown poweroff stty cat ps ln ip \
+ mount dmesg mkdir cp ping grep ls
+ for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
+ [[ -f ${_terminfodir}/l/linux ]] && break
+ done
+ inst_multiple -o "${_terminfodir}"/l/linux
+ inst_simple /etc/os-release
+ inst ./client-init.sh /sbin/init
+ (
+ cd "$initdir"
+ mkdir -p -- dev sys proc etc run
+ mkdir -p -- var/lib/nfs/rpc_pipefs
+ )
+ inst /etc/nsswitch.conf /etc/nsswitch.conf
+ inst /etc/passwd /etc/passwd
+ inst /etc/group /etc/group
+
+ inst_multiple rpc.idmapd /etc/idmapd.conf
+ inst_libdir_file 'libnfsidmap_nsswitch.so*'
+ inst_libdir_file 'libnfsidmap/*.so*'
+ inst_libdir_file 'libnfsidmap*.so*'
+
+ _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc/nsswitch.conf \
+ | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
+ _nsslibs=${_nsslibs#|}
+ _nsslibs=${_nsslibs%|}
+
+ inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'
+
+ cp -a -- /etc/ld.so.conf* "$initdir"/etc
+ ldconfig -r "$initdir"
+ )
+
+ umount "$TESTDIR"/mnt
+ rm -fr -- "$TESTDIR"/mnt
+
+ # Make an overlay with needed tools for the test harness
+ (
+ export initdir="$TESTDIR"/overlay
+ . "$basedir"/dracut-init.sh
+ inst_multiple poweroff shutdown
+ inst_hook emergency 000 ./hard-off.sh
+ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
+ )
+
+ # Make server's dracut image
+ $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
+ --no-early-microcode \
+ -m "udev-rules base rootfs-block fs-lib debug kernel-modules watchdog" \
+ -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd e1000 i6300esb ib700wdt" \
+ --no-hostonly-cmdline -N \
+ -f "$TESTDIR"/initramfs.server "$KVERSION" || return 1
+
+ # Make client's dracut image
+ $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
+ --no-early-microcode \
+ -o "plymouth" \
+ -a "debug" \
+ -d "af_packet piix sd_mod sr_mod ata_piix ide-gd_mod e1000 nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files sunrpc i6300esb ib700wdt" \
+ --no-hostonly-cmdline -N \
+ -f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
+}
+
+kill_server() {
+ if [[ -s "$TESTDIR"/server.pid ]]; then
+ kill -TERM -- $(cat "$TESTDIR"/server.pid)
+ rm -f -- "$TESTDIR"/server.pid
+ fi
+}
+
+test_cleanup() {
+ kill_server
+}
+
+. "$testdir"/test-functions
mkdir -p "$rootdir/proc"
mkdir -p "$rootdir/sys"
mkdir -p "$rootdir/dev"
+ mkdir -p "$rootdir/boot"
-trap 'ret=$?; [[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; } || :; exit $ret;' EXIT
-trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; } || :; exit 1;' SIGINT
+ trap 'ret=$?; [[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; } || :; exit $ret;' EXIT
+ trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; } || :; exit 1;' SIGINT
mount --bind /proc "$rootdir/proc"
mount --bind /sys "$rootdir/sys"
mount -t devtmpfs devtmpfs "$rootdir/dev"
+ mkdir -p "$rootdir/$TESTDIR"
+ cp --reflink=auto -a \
+ "$TESTDIR"/dracut-[0-9]*.$(arch).rpm \
+ "$TESTDIR"/dracut-network-[0-9]*.$(arch).rpm \
+ "$rootdir/$TESTDIR/"
+
dnf_or_yum=yum
- command -v dnf >/dev/null && dnf_or_yum=dnf
- $dnf_or_yum --nogpgcheck --installroot "$rootdir"/ --releasever 25 --disablerepo=updates-testing install --allowerasing -y \
- $dnf_or_yum \
- passwd \
- rootfiles \
- systemd \
- kernel \
- fedora-release \
- device-mapper-multipath \
- lvm2 \
- mdadm \
- bash \
- iscsi-initiator-utils \
- "$TESTDIR"/dracut-[0-9]*.$(arch).rpm \
- "$TESTDIR"/dracut-network-[0-9]*.$(arch).rpm
+ dnf_or_yum_cmd=yum
+ command -v dnf >/dev/null && { dnf_or_yum="dnf"; dnf_or_yum_cmd="dnf --allowerasing"; }
+ for (( i=0; i < 5 ; i++)); do
+ $dnf_or_yum_cmd -v --nogpgcheck --installroot "$rootdir"/ --releasever 25 --disablerepo='*' \
+ --enablerepo=fedora --enablerepo=updates \
+ install -y \
+ $dnf_or_yum \
+ passwd \
+ rootfiles \
+ systemd \
+ systemd-udev \
+ kernel \
+ kernel-core \
+ redhat-release \
+ device-mapper-multipath \
+ lvm2 \
+ mdadm \
+ bash \
+ iscsi-initiator-utils \
+ "$TESTDIR"/dracut-[0-9]*.$(arch).rpm \
+ ${NULL} && break
+ #"$TESTDIR"/dracut-config-rescue-[0-9]*.$(arch).rpm \
+ #"$TESTDIR"/dracut-network-[0-9]*.$(arch).rpm \
+ # ${NULL}
+ done
+ (( i < 5 ))
cat >"$rootdir"/test.sh <<EOF
#!/bin/bash
-set -xe
+set -x
export LC_MESSAGES=C
rpm -Va |& grep -F -v '85-display-manager.preset' &> /test.output
find / -xdev -type f -not -path '/var/*' \
-not -path '/dev/null' \
-not -path "/boot/loader/entries/\$(cat /etc/machine-id)-*" \
-not -path "/boot/\$(cat /etc/machine-id)/*" \
- -exec rpm -qf '{}' ';' | \
+ -not -path '/etc/openldap/certs/*' \
+ -print0 | xargs -0 rpm -qf | \
grep -F 'not owned' &>> /test.output || :
exit 0
EOF
chroot "$rootdir" /test.sh || :
if [[ -s "$rootdir"/test.output ]]; then
- failed=1
- echo TEST Failed >&2
- cat "$rootdir"/test.output >&2
+ failed=1
+ echo TEST Failed >&2
+ cat "$rootdir"/test.output >&2
fi
umount "$rootdir/proc"
fi
fi
-exec sudo $BIN $ARGS -kernel $VMLINUZ "$@"
+exec sudo $BIN $ARGS -kernel $VMLINUZ -cpu host "$@"
+++ /dev/null
-dash
-bridge-utils
-asciidoc
-mdadm
-lvm2
-cryptsetup
-nfs-utils
-nbd
-dhcp-server
-scsi-target-utils
-iscsi-initiator-utils
-