If you have installed Linux in a Generation 2 virtual machine – everything is probably working great for you! You can even export the virtual machine and import it somewhere else. However, things will not go well if you just shutdown the virtual machine and copy the virtual hard drive to a new location.
If you do this – and create a new virtual machine with the copied virtual hard drive – you will find that it does not boot.
Why does this happen?
Well, when Linux is installed in a Generation 2 virtual machine it stores key boot information in the UEFI firmware of the virtual machine. This is, in turn, stored in the virtual machine configuration file. If you separate the virtual hard drive and virtual machine configuration file – you can no longer boot.
Luckily – you can avoid this. Here are the steps that I had to take with an Ubuntu virtual machine to enable VHD copying:
- Log in to the virtual machine.
- Change directory to the boot EFI directory :
- Copy the ubuntu directory in to a new directory named boot :
sudo cp –r ubuntu/ boot
- Change directory to the newly created boot directory :
- Rename the shimx64.efi file :
sudo mv shimx64.efi bootx64.efi
What this does is move the boot information out of the UEFI firmware and onto the disk. With this done you can copy and boot the virtual hard drive with ease.