diff --git a/dracut.8.asc b/dracut.8.asc index 6a79d12..8b50782 100644 --- a/dracut.8.asc +++ b/dracut.8.asc @@ -75,12 +75,12 @@ version is: ---- If you want to create lighter, smaller initramfs images, you may want to specify -the --host-only or -H option. Using this option, the resulting image will +the --hostonly or -H option. Using this option, the resulting image will contain only those dracut modules, kernel modules and filesystems, which are needed to boot this specific machine. This has the drawback, that you can't put the disk on another controller or machine, and that you can't switch to another root filesystem, without recreating the initramfs image. The usage of the ---host-only option is only for experts and you will have to keep the broken +--hostonly option is only for experts and you will have to keep the broken pieces. At least keep a copy of a general purpose image (and corresponding kernel) as a fallback to rescue your system. @@ -376,7 +376,7 @@ will not be able to boot. Equivalent to "--compress=bzip2" [WARNING] ==== Make sure your kernel has lzma decompression support compiled in, otherwise you -will not be able to boot. Equivalent to "--compress=lzma -9" +will not be able to boot. Equivalent to "lzma --compress=lzma -9" ==== **--xz**:: @@ -385,8 +385,7 @@ will not be able to boot. Equivalent to "--compress=lzma -9" [WARNING] ==== Make sure your kernel has xz decompression support compiled in, otherwise you -will not be able to boot. Equivalent to "--compress=xz --check=crc32 ---lzma2=dict=1MiB" +will not be able to boot. Equivalent to "lzma --compress=xz --check=crc32 --lzma2=dict=1MiB" ==== **--compress** __:: @@ -409,6 +408,27 @@ will not be able to boot. Equivalent to "--compress=xz --check=crc32 **--keep**:: Keep the initramfs temporary directory for debugging purposes. +**--printsize**:: + Print out the module install size + +**--profile**: + Output profile information of the build process + +**--ro-mnt**: + Mount / and /usr read-only by default. + +**-L, --stdlog** __:: + [0-6] Specify logging level (to standard error) +---- + 0 - suppress any messages + 1 - only fatal errors + 2 - all errors + 3 - warnings + 4 - info + 5 - debug info (here starts lots of output) + 6 - trace info (and even more) +---- + **--regenerate-all**:: Regenerate all initramfs images at the default location with the kernel versions found on the system. Additional parameters are passed through. diff --git a/dracut.sh b/dracut.sh index 5e9ea3e..586172c 100755 --- a/dracut.sh +++ b/dracut.sh @@ -74,19 +74,21 @@ Creates initial ramdisk images for preloading modules call when building the initramfs. Modules are located in /usr/lib/dracut/modules.d. -o, --omit [LIST] Omit a space-separated list of dracut modules. + --force-add [LIST] Force to add a space-separated list of dracut modules + to the default set of modules, when -H is specified. -d, --drivers [LIST] Specify a space-separated list of kernel modules to - exclusively include in the initramfs. - --add-drivers [LIST] Specify a space-separated list of kernel - modules to add to the initramfs. + exclusively include in the initramfs. + --add-drivers [LIST] Specify a space-separated list of kernel + modules to add to the initramfs. --omit-drivers [LIST] Specify a space-separated list of kernel - modules not to add to the initramfs. + modules not to add to the initramfs. --filesystems [LIST] Specify a space-separated list of kernel filesystem - modules to exclusively include in the generic - initramfs. + modules to exclusively include in the generic + initramfs. -k, --kmoddir [DIR] Specify the directory, where to look for kernel - modules + modules --fwdir [DIR] Specify additional directories, where to look for - firmwares, separated by : + firmwares, separated by : --kernel-only Only install kernel drivers and firmware files --no-kernel Do not install kernel drivers and firmware files --kernel-cmdline [PARAMETERS] Specify default kernel command line parameters @@ -317,7 +319,9 @@ TEMP=$(unset POSIXLY_CORRECT; getopt \ --long quiet \ --long local \ --long hostonly \ + --long host-only \ --long no-hostonly \ + --long no-host-only \ --long fstab \ --long help \ --long bzip2 \ @@ -391,8 +395,10 @@ while :; do [[ -f "$(readlink -f ${0%/*})/dracut-functions.sh" ]] \ && dracutbasedir="$(readlink -f ${0%/*})" ;; - -H|--hostonly) hostonly_l="yes" ;; - -N|--no-hostonly) hostonly_l="no" ;; + -H|--hostonly|--host-only) + hostonly_l="yes" ;; + -N|--no-hostonly|--no-host-only) + hostonly_l="no" ;; --fstab) use_fstab_l="yes" ;; -h|--help) long_usage; exit 1 ;; -i|--include) push include_src "$2" diff --git a/dracut.spec b/dracut.spec index af417a4..cb605c6 100644 --- a/dracut.spec +++ b/dracut.spec @@ -92,7 +92,7 @@ Requires: kbd kbd-misc %if 0%{?fedora} || 0%{?rhel} > 6 Requires: util-linux >= 2.21 -Requires: systemd >= 198-5 +Requires: systemd >= 199 Conflicts: grubby < 8.23 %else Requires: udev > 166 diff --git a/modules.d/90crypt/parse-crypt.sh b/modules.d/90crypt/parse-crypt.sh index d61220c..4cb281b 100755 --- a/modules.d/90crypt/parse-crypt.sh +++ b/modules.d/90crypt/parse-crypt.sh @@ -27,6 +27,14 @@ else printf -- '--name cryptroot-ask-%%k %s ' $(command -v cryptroot-ask) printf -- '$env{DEVNAME} luks-$env{ID_FS_UUID} %s"\n' $tout } >> /etc/udev/rules.d/70-luks.rules.new + else + { + printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", ' + printf -- 'ENV{ID_FS_UUID}=="*%s*", ' $luksid + printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue) + printf -- '--name systemd-cryptsetup-%%k %s start ' $(command -v systemctl) + printf -- 'systemd-cryptsetup@luks$$(dev_unit_name -$env{ID_FS_UUID}).service"\n' + } >> /etc/udev/rules.d/70-luks.rules.new fi uuid=$luksid diff --git a/modules.d/95nfs/module-setup.sh b/modules.d/95nfs/module-setup.sh index 7c3a64d..6d4d412 100755 --- a/modules.d/95nfs/module-setup.sh +++ b/modules.d/95nfs/module-setup.sh @@ -62,12 +62,8 @@ install() { # Rather than copy the passwd file in, just set a user for rpcbind # We'll save the state and restart the daemon from the root anyway - egrep '^nfsnobody:' /etc/passwd >> "$initdir/etc/passwd" - egrep '^rpc:' /etc/passwd >> "$initdir/etc/passwd" - egrep '^rpcuser:' /etc/passwd >> "$initdir/etc/passwd" - #type -P nologin >/dev/null && dracut_install nologin - egrep '^nobody:' /etc/group >> "$initdir/etc/group" - egrep '^rpc:' /etc/group >> "$initdir/etc/group" + egrep '^nfsnobody:|^rpc:|^rpcuser:' /etc/passwd >> "$initdir/etc/passwd" + egrep '^nogroup:|^rpc:|^nobody:' /etc/group >> "$initdir/etc/group" # rpc user needs to be able to write to this directory to save the warmstart # file diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index e456b01..f2b16d3 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -818,6 +818,15 @@ wait_for_mount() } >> "$hookdir/emergency/90-${_name}.sh" } +dev_unit_name() +{ + _name="${1%%/}" + _name="${_name##/}" + _name="$(str_replace "$_name" '-' '\x2d')" + _name="$(str_replace "$_name" '/' '-')" + echo "$_name" +} + # wait_for_dev # # Installs a initqueue-finished script, @@ -835,14 +844,18 @@ wait_for_dev() } >> "${PREFIX}$hookdir/emergency/80-${_name}.sh" if [ -n "$DRACUT_SYSTEMD" ]; then - _name="${1%%/}" - _name="${_name##/}" - _name="$(str_replace "$_name" '-' '\x2d')" - _name="$(str_replace "$_name" '/' '-')" + _name=$(dev_unit_name "$1") if ! [ -L ${PREFIX}/etc/systemd/system/initrd.target.requires/${_name}.device ]; then [ -d ${PREFIX}/etc/systemd/system/initrd.target.requires ] || mkdir -p ${PREFIX}/etc/systemd/system/initrd.target.requires ln -s ../${_name}.device ${PREFIX}/etc/systemd/system/initrd.target.requires/${_name}.device fi + + mkdir -p ${PREFIX}/etc/systemd/system/${_name}.device.d + { + echo "[Unit]" + echo "JobTimeoutSec=3600" + } > ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf + [ -z "$PREFIX" ] && /sbin/initqueue --onetime --unique --name daemon-reload systemctl daemon-reload fi } @@ -852,6 +865,12 @@ cancel_wait_for_dev() _name="$(str_replace "$1" '/' '\\x2f')" rm -f "$hookdir/initqueue/finished/devexists-${_name}.sh" rm -f "$hookdir/emergency/80-${_name}.sh" + if [ -n "$DRACUT_SYSTEMD" ]; then + _name=$(dev_unit_name "$1") + rm -f ${PREFIX}/etc/systemd/system/initrd.target.requires/${_name}.device + rm -f ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf + /sbin/initqueue --onetime --unique --name daemon-reload systemctl daemon-reload + fi } killproc() { @@ -1017,7 +1036,7 @@ listlist() { # returns OK if both lists contain the same values. An order and a duplication # doesn't matter. -# +# # $1 = separator # $2 = list1 # $3 = list2 diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh index b441a27..410201a 100755 --- a/modules.d/99base/init.sh +++ b/modules.d/99base/init.sh @@ -104,7 +104,7 @@ else fi [ -f /etc/initrd-release ] && . /etc/initrd-release -[ -n "$VERSION" ] && info "dracut-$VERSION" +[ -n "$VERSION_ID" ] && info "$NAME-$VERSION_ID" source_conf /etc/conf.d diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh index 7f2940b..4955b7b 100755 --- a/modules.d/99base/module-setup.sh +++ b/modules.d/99base/module-setup.sh @@ -89,18 +89,18 @@ install() { ## save host_devs which we need bring up ( + if dracut_module_included "systemd"; then + DRACUT_SYSTEMD=1 + fi + PREFIX="$initdir" + . "$moddir/dracut-lib.sh" + for _dev in ${host_devs[@]}; do _pdev=$(get_persistent_dev $_dev) case "$_pdev" in - /dev/?*) - if ! dracut_module_included "systemd"; then - PREFIX="$initdir" wait_for_dev $_pdev - else - DRACUT_SYSTEMD=1 PREFIX="$initdir" wait_for_dev $_pdev - fi - ;; + /dev/?*) wait_for_dev $_pdev;; *) ;; esac done diff --git a/modules.d/99base/wait-host-devs.sh b/modules.d/99base/wait-host-devs.sh deleted file mode 100644 index ce84922..0000000 --- a/modules.d/99base/wait-host-devs.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh - -type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh - -wait_host_devs() { - local _dev - - while read _dev; do - case "$_dev" in - /dev/?*) - wait_for_dev $_dev - ;; - *) ;; - esac - done < $1 -} - -[ -f /etc/host_devs ] && wait_host_devs /etc/host_devs diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh index 7727cd0..84f4b7d 100755 --- a/test/TEST-01-BASIC/test.sh +++ b/test/TEST-01-BASIC/test.sh @@ -86,7 +86,7 @@ test_setup() { ) sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \ -a "debug watchdog" \ - -d "piix ide-gd_mod ata_piix ext3 sd_mod i6300esbwdt" \ + -d "piix ide-gd_mod ata_piix ext3 sd_mod i6300esb ib700wdt" \ -f $TESTDIR/initramfs.testing $KVERSION || return 1 # -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm" diff --git a/test/TEST-03-USR-MOUNT/test.sh b/test/TEST-03-USR-MOUNT/test.sh index 680720b..ca7dc12 100755 --- a/test/TEST-03-USR-MOUNT/test.sh +++ b/test/TEST-03-USR-MOUNT/test.sh @@ -122,7 +122,7 @@ test_setup() { sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \ -a "debug watchdog" \ -o "network" \ - -d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esbwdt" \ + -d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \ -f $TESTDIR/initramfs.testing $KVERSION || return 1 rm -rf $TESTDIR/overlay diff --git a/test/TEST-40-NBD/test.sh b/test/TEST-40-NBD/test.sh index 88570af..208b784 100755 --- a/test/TEST-40-NBD/test.sh +++ b/test/TEST-40-NBD/test.sh @@ -356,7 +356,7 @@ test_setup() { sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \ -o "plymouth" \ -a "debug watchdog" \ - -d "af_packet piix ide-gd_mod ata_piix ext2 ext3 sd_mod e1000 i6300esbwdt" \ + -d "af_packet piix ide-gd_mod ata_piix ext2 ext3 sd_mod e1000 i6300esb ib700wdt" \ -f $TESTDIR/initramfs.testing $KVERSION || return 1 } diff --git a/test/TEST-50-MULTINIC/server-init.sh b/test/TEST-50-MULTINIC/server-init.sh index 144f83c..5a8359b 100755 --- a/test/TEST-50-MULTINIC/server-init.sh +++ b/test/TEST-50-MULTINIC/server-init.sh @@ -7,11 +7,53 @@ 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 +} + >/dev/watchdog ip addr add 127.0.0.1/8 dev lo -ip link set lo up +linkup lo ip addr add 192.168.50.1/24 dev eth0 -ip link set eth0 up +linkup eth0 >/dev/watchdog modprobe af_packet > /dev/watchdog @@ -42,10 +84,14 @@ exportfs -r chmod 777 /var/lib/dhcpd/dhcpd.leases >/dev/watchdog dhcpd -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases -echo -n 'V' > /dev/watchdog +#echo -n 'V' > /dev/watchdog #sh -i +#tcpdump -i eth0 # Wait forever for the VM to die echo "Serving NFS mounts" -while :; do sleep 30; done +while :; do + sleep 10 + >/dev/watchdog +done mount -n -o remount,ro / poweroff -f diff --git a/test/TEST-50-MULTINIC/test.sh b/test/TEST-50-MULTINIC/test.sh index a3aa679..5cb0971 100755 --- a/test/TEST-50-MULTINIC/test.sh +++ b/test/TEST-50-MULTINIC/test.sh @@ -8,7 +8,6 @@ KVERSION=${KVERSION-$(uname -r)} # Uncomment this to debug failures #DEBUGFAIL="rd.shell" #SERIAL="tcp:127.0.0.1:9999" -SERIAL="null" run_server() { # Start server first @@ -19,9 +18,9 @@ run_server() { -hda $TESTDIR/server.ext3 \ -m 512M -smp 2 \ -display none \ - -netdev socket,mcast=230.0.0.1:12320,id=net0 \ - -net nic,macaddr=52:54:01:12:34:56,model=e1000,netdev=net0 \ - -serial $SERIAL \ + -net socket,listen=127.0.0.1:12350 \ + -net nic,macaddr=52:54:01:12:34:56,model=e1000 \ + ${SERIAL+-serial $SERIAL} \ -watchdog i6300esb -watchdog-action poweroff \ -kernel /boot/vmlinuz-$KVERSION \ -append "loglevel=77 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \ @@ -53,15 +52,13 @@ client_test() { fi $testdir/run-qemu -hda $TESTDIR/client.img -m 512M -smp 2 -nographic \ - -netdev socket,mcast=230.0.0.1:12320,id=net0 \ - -net nic,netdev=net0,macaddr=52:54:00:12:34:$mac1,model=e1000 \ - -netdev socket,mcast=230.0.0.1:12320,id=net1 \ - -net nic,netdev=net1,macaddr=52:54:00:12:34:$mac2,model=e1000 \ - -netdev socket,mcast=230.0.0.1:12320,id=net2 \ - -net nic,netdev=net2,macaddr=52:54:00:12:34:$mac3,model=e1000 \ + -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 \ + -net nic,macaddr=52:54:00:12:34:$mac3,model=e1000 \ -watchdog i6300esb -watchdog-action poweroff \ -kernel /boot/vmlinuz-$KVERSION \ - -append "$cmdline $DEBUGFAIL rd.retry=5 rd.info ro rd.systemd.log_level=debug console=ttyS0,115200n81 selinux=0 rd.copystate rd.chroot init=/sbin/init" \ + -append "$cmdline $DEBUGFAIL rd.retry=5 rd.info ro console=ttyS0,115200n81 selinux=0 init=/sbin/init" \ -initrd $TESTDIR/initramfs.testing if [[ $? -ne 0 ]] || ! grep -m 1 -q OK $TESTDIR/client.img; then @@ -252,14 +249,14 @@ test_setup() { # Make server's dracut image $basedir/dracut.sh -l -i $TESTDIR/overlay / \ -m "dash udev-rules base rootfs-block 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 i6300esbwdt" \ + -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" \ -f $TESTDIR/initramfs.server $KVERSION || return 1 # Make client's dracut image $basedir/dracut.sh -l -i $TESTDIR/overlay / \ -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 i6300esbwdt" \ + -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" \ -f $TESTDIR/initramfs.testing $KVERSION || return 1 } diff --git a/test/TEST-99-RPM/test.sh b/test/TEST-99-RPM/test.sh index 66f0beb..f030cb0 100755 --- a/test/TEST-99-RPM/test.sh +++ b/test/TEST-99-RPM/test.sh @@ -50,6 +50,7 @@ find / -xdev -type f -not -path '/var/*' \ -not -path '/test.output' \ -not -path '/etc/nsswitch.conf.bak' \ -not -path '/etc/iscsi/initiatorname.iscsi' \ + -not -path '/boot/*0-rescue*' \ -not -path '/dev/null' \ -exec rpm -qf '{}' ';' | \ fgrep 'not owned' &> /test.output