Regenerating the initrd in SUSE Linux, including versions like SUSE 12.x / 15.x , can be necessary after making changes to the kernel or its modules. Here’s a step-by-step guide to doing this:
We may need to re-install the initrd files during the part of linux troubleshooting.
Steps to Regenerate initrd in SUSE 12.x and SUSE 15.x
Step |
Description |
Command/Action SUSE
12/15 |
1 |
goto single/emergency/chroot mode if VM is not booting |
|
2 |
Identify the current kernel version |
uname -r |
3 |
Backup existing initrd (optional) |
Backup initrd file with cp |
4 |
Regenerate the modules dependency file |
depmod or depmod -v |
5a |
Regenerate initrd for the current
kernel |
sudo mkinitrd or dracut |
5b |
Regenerate initrd for a specific
kernel |
mkinitrd -k /boot/vmlinuz-<kernel_version> -i /boot/initrd-<kernel_version> |
5c |
Regenerate initrd for a specific kernel | dracut -f /boot/initrd-<kernel_version> <kernel_version> Ex: dracut -force /boot/initrd-6.4.0-150600.21-default 6.4.0-150600.21-default |
6 |
Regenerate initrd for the current
kernel |
sudo grub2-mkconfig -o
/boot/grub2/grub.cfg |
7 |
Regenerate initrd for a specific
kernel |
sudo reboot |
Note : if mkinitrd is not working you can regenerate through the dracut commmand
If mkinitrd is not installed or recognized on your openSUSE Leap 15.6 system. You can use dracut instead to create or update the initrd image, as dracut is the default tool for this purpose on many modern SUSE systems.
OpenSUSE Leap 15.6 Process

suse15-1:/boot # ls -lrt initrd*
lrwxrwxrwx 1 root root 33 Nov 10 11:00 initrd -> initrd-6.4.0-150600.23.25-default
-rw------- 1 root root 24885387 Nov 10 11:03 initrd-6.4.0-150600.21-default
-rw------- 1 root root 24708696 Dec 15 18:53 initrd-6.4.0-150600.23.25-default
suse15-1:/boot # ls -lrt vmlinuz*
-rw-r--r-- 1 root root 14191584 Jun 12 2024 vmlinuz-6.4.0-150600.21-default
-rw-r--r-- 1 root root 14198912 Oct 2 05:24 vmlinuz-6.4.0-150600.23.25-default
lrwxrwxrwx 1 root root 34 Nov 10 11:00 vmlinuz -> vmlinuz-6.4.0-150600.23.25-default
suse15-1:/boot # uname -a
Linux suse15-1 6.4.0-150600.23.25-default #1 SMP PREEMPT_DYNAMIC Tue Oct 1 10:54:01 UTC 2024 (ea7c56d) x86_64 x86_64 x86_64 GNU/Linux
suse15-1:/boot # > initrd-6.4.0-150600.21-default
suse15-1:/boot # du -sh initrd-6.4.0-150600.21-default
0 initrd-6.4.0-150600.21-default
suse15-1:/boot # dracut --force /boot/initrd-$(uname -r) $(uname -r)
suse15-1:/boot # dracut -f /boot/initrd-<kernel_version> <kernel_version>
Replace <kernel_version> with the actual version of the kernel.
suse15-1:/boot # dracut --force /boot/initrd-6.4.0-150600.21-default 6.4.0-150600.21-default
dracut[I]: Executing: /usr/bin/dracut --force /boot/initrd-6.4.0-150600.21-default 6.4.0-150600.21-default
dracut[I]: Module 'systemd-coredump' will not be installed, because command 'coredumpctl' could not be found!
dracut[I]: Module 'systemd-coredump' will not be installed, because command '/usr/lib/systemd/systemd-coredump' 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-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-portabled' will not be installed, because command 'portablectl' could not be found!
dracut[I]: Module 'systemd-portabled' will not be installed, because command '/usr/lib/systemd/systemd
nullified the initrd of initrd-6.4.0-150600.21-default and regenerated
re-generate the grub and rebooted the VM and booted with old kerenel.
SUSE 15 re-generation with mkinitrd
suse15sp3:/boot # ls -lrt /boot/initrd*
lrwxrwxrwx 1 root root 35 Dec 14 15:26 /boot/initrd -> initrd-5.3.18-150300.59.185-default
-rw------- 1 root root 12603052 Dec 16 08:21 /boot/initrd-5.3.18-150300.59.185-default
suse15sp3:/boot # ls -lrt vmlinuz*
-rw-r--r-- 1 root root 10582272 Dec 10 09:48 vmlinuz-5.3.18-150300.59.185-default
lrwxrwxrwx 1 root root 36 Dec 14 15:26 vmlinuz -> vmlinuz-5.3.18-150300.59.185-default
suse15sp3:/boot # cat /etc/os-release
NAME="SLES"
VERSION="15-SP3"
suse15sp3:/boot # mkinitrd
Creating initrd: /boot/initrd-5.3.18-150300.59.185-default
dracut: Executing: /usr/bin/dracut --logfile /var/log/YaST2/mkinitrd.log --force /boot/initrd-5.3.18-150300.59.185-default 5.3.18-150300.59.185-default
dracut: dracut module 'btrfs' will not be installed, because command 'btrfs' could not be found!
dracut: dracut module 'dmraid' will not be installed, because command 'dmraid' could not be found!
dracut: dracut module 'dmsquash-live-ntfs' will not be installed, because command 'ntfs-3g' could not be found!
dracut: dracut module 'mdraid' will not be installed, because command 'mdadm' could not be found!
dracut: dracut module 'nvmf' will not be installed, because command 'nvme' could not be found!
dracut: dracut module 'biosdevname' will not be installed, because command 'biosdevname' could not
.........
................
dracut: root=UUID=c6434c64-345c-4975-b205-dd446215ed7e rootfstype=xfs rootflags=rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota
dracut: *** Creating image file '/boot/initrd-5.3.18-150300.59.185-default' ***
dracut: *** Creating initramfs image file '/boot/initrd-5.3.18-150300.59.185-default' done ***
suse15sp3:/boot #
Note: If you observe the mkinitrd command , its calling dracut only at backend which you can see.
So which means we can execute either dracut or mkinitrd in SUSE 12 or SUSE 15 Linux OS.
initrd re-generation with mkinitrd for specified kernel version
suse15sp3:/boot # mkinitrd -k /boot/vmlinuz-<kernel_version> -i /boot/initrd-<kernel_version>
suse15sp3:/boot # mkinitrd -k /boot/vmlinuz-5.3.18-150300.59.185-default -i /boot/initrd-5.3.18-150300.59.185-default
Creating initrd: /boot/initrd-5.3.18-150300.59.185-default
dracut: Executing: /usr/bin/dracut --logfile /var/log/YaST2/mkinitrd.log --force /boot/initrd-5.3.18-150300.59.185-default 5.3.18-150300.59.185-default
...............
..........................
dracut: *** Creating image file '/boot/initrd-5.3.18-150300.59.185-default' ***
dracut: *** Creating initramfs image file '/boot/initrd-5.3.18-150300.59.185-default' done ***
suse15sp3:/boot # ls -lrt initrd*
lrwxrwxrwx 1 root root 35 Dec 14 15:26 initrd -> initrd-5.3.18-150300.59.185-default
-rw------- 1 root root 12675196 Dec 16 11:38 initrd-5.3.18-150300.59.185-default
suse15sp3:/boot # date
Mon Dec 16 11:41:33 UTC 2024
suse15sp3:/boot #
Post a Comment