How to modify a VM instance setting to boot from BIOS to UEFI?

I shrank my boot hard disk size on my Google Cloud Compute VM. Something which switched the boot method of the OS installed on it from legacy to UEFI along with the disk boot settings (which triggers UEFI setting must be the same for the instance and the boot disk. error).

How to change the Instance setting in order to match the UEFI setting of the instance given the OS boot method on the disk was migrated too?


Solution 1:

This is an old post, but I was able to resolve this issue. All I did was create the new smaller drive from the same public bootable image as the original drive. (in my case Ubuntu 18.04 LTS: ubuntu-1804-bionic-v20210504). Do this is instead of starting from a completely blank disk.

I had the opposite problem as OP, my drive was not UEFI compatible when it needed to be. Provisioning the new drive with a pre-installed OS made it share the old boot settings. I imagine this works the other way around as well. I then mounted the drive onto my VM and cloned my source boot drive to it using weresync with this command (adjust according to your system):

sudo weresync -C -L grub2 -E 15 -g 1 /dev/sda /dev/sdc

I then stopped the server, replaced the large boot drive with the smaller one, and it booted right up. I had to reconfigure my fstab to get my secondary drive to mount properly, but that's it.

Solution 2:

You may try to use the gcloud compute images create command with the --guest-os-features flag to create a new custom image from an existing custom image.

You can read more how to enable this feature here.

Try following these steps:

  • create an image with UEFI_COMPATIBLE flag enabled
  • detach existing disk from your VM
  • attach new disk to the VM
  • start the VM

Similar issue was also discussed here. You may also have a look at migrating to UEFI VM's documentation for additional insight.