Rebuilding initramfs
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
- Boot the VM with the SystemRescue ISO
- 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
- Chroot into your system
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
chroot /mnt
- Rebuild
initramfs
with needed drivers
dracut -f -v
# Or specify kernel version:
dracut -f -v /boot/initramfs-$(uname -r).img $(uname -r)
- Exit and reboot
exit
reboot