I ran into some troubles doing do-release-upgrade and it killed my grub boot.
Because I couldn't find the steps on how to fix this online I'll answer with my own notes below.
I ran into some troubles doing do-release-upgrade and it killed my grub boot.
Because I couldn't find the steps on how to fix this online I'll answer with my own notes below.
First install the vm-repair extension for Azure. If you are using a different cloud provider you need to do these steps manually (attach the OS disk to a secondary VM).
az extension add -n vm-repair
Then create a repair VM that will mount the 'damaged' OS disk as a data disk (make sure the VM is stopped):
az vm repair create -g MyResourceGroup -n myVM \
--repair-username USERNAME --repair-password PASSWORD \
--verbose --associate-public-ip --distro ubuntu20
myVM is the name of the VM you wish to repair. The distro does not have to match exactly if it supports the same grub version.
Once the repair VM has been created look up its public IP (or connect via the serial console).
ssh -o 'UserKnownHostsFile /dev/null' USERNAME@PUBLIC-IP
Once connected:
sudo -s
mkdir /p2
# mount the disk to repair, see `lsblk`
# (on Azure this is usually sdc1)
mount /dev/sdc1 /p2
# now mount the efi to boot
mount /dev/sdc15 /p2/boot/efi
# prep for chroot
for i in /dev /dev/pts /proc /sys /run; do mount -B $i /p2$i; done
# chroot into the mounted disk
chroot /p2
# install grub
grub-install /dev/sdc --boot-directory=/boot
When you are done
az vm repair restore -g MyResourceGroup -n MyVM --verbose
The original VM should now be able to boot again.