fix(dracut.sh): --sysroot option broken if global variables not set in conf
When `$dracutsysrootdir` is set and references an existing directory, the
internal global variables are never set, unless their value is assigned via
configuration file.
But this patch also includes a refactoring, removing duplicate code using the
same `set_global_var` function to set and export global variables, and improving
readability.
fix(lsinitrd.sh): handle filenames with special characters
Printing and unpacking of specific files passed as arguments does not work if
their filenames contain special characters with a hexadecimal character escape
(\x), which is often the case for systemd device units.
feat(lvm): always include all drivers that LVM can use
This patch adds all the kernel modules that might be needed by LVM, to avoid
having to rebuild the initrd in hostonly mode after a dynamic change that
requires new drivers to boot.
For example, LVM allows to dynamically convert a linear logical volume to a
RAID-1 type (`lvconvert --type raid1 vg/lv`), which, in hostonly mode, will
require the user to manually rebuild the initrd again to include the new RAID
drivers in use, otherwise the system will fail to boot.
LinkTed [Fri, 23 Dec 2022 19:16:31 +0000 (20:16 +0100)]
fix(crypt-gpg): do not use always --card-status
If no GPG smart card is used then the card-status breaks the decryption
of the keyfile. Therefore, use the card-status only if a smart card is
used to decrypt the keyfie.
- Remove the reference to Harald's git ci alias
- Added a missing push to master
- Added a warning not to add the Rendered View entry from the NEWS.md to
the tags. ( Github adds that to the release with no way of removing it, see 058 )
- Added validation of the new tag ( Good practice )
- Clarify milestone handover.
Without this service, timedatectl fails to run in the initrd.
```
sh-5.2# timedatectl
Failed to query server: Could not activate remote peer: activation request failed: unknown unit.
sh-5.2# systemctl status dbus | grep timedate
Dec 22 13:57:03 sd-net-test dbus-broker-launch[219]: Activation request for 'org.freedesktop.timedate1' failed: The systemd unit 'dbus-org.freedesktop.timedate1.service' could not be found.
```
Without this service, hostnamectl fails to run in the initrd.
```
sh-5.2# hostnamectl
Failed to query system properties: Could not activate remote peer: activation request failed: unknown unit.
sh-5.2# systemctl status dbus | grep hostname
Dec 22 11:07:56 sd-net-test dbus-broker-launch[216]: Activation request for 'org.freedesktop.hostname1' failed: The systemd unit 'dbus-org.freedesktop.hostname1.service' could not be found.
```
Also, remove duplicate code by creating a function to get the zipl boot device,
prepend $dracutsysrootdir to /etc/fstab and print cmdline properly: start
with a space and do not print a newline.
fix(dracut): allow to set persistent policy based on /dev/mapper device names
Currently, dracut only allows to configure the persistent policy to address
disks and partitions using any directory name found in /dev/disk, but there is
no defined way to set the default policy based on /dev/mapper device names. So,
for example, if the persistent policy is set by the distribution in any
configuration file, the user cannot set the default if he wants to.
The current workaround is to set persistent_policy="" in a conf file or pass
--persistent-policy " " (white space) as an argument. This patch aims to
establish a specific value for this case.
Kairui Song [Tue, 6 Dec 2022 16:06:34 +0000 (00:06 +0800)]
fix(iscsi): don't install the module if kernel doesn't support iscsi
The cmdline hook of iscsi module will force check if iscsi_tcp module
is available, and abort the boot progress is not. But actually iscsi
module shouldn't be allowed to be installed in the first place if the
corresponding kernel doesn't support it.
So print an warning and refuse to install the iscsi dracut module
in such case, instead of dying on reboot.
Kairui Song [Tue, 6 Dec 2022 09:24:47 +0000 (17:24 +0800)]
feat(dracut-init.sh): introduce a new helper require_kernel_modules
Some dracut modules won't work without certain kernel modules,
this helper will be helpful for checking such kernel configs in
check() and error out early.
Kairui Song [Tue, 6 Dec 2022 09:20:26 +0000 (17:20 +0800)]
fix(dracut-functions.sh): check_kernel_module should follow dracutsysrootdir
check_kernel_module calls modprobe and tries to dry-run a module load to
check if a module is available. modprobe supports `-d` to specify a
rootdir, so just pass dracutsysrootdir to it to make it work as expected
when building initramfs for another rootfs.
Laszlo Gombos [Wed, 7 Dec 2022 20:04:27 +0000 (20:04 +0000)]
ci: reduce the timeout for local tests to 30 min
The main motivation here is to do not allow each test to grow beyond
30 min. If a longer test is needed for some reason, it should be
split into two tests.
Currently each local test is passing at 20 min.
The longest running local test is test 12: encrypted LVM PV
on a degraded RAID-5.
Laszlo Gombos [Tue, 25 Oct 2022 17:54:34 +0000 (17:54 +0000)]
refactor(dmsquash-live): move ntfs-3g code to dmsquash-live-ntfs
Since the installation of ntfs-3g binary is in the
dmsquash-live-ntfs module, calling ntfs-3g from dmsquash-live fails
when dmsquash-live-ntfs module is not installed anyways.
The directory where to look for kernel modules can be set via the -k/--kmoddir
command line option or the drivers_dir configuration option. Its current check
should be split into two different ones to avoid misleading error messages (see
referenced issue):
- First check that its basename matches the kernel version set for the initramfs
(via --kver or automatically set by "uname -r").
- Second check that the parent directory of the last provided directory contains
"/lib/modules/". This check was also fixed to avoid accepting other directories
like "xxxlib/modules".
Laszlo Gombos [Sun, 11 Dec 2022 15:33:00 +0000 (15:33 +0000)]
test: do not omit dash module
It should not be necessary to explicitly omit dash module.
If this is needed, that would mean that bash is not marked
as an explicit dependency for some modules.
fix(dracut): shellcheck regression in DRACUT_INSTALL calls
If the DRACUT_INSTALL environment variable contains arguments (e.g.:
DRACUT_INSTALL="/usr/lib/dracut/dracut-install --debug"), its call cannot
be enclosed in double quotes. E.g.:
```
> export DRACUT_INSTALL="/usr/lib/dracut/dracut-install"
> "$DRACUT_INSTALL" > /dev/null
dracut-install: No SOURCE argument given
> export DRACUT_INSTALL="/usr/lib/dracut/dracut-install --debug"
> "$DRACUT_INSTALL" > /dev/null
-bash: /usr/lib/dracut/dracut-install --debug: No such file or directory
> $DRACUT_INSTALL > /dev/null
dracut-install: No SOURCE argument given
Laszlo Gombos [Sun, 11 Dec 2022 15:03:48 +0000 (15:03 +0000)]
ci: introduce more networking options into test containers
Add systemd-networked to Fedora container.
Add connman to Arch container.
This change enables manual testing of various network configurations
and also allows the ci to ensure that having additional networking
packages installed does not break the network meta module.
fix(90kernel-modules): MMC and NVMe on kernels 6.0+
Commit 6f8191fdf41 ("block: simplify disk shutdown") in Linux kernels 6.0 and above
renamed blk_cleanup_disk to blk_mq_destroy_queue. Adapt code to handle both cases.
Because of this the kernel module mmc_block.ko was not included into initrd on kernel 6.1:
dracut-install: No symbol or path match for '/lib/modules/6.1.0-generic-0.rc7.1rosa2021.1-x86_64//kernel/drivers/mmc/core/mmc_block.ko.zst
while on kernel 5.15 it was included:
dracut-install: Handling /lib/modules/5.15.79-generic-1rosa2021.1-x86_64//kernel/drivers/mmc/core/mmc_block.ko.zst
dracut-install: Module mmc_block: symbol blk_cleanup_queue matched inclusion filter
It made booting OS from root on /dev/mmcblk* impossible.
Just adding blk_mq_destroy_queue was not enough to make mmc_block.ko be included into initrd
(maybe because call of blk_cleanup_disk() was removed and call of blk_mq_destroy_queue() was not added).
So also adding blk_mq_alloc_request which is used from mmc_block.
Laszlo Gombos [Fri, 25 Nov 2022 03:04:26 +0000 (03:04 +0000)]
test: do not omit dracut networking modules
The main motivation of this change is to prepare to enable
testing all four networking dracut modules not just two.
There are four networking modules supported currently.
Omitting one networking module not only is not necessary but
confusing as if the test really wants to omit networking modules,
it should omit all three non-used dracut networking modules.
Laszlo Gombos [Sun, 27 Nov 2022 04:08:58 +0000 (04:08 +0000)]
ci: remove native dracut installation from the test containers
The installed packaged dracut version from a distributions can
interfere with testing latest dracut from source, which is the
primary goal of these containers.
The base module requires grep with the `rd.memdebug=1` command line parameter.
As this code is broken if grep is not added by other means and grep is only
required for this, rewriting this code to avoid the dependency.
fix(dracut-systemd): run systemctl daemon-reload after remove_hostonly_files
Dependencies to systemd .device unit files are marked as "hostonly" in the
special file hostonly-files. These .device unit files can be removed using the
`rd.hostonly=0` command line parameter. But, since systemd v252
(https://github.com/systemd/systemd/pull/24054), the initrd-parse-etc.service
service does not run `systemctl daemon-reload`, so systemd keeps waiting
for these .device units to show up.
This means that if a hostonly device is not available for any reason at boot
time, using `rd.hostonly=0` has no effect and the system will not boot.