Ali The Expert

Logo

How to Rebuild the “initramfs” with Multipath in CentOS/RHEL 6 and 7

The initramfs contains kernel modules for all hardware that is required to boot, as well as the initial scripts required to proceed to the next stage of booting. On CentOS/RHEL system, the initramfs contains a complete operational system (which may be used for troubleshooting purposes).
Occasionally, the initramfs image may get damaged as well. If this happens, you cannot boot your server into normal operational mode. To repair the initramfs image after booting into the rescue environment, you can use the dracut command. If used with no arguments, this command creates a new initramfs for the kernel currently loaded.

Alternatively, you can use the dracut command with several options to make an initramfs for specific kernel environments. There is also a configuration file with the name /etc/dracut.conf that you can use to include specific options while re-creating the initramfs.

Backup initramfs

Always make a backup of the current initramfs image in case there are issues with the new version created.
# cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.$(date +%m-%d-%H%M%S).bak

Rebuild initramfs with multipath

Rebuild the initramfs image with multipath, execute the dracut command with the following options:

CentOS/RHEL 6

# cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.$(date +%m-%d-%H%M%S).bak

CentOS/RHEL 7

# dracut –force –add multipath –include /etc/multipath

Verify

Verify the new initramfs image was created in /boot directory:
# ls -lrt /boot/initramfs-$(uname -r).img

Reboot

Reboot the system with the newly created initramfs image.
# reboot