resume: always write valid resume device to /sys/power/resume
Users report that hibernation does not work on Ubuntu 24.04 (noble). The
initrd only sets the major:minor in `/sys/power/resume` in case of
resuming from hibernation, but systemd v255 will not allow hibernate to
start if the resume device has not be set in the kernel.
`blkid -p -o value -s TYPE $device` reports `swap` for swap partitions
and for swap files on Ubuntu 24.04 (noble). The type for resume images
is `swsuspend`.
So also set the major:minor in `/sys/power/resume` when the swap type is
`swap`.
fsck: Mention file system name in failed identification warning
`update-initramfs` might be unable to identify the file system type of
the root file system:
```
$ update-initramfs -u
update-initramfs: Generating /boot/initrd.img-5.15.0-1059-kvm
W: Couldn't identify type of root file system for fsck hook
```
This error message can be confusing and misleading for the user. The
Ubuntu bug reported initially assumed it to be a bug in initramfs-tools
but later found out that the file system missed the label.
Mention the file system name in failed identification warning to help
the user finding the reason.
Fix resume failure due to resume=UUID=... in certain cases
If resume= has not been set on the kernel command line, and either:
* RESUME=UUID=... is set in /etc/initramfs-tools/conf.d/resume
* RESUME=auto is set in /etc/initramfs-tool/conf.d/resume and swap is a
traditional partition (not in LVM)
Then the resume variable will be set to a UUID, which causes the resume
local-premount script to fail as it expects the resume variable to be a
device path.
This moves the UUID handling further down, outside of the parse kernel
command line options loop, to catch these cases.
Use copy_modules_dir instead of dracut-install calls
dracut-install has some startup costs and reducing the number of
dracut-install will increase the execution time. So use
`copy_modules_dir` again for calls that do not use `-s`.
Benchmark results
=================
Benchmark on a Raspberry Pi Zero 2W on Ubuntu 24.04 (noble) on
2024-06-04. Previous commit:
```
bdrung@zero2w:~$ sudo hyperfine --warmup 1 -r 10 "update-initramfs -u"
Benchmark 1: update-initramfs -u
Time (mean ± σ): 236.326 s ± 6.033 s [User: 62.455 s, System: 165.245 s]
Range (min … max): 229.254 s … 244.094 s 10 runs
```
This commit:
```
bdrung@zero2w:~$ sudo hyperfine --warmup 1 -r 10 "update-initramfs -u"
Benchmark 1: update-initramfs -u
Time (mean ± σ): 228.483 s ± 5.953 s [User: 57.447 s, System: 162.737 s]
Range (min … max): 219.897 s … 240.041 s 10 runs
```
The expected difference (for two dracut-install calls less) is a few
seconds which fits within the margin of error. The changes of the range
is a good indicator.
dracut-install has a slow start-up time on ARM devices. Alper Nebi Yasak
wrote: "On my ARM64 Chromebooks dracut-install takes about 2-3 seconds
to start up even for a single module." [1]
Instead of `manual_add_modules` calling `dracut-install` directly,
collect the wanted kernel modules in a temporary file. Call
dracut-install at the end on all modules in one go.
Since the `vmxnet` hook from `open-vm-tools` and `bootcdinitramfshook`
from `bootcd` look at the copied kernel modules, call
`apply_add_modules` before calling the hooks to not break those hooks.
`hidden_dep_add_modules` looks at the installed kernel modules. So call
`apply_add_modules` before it. Since it is the last function that
installs kernel modules, let it call dracut-install directly.
This can be a breaking change. To restore the previous behavior, call
`apply_add_modules` without arguments after a `manual_add_modules` call.
Benchmark results
=================
Benchmark on a Raspberry Pi Zero 2W on Ubuntu 24.04 (noble) on
2024-06-03. initramfs-tools 0.142ubuntu25.1:
```
bdrung@zero2w:~$ sudo hyperfine --warmup 1 -r 10 "update-initramfs -u"
Benchmark 1: update-initramfs -u
Time (mean ± σ): 402.751 s ± 5.592 s [User: 166.316 s, System: 228.909 s]
Range (min … max): 394.380 s … 411.445 s 10 runs
```
This commit:
```
bdrung@zero2w:~$ sudo hyperfine --warmup 1 -r 10 "update-initramfs -u"
Benchmark 1: update-initramfs -u
Time (mean ± σ): 236.326 s ± 6.033 s [User: 62.455 s, System: 165.245 s]
Range (min … max): 229.254 s … 244.094 s 10 runs
```
mkinitramfs: Resolve hidden dependencies after all modules were copied
Move the `hidden_dep_add_modules` call after all kernel modules were
copied. Hooks might add or remove kernel modules that will infuence what
kernel modules `hidden_dep_add_modules` will add.
hook-functions: Use firmware search order from kernel
`add_firmware` should behave like the kernel searches for the firmware
files in `_request_firmware`. This functions calls
`fw_get_filesystem_firmware` (that iterates over the paths) for
uncompressed files, then `.zstd`, and then `.xz`.