Rebuilding initramfs

Rebuilding initramfs
Photo by Dmitriy / Unsplash

Admins migrating VMs between different hypervisors often forget to rebuild the initramfs, which leads to missing drivers required by the target environment—causing the VM to fail to boot.

Here's a quick summary of how to fix that:

We'll use SystemRescue (sysrescue) instead of a CentOS installation CD for rebuilding initramfs—and in many cases, it’s even better because:

  • ✅ It’s lightweight and fast to boot
  • ✅ Includes all common tools: chroot, dracut, lvm2, mdadm, etc.
  • ✅ Actively maintained and not tied to a specific distro

🛠️ Steps Using SystemRescue to Rebuild initramfs

  1. Boot the VM with the SystemRescue ISO
  2. Identify and mount your root filesystem
lvm vgchange -ay  # Activate LVM volumes, if needed
lsblk             # Identify root and boot partitions
mount /dev/mapper/centos-root /mnt
mount /dev/sda1 /mnt/boot      # if /boot is separate
  1. Chroot into your system
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
chroot /mnt
  1. Rebuild initramfs with needed drivers
dracut -f -v
# Or specify kernel version:
dracut -f -v /boot/initramfs-$(uname -r).img $(uname -r)
  1. Exit and reboot
exit
reboot