~jefferyto/ubuntu/+source/initramfs-tools:ubuntu-core-dev-hibernate-fixes

Last commit made on 2024-06-06
Get this branch:
git clone -b ubuntu-core-dev-hibernate-fixes https://git.launchpad.net/~jefferyto/ubuntu/+source/initramfs-tools
Only Jeffery To can upload to this branch. If you are Jeffery To please log in for upload directions.

Branch merges

Branch information

Name:
ubuntu-core-dev-hibernate-fixes
Repository:
lp:~jefferyto/ubuntu/+source/initramfs-tools

Recent commits

ef83547... by Jeffery To

Fix hibernate for systemd v255

The resume device should always be written to the kernel, either (a) to
resume, if a suspend image is found, or (b) to enable suspend to that
device later.

More specifically, systemd v255 will not allow hibernate to start if the
resume device has not be set in the kernel.

This changes the resume local-premount script to always write the resume
device to /sys/power/resume so that hibernate can start.

Fixes: b3a78e4f8057 (" - resume: only resume when the partition contains a resume image - Fix resuming a hibernate session from a swapfile")
Fixes: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2057687
Signed-off-by: Jeffery To <email address hidden>

68dae92... by Jeffery To

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.

Fixes: https://bugs.launchpad.net/ubuntu/+source/initramfs-tools/+bug/1769297
Fixes: https://bugs.launchpad.net/ubuntu/+source/initramfs-tools/+bug/1853982
Fixes: https://bugs.launchpad.net/ubuntu/+source/initramfs-tools/+bug/1957194
Signed-off-by: Jeffery To <email address hidden>

326e5a7... by Benjamin Drung

Release initramfs-tools 0.142ubuntu28

Signed-off-by: Benjamin Drung <email address hidden>

0a8e905... by Benjamin Drung

auto_add_modules: group dracut-install calls for block modules

Group calls to `dracut-install` that use the same `-s` parameter.

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 ± σ): 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
```

This commit:

```
bdrung@zero2w:~$ sudo hyperfine --warmup 1 -r 10 "update-initramfs -u"
Benchmark 1: update-initramfs -u
  Time (mean ± σ): 226.658 s ± 5.861 s [User: 54.878 s, System: 160.566 s]
  Range (min … max): 220.091 s … 237.076 s 10 runs
```

bb20916... by Benjamin Drung

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.

3121df3... by Benjamin Drung

reduce number of dracut-install calls

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

LP: #2065180
Forwarded: https://salsa.debian.org/kernel-team/initramfs-tools/-/merge_requests/114
[1] https://salsa.debian.org/kernel-team/initramfs-tools/-/merge_requests/102

949a2ce... by Benjamin Drung

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.

c2dfc45... by Benjamin Drung

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

See also https://salsa.debian.org/kernel-team/initramfs-tools/-/merge_requests/108

4ef7091... by Benjamin Drung

Release initramfs-tools 0.142ubuntu27

Signed-off-by: Benjamin Drung <email address hidden>

1bcce09... by Benjamin Drung

init: fix setting hostname if busybox is not used

If busybox is not used, `/bin/hostname` will not be available in the
initrd.

Signed-off-by: Benjamin Drung <email address hidden>