CentOS 7 VMWare to Hyper-V Migration – Disk Not Visible Issue

centos7hyper-vwindows 10

I had a VM which was migrated from VMWare, I've confirmed that the disk is as expected by booting to a Live CD, mounting, and inspecting the file system.

The system does also boot to a certain extent, but after a while it gives up trying, dropping to a 'dracut' terminal, I've read through the logs in /run/initramfs/rdsosreport.txt and saw this:

Hyper-V Virtual Machine detected, ATA device ignore set

In the terminal I also saw an error saying that /dev/disk/by-uuid/{uuid here} was not available. While I was in Ubuntu, I did check the UUIDs listed in the error, /etc/fstab and everything matched up with the output from blkid.

I've also done a clean install of CentOS, which booted normally, so it is almost certainly something about the migrated install.

Sorry if this doesn't give enough to go on, if anyone needs any specific information, I'll do my best to update the question with it.

In case it helps, I'm running Windows 10, version 1903, build 10.0.18941.1001 (which is the version Hyper-V reports being).

Best Answer

I believe that 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. Please, follow these instructions:

  • Attach a CentOS 7 installation ISO to the virtual machine
  • Boot into Anaconda rescue mode (instructions) (alternative instructions)
  • Make sure the filesystem inside the virtual disk is mounted correctly on /mnt/sysimage
  • Use dracut to rebuild the initramfs: # chroot /mnt/sysimage dracut --no-hostonly --force --regenerate-all --verbose
  • Program a SELinux relabelling: # touch /mnt/sysimage/.autorelabel
  • Exit from Anaconda rescue mode

Initramfs is a filesystem image which 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. I do not know what modules are needed for a Hyper-V virtual machine; if you are able to find them by yourself, you may tell dracut to add them to the rebuilt initramfs by using the --add-drivers argument.