#3407 PR open
: regenerate all initramfs on SLES¶
Labels: enhancement
saschalucas opened issue at 2025-02-25 05:47:¶
Relax-and-Recover (ReaR) Pull Request Template¶
Please fill in the following items before submitting a new pull request:
Pull Request Details:¶
-
Type: Bug Fix
-
Impact: Low
-
Reference to related issue (URL): #3263
-
How was this pull request tested? recover SLES12 and SLES15 with portable mode (systemrescue) and verified, that initramfs was regenerated.
-
Description of the changes in this pull request: In order to fix recovery in portable mode, where the running kernel does not match the version installed in the recovered chroot regenerate all initramfs images. This eliminates the need to parse present kernels from /boot.
fixes #3263
jsmeix commented at 2025-02-25 09:16:¶
@saschalucas
thank you for your enhancement to make ReaR also working
with OUTPUT=PORTABLE when the non-ReaR rescue system
does not have the same kernel and its matching
/lib/modules/kernel-version modules directory
as used on the original system so plain 'dracut'
uses the kernel version of the currently running
rescue system kernel and then dracut which runs
in 'chroot /mnt/local' cannot find a matching
(/mnt/local)/lib/modules/kernel-version directory.
I tested how 'dracut --regenerate-all' behaves
when there are several kernels with several
/lib/modules/kernel-version modules directories:
To test it on my SLES15-SP6 test VM
I copied in /boot/ the vmlinuz* kernel
and I copied recursively in /lib/modules/
the kernel-version modules directory
so I got
# ls -lhdtr /boot/vmlinuz*
-rw-r--r-- 1 root root 14M Jun 12 2024 /boot/vmlinuz-6.4.0-150600.21-default
lrwxrwxrwx 1 root root 31 Sep 2 15:32 /boot/vmlinuz -> vmlinuz-6.4.0-150600.21-default
-rw-r--r-- 1 root root 14M Feb 25 08:23 /boot/vmlinuz-6.4.0-150600.22-default
-rw-r--r-- 1 root root 14M Feb 25 08:23 /boot/vmlinuz-6.4.0-150600.23-default
-rw-r--r-- 1 root root 14M Feb 25 08:23 /boot/vmlinuz-6.4.0-150600.24-default
# ls -lhdtr /lib/modules/*
drwxr-xr-x 1 root root 466 Sep 2 15:34 /lib/modules/6.4.0-150600.21-default
drwxr-xr-x 1 root root 466 Feb 25 09:12 /lib/modules/6.4.0-150600.22-default
drwxr-xr-x 1 root root 466 Feb 25 09:12 /lib/modules/6.4.0-150600.23-default
drwxr-xr-x 1 root root 466 Feb 25 09:13 /lib/modules/6.4.0-150600.24-default
During "rear recover" dracut needed 4 times more time
to regenerate all 4 initrds.
With the additional '--parallel' dracut option in
usr/share/rear/finalize/SUSE_LINUX/i386/550_rebuild_initramfs.sh
if chroot $TARGET_FS_ROOT /bin/bash -c "PATH=/sbin:/usr/sbin:/usr/bin:/bin $dracut_binary --force --regenerate-all --parallel" ; then
on a test VM with quad core CPU
during "rear recover" dracut needs again (almost) the same time
to regenerate all 4 initrds as it needs to regenerate one initrd.
Needed time details:
For a single kernel without --regenerate-all on a single core CPU:
RESCUE localhost:~ # egrep ' initrd with /usr/bin/dracut| Executing: /usr/bin/dracut ' /var/log/rear/rear-localhost.log
++ LogPrint 'Recreating initrd with /usr/bin/dracut...'
2025-02-25 08:16:45.491168753 Recreating initrd with /usr/bin/dracut...
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.21-default --force
++ LogPrint 'Recreated initrd with /usr/bin/dracut'
2025-02-25 08:16:49.770112271 Recreated initrd with /usr/bin/dracut
Needed time: 49.770112271 - 45.491168753 = 4.278943518
For a single kernel with --regenerate-all on a single core CPU:
RESCUE localhost:~ # egrep ' initrd with /usr/bin/dracut| Executing: /usr/bin/dracut ' /var/log/rear/rear-localhost.log
++ LogPrint 'Recreating initrd with /usr/bin/dracut...'
2025-02-25 09:04:44.289959149 Recreating initrd with /usr/bin/dracut...
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.21-default --force
++ LogPrint 'Recreated initrd with /usr/bin/dracut'
2025-02-25 09:04:48.661493371 Recreated initrd with /usr/bin/dracut
Needed time: 48.661493371 - 44.289959149 = 4.371534222
For 4 kernels with --regenerate-all on a single core CPU:
RESCUE localhost:~ # egrep ' initrd with /usr/bin/dracut| Executing: /usr/bin/dracut ' /var/log/rear/rear-localhost.log
++ LogPrint 'Recreating initrd with /usr/bin/dracut...'
2025-02-25 09:20:35.415214452 Recreating initrd with /usr/bin/dracut...
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.21-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.22-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.23-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.24-default --force
++ LogPrint 'Recreated initrd with /usr/bin/dracut'
2025-02-25 09:20:51.497077129 Recreated initrd with /usr/bin/dracut
Needed time: 51.497077129 - 35.415214452 = 16.081862677
For 4 kernels with --regenerate-all plus --parallel on a single core CPU:
RESCUE localhost:~ # egrep ' initrd with /usr/bin/dracut| Executing: /usr/bin/dracut ' /var/log/rear/rear-localhost.log
++ LogPrint 'Recreating initrd with /usr/bin/dracut...'
2025-02-25 09:30:26.859244329 Recreating initrd with /usr/bin/dracut...
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.23-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.24-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.22-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.21-default --force
++ LogPrint 'Recreated initrd with /usr/bin/dracut'
2025-02-25 09:30:42.477938935 Recreated initrd with /usr/bin/dracut
Needed time: 42.477938935 - 26.859244329 = 15.618694606
For 4 kernels with --regenerate-all plus --parallel on a dual core CPU:
RESCUE localhost:~ # egrep ' initrd with /usr/bin/dracut| Executing: /usr/bin/dracut ' /var/log/rear/rear-localhost.log
++ LogPrint 'Recreating initrd with /usr/bin/dracut...'
2025-02-25 09:40:18.627934196 Recreating initrd with /usr/bin/dracut...
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.22-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.21-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.24-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.23-default --force
++ LogPrint 'Recreated initrd with /usr/bin/dracut'
2025-02-25 09:40:27.015404668 Recreated initrd with /usr/bin/dracut
Needed time: 27.015404668 - 18.627934196 = 8.387470472
For 4 kernels with --regenerate-all plus --parallel on a quad core CPU:
RESCUE localhost:~ # egrep ' initrd with /usr/bin/dracut| Executing: /usr/bin/dracut ' /var/log/rear/rear-localhost.log
++ LogPrint 'Recreating initrd with /usr/bin/dracut...'
2025-02-25 09:47:32.045019481 Recreating initrd with /usr/bin/dracut...
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.22-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.23-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.21-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.24-default --force
++ LogPrint 'Recreated initrd with /usr/bin/dracut'
2025-02-25 09:47:37.596896288 Recreated initrd with /usr/bin/dracut
Needed time: 37.596896288 - 32.045019481 = 5.551876807
jsmeix commented at 2025-02-25 09:18:¶
@saschalucas
could you also add the dracut option '--parallel'
and test how it behaves in your environment?
jsmeix commented at 2025-02-25 09:26:¶
The drawback of using the dracut option '--parallel' is
that then the dracut messages of the parallel running
dracut processes mix up in the dracut output
so one gets in the "rear -D recover" log file
++ LogPrint 'Recreating initrd with /usr/bin/dracut...'
2025-02-25 09:40:18.627934196 Recreating initrd with /usr/bin/dracut...
++ chroot /mnt/local /bin/bash -c 'PATH=/sbin:/usr/sbin:/usr/bin:/bin /usr/bin/dracut --force --regenerate-all --parallel'
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.22-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.21-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.24-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.23-default --force
dracut[I]: Module 'systemd-networkd' will not be installed, because command 'networkctl' could not be found!
dracut[I]: Module 'systemd-networkd' will not be installed, because command '/usr/lib/systemd/systemd-networkd' could not be found!
dracut[I]: Module 'systemd-networkd' will not be installed, because command 'networkctl' could not be found!
dracut[I]: Module 'systemd-networkd' will not be installed, because command 'networkctl' could not be found!
dracut[I]: Module 'systemd-networkd' will not be installed, because command '/usr/lib/systemd/systemd-networkd-wait-online' could not be found!
dracut[I]: Module 'systemd-networkd' will not be installed, because command '/usr/lib/systemd/systemd-networkd' could not be found!
dracut[I]: Module 'systemd-networkd' will not be installed, because command '/usr/lib/systemd/systemd-networkd' could not be found!
dracut[I]: Module 'systemd-networkd' will not be installed, because command '/usr/lib/systemd/systemd-networkd-wait-online' could not be found!
dracut[I]: Module 'systemd-pcrphase' will not be installed, because command '/usr/lib/systemd/systemd-pcrphase' could not be found!
dracut[I]: Module 'systemd-networkd' will not be installed, because command '/usr/lib/systemd/systemd-networkd-wait-online' could not be found!
dracut[I]: Module 'systemd-networkd' will not be installed, because command 'networkctl' could not be found!
dracut[I]: Module 'systemd-networkd' will not be installed, because command '/usr/lib/systemd/systemd-networkd' could not be found!
dracut[I]: Module 'systemd-pcrphase' will not be installed, because command '/usr/lib/systemd/systemd-pcrphase' could not be found!
dracut[I]: Module 'systemd-pcrphase' will not be installed, because command '/usr/lib/systemd/systemd-pcrphase' could not be found!
dracut[I]: Module 'systemd-networkd' will not be installed, because command '/usr/lib/systemd/systemd-networkd-wait-online' could not be found!
...
which makes it impossible to see which message
belongs to which kernel-version initrd recreating.
I think faster recreating by using the available CPUs
is more important than working around an issue in dracut
(at least in the dracut version in SLES15-SP6)
that dracut does not properly prefix its messages
when it runs several times in parallel.
jsmeix commented at 2025-02-25 09:40:¶
A side note FYI:
According to
https://discussion.fedoraproject.org/t/what-exactly-do-a-dracut-regenerate-all-force/78379
what exactly do a “dracut --regenerate-all --force” ?
I'm running the command out of curiosity and it seems
to be looking after every /lib/modules/*
it is the /lib/modules/kernel-version modules directories
which determine for what kernel versions '--regenerate-all'
will regenerate initramfs images.
In particular 'dracut --regenerate-all' regenerates
initramfs images for all /lib/modules/kernel-version
modules directories regardless if a matching
/boot/vmlinuz* kernel exists
(at least in the dracut version in SLES15-SP6).
I tested it.
I removed my /boot/vmlinuz-6.4.0-150600.23-default
but kept /lib/modules/6.4.0-150600.23-default
and got after "rear recover" (with dual core CPU)
RESCUE localhost:~ # egrep ' initrd with /usr/bin/dracut| Executing: /usr/bin/dracut ' /var/log/rear/rear-localhost.log
++ LogPrint 'Recreating initrd with /usr/bin/dracut...'
2025-02-25 10:48:52.095169992 Recreating initrd with /usr/bin/dracut...
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.22-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.21-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.23-default --force
dracut[I]: Executing: /usr/bin/dracut --kver=6.4.0-150600.24-default --force
++ LogPrint 'Recreated initrd with /usr/bin/dracut'
2025-02-25 10:49:01.040609638 Recreated initrd with /usr/bin/dracut
RESCUE localhost:~ # ls -l /mnt/local/boot/vmlinuz*
lrwxrwxrwx 1 root root 31 Sep 2 15:32 /mnt/local/boot/vmlinuz -> vmlinuz-6.4.0-150600.21-default
-rw-r--r-- 1 root root 14191584 Jun 12 2024 /mnt/local/boot/vmlinuz-6.4.0-150600.21-default
-rw-r--r-- 1 root root 14191584 Feb 25 08:23 /mnt/local/boot/vmlinuz-6.4.0-150600.22-default
-rw-r--r-- 1 root root 14191584 Feb 25 08:23 /mnt/local/boot/vmlinuz-6.4.0-150600.24-default
RESCUE localhost:~ # ls -l /mnt/local/boot/initrd*
lrwxrwxrwx 1 root root 30 Sep 2 15:32 /mnt/local/boot/initrd -> initrd-6.4.0-150600.21-default
-rw------- 1 root root 22067353 Feb 25 10:49 /mnt/local/boot/initrd-6.4.0-150600.21-default
-rw------- 1 root root 22067356 Feb 25 10:49 /mnt/local/boot/initrd-6.4.0-150600.22-default
-rw------- 1 root root 22067356 Feb 25 10:49 /mnt/local/boot/initrd-6.4.0-150600.23-default
-rw------- 1 root root 22067356 Feb 25 10:49 /mnt/local/boot/initrd-6.4.0-150600.24-default
[Export of Github issue for rear/rear.]