“Could Not Boot” Error After Converting a Linux VMware to Hyper-V – CloudShell - The Legend of Hanuman

“Could Not Boot” Error After Converting a Linux VMware to Hyper-V – CloudShell


In my previous post, I was talking about converting vmware vms to Hyper-V. The Windows machines worked fine because it’s all Microsoft products, the vm knows how to fix the driver issues. However, when you try to convert a Linux vm, you have to re-install the drivers of the new hypervisor, let’s understand a bit more in this post what happens with the linux vms after converting them.


Table of Contents

1 – The Error

When you start the vm, the following error has been thrown:

boot error the problem cloudshell
Figure 1 : The Error

This issue was caused by the incorrect drivers in the virtual machine that was using the vmware drivers and it is now running on top of a hyper-v server, that is, it’s missing the hyper-v drivers on this instance.

dracut creates an initial image used by the kernel for preloading the block device modules (such as IDE, SCSI or RAID) which are needed to access the root filesystem, mounting the root filesystem and booting into the real system.

At boot time, the kernel unpacks that archive into RAM disk, mounts and uses it as initial root file system. All finding of the root device happens in this early userspace.

Initramfs images are also called “initrd“.

1.2 – What is Initramfs?

Initramfs is a filesystem image that the bootloader will extract to memory after loading the kernel and before switching execution context to it. Such image is expected to contain all modules the kernel will need to find the block device containing the root filesystem.

When you see this screen, the initramfs file is corrupted because it’s not possible to find the root filesystem, but luckily we can fix that, let’s see how in the next section.


2 – Fixing the Issue

Tested using CentOS;

You will need to reconstruct the initramfs file /boot/initramfs-(kernel version).img, because of the virtual hardware change. The module used by CentOS kernel for virtual disk access is probably different.

To fix the issue, we have some steps to go through:

2.1 – Attach a CentOS installation ISO to the virtual machine

You can download the CentOS image using the official page here. You can either use the complete ISO or the minimal one. After that, go to your vm and attach the disk to it:

boot error cdcentos cloudshell
Figure 2: CentOS 8 Disk

2.2 – Boot into Anaconda rescue mode:

Start the disk on your machine and select the “Troubleshooting” option:

boot error troubleshooting cloudshell
Figure 3 : Troubleshooting

Select “Rescue a CentOS Linux system“:

boot error rescue cloudshell
Figure 4: Rescue Option

Select ‘1‘ to mount your Linux installation under /mnt/sysimage  :

boot error mount cloudshell
Figure 5: Mount the Linux Installation

Run :

To make the root of your installation, the root of this system:

boot error chroot cloudshell
Figure 6: Changing root directory to the supplied directory

2.3 – Make sure the filesystem inside the virtual disk is mounted correctly on /mnt/sysimage:

To do this, simply run ‘lsblk‘ :

boot error lsblk cloudshell
Figure 7 : Finding the FileSystem

Use dracut to rebuild the initramfs:

chroot /mnt/sysimage dracut --no-hostonly --force --regenerate-all --verbose

If everything goes well, you will receive the following output:

boot error image done cloudshell
Figure 8: Rebuilding the Initramfs
2.4 – Program an SELinux relabelling

This usually occurs when labelling a file system for SELinux for the first time, or when switching between different types of policy, such as changing from the targeted to the strict policy. You can find more about SELinux policies here.

touch /mnt/sysimage/.autorelabel

Next time when you will reboot the system, it will relabel the filesystem for SElinux automatically.

To exit from Anaconda rescue mode, simply type ‘exit‘. The vm will reboot. shut it down and change the boot order to your hard drive instead of the linux ISO.

3 – Booting the Virtual Machine

When you start up the VM, you’ll see the following output in the first boot:

boot error selinux relabel cloudshell
Figure 9 : Relabeling the SELinux

After that, you’ll be able to use the vm again:

boot error vm running cloudshell 1
Figure 10 : VM Running

In this post, you’ve learned how to fix the initramfs corrupted error. I hope you liked it, and I’ll see you in the next post. Don’t forget to leave us a comment below if this information was helpful.


Share this content:

I am a passionate blogger with extensive experience in web design. As a seasoned YouTube SEO expert, I have helped numerous creators optimize their content for maximum visibility.

Leave a Comment