2

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?

Dave M
  • 4,494
  • 21
  • 30
  • 30
user2284570
  • 178
  • 12

2 Answers2

3

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.

Dave M
  • 4,494
  • 21
  • 30
  • 30
Teniralc
  • 46
  • 1
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:

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

Wojtek_B
  • 931
  • 3
  • 12
  • The problem is users are managed through the instance (I mean gcloud/web Interface). And I want to keep the data. [The link you posted](https://cloud.google.com/migrate/compute-engine/docs/4.9/how-to/prepare-vms-servers/migrating-to-uefi-based-vms) is only for non ɢᴄᴇ ᴠᴍs. The problem isn’t the disk which is already marked as ᴜᴇꜰɪ compatible but the instance itself. – user2284570 May 18 '20 at 16:02
  • Did you try to create an image and attach it to another VM ? – Wojtek_B May 19 '20 at 06:12
  • Also - if your VM won't boot you can try this guide: https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-instances – Wojtek_B May 19 '20 at 06:38
  • I put the existing boot disk of an instance not using ᴇꜰɪ to boot to a different smaller ᴜᴇꜰɪ disk and in the same way, I performed the necessary partition changes so it becomes compatible with ᴜᴇꜰɪ. But now, if I try to assign that new boot disk to the existing ᴠᴍ instance, I’m getting this error message : `ᴜᴇꜰɪ setting must be the same for the instance and the boot disk.` So it mean there’s an additional setting I need to change, but where ? – user2284570 May 19 '20 at 08:07
  • Are you trying to start the machine via console or gcloud utility ? Can you tell how exactly (with steps) you shrinked your boot disk ? – Wojtek_B May 19 '20 at 11:06
  • Simple, the only way to shrink a disk is to copy the old one on a smaller one on Google Cloud Computer. `ᴇꜰɪ setting must be the same for the instance and the boot disk.` is the message I’m getting while trying to assign the new boot disk to the instance. So before changing the boot disk in settings, I need to change that other setting first ! – user2284570 May 19 '20 at 11:57
  • You can easily resize your boot disk using gcloud compute disks resize example-disk --size 250. If you still have the original disk create an image and then the disk from it. Then resize the new one an try booting it. Here's more about resizing disks in GCP: https://stackoverflow.com/a/36348255/12257250 – Wojtek_B May 19 '20 at 12:04
  • `You can easily resize your boot disk using gcloud compute disks resize example-disk --size 250` This can be used for growing only… Not for shrinking which isn’t supported. – user2284570 May 19 '20 at 12:26
  • You're right - my bad. And when you do gcloud compute disks describe --zone=zone-disk-is-in disk-name what do you get ? It should say under guestOsFeatures: - type: UEFI_COMPATIBLE – Wojtek_B May 19 '20 at 12:44
  • The new disk is ᴜᴇꜰɪ but not the ᴠᴍ instance hence, the error message… so again the problem isn’t the disk. `ᴇꜰɪ setting must be the same for the instance and the boot disk.` is displayed because the new boot disk (or rather the attempt to assign it) is ᴜᴇꜰɪ compatible while the instance isn’t (setting mismatch). Which brings back to my question `How to change the Instance setting in order to match the (uefi) setting of the instance?`. **Please stop explain to me how to switch the disk setting because the problem is not with the disk but the ᴠᴍ**. – user2284570 May 19 '20 at 16:20
  • Did you try to create a new VM with --guest-os-features=UEFI_COMPATIBLE" setting ? If so it should work unless there's something wrong with the contents of the disk itself. – Wojtek_B May 20 '20 at 06:39
  • The problem is because users are managed on the ᴠᴍ and other reasons, I need to keep/modify the existing instance. – user2284570 May 20 '20 at 09:02
  • 1
    There is no way to modify VM instance this way after it's created. You have to try with the new one. – Wojtek_B May 20 '20 at 10:37