boot – Restore/copy GPT+EFI disk backups to new disk and make bootable
I’ve been going in circles. My situation is as follows:
- old disk died, it was a GPT disk booting EFI with 3 partitions, sda1=fat32 (flagged esp,boot and containing /boot and /EFI), sda2=etx4 (containing the rest, as well as the typical /boot), sda3=swap (linuxswap);
- I have backups (made using rsync -aAXH) of the contents of both sda1 and sda2
- I have a new disk and a bootable Ubuntu 20.04.3 USB stick
I want to restore the backups onto the new disk and make it bootable.
What I’ve tried (unsuccessfully):
- boot from the usb stick, gparted sda and made it GPT, then recreated the same 3 partitions, sda1=fat32 and flagged it esp,boot, sda2=ext4, sda3=swap
- restored all contents from old sda1 backup to new sda1, and from old sda2 to new sda2
- edited (sda2)/etc/fstab and updated the UUIDs with the new values from
lsblk
- edited (sda1)/EFI/ubuntu/grub.cfg and updated the UUID of the search.fs_uuid line
- installed grub-efi-amd64 and attempted
grub-install /dev/sda
The last line fails with:
Installing for x86_64-efi platform
grub-install: error: cannot find EFI directory
Obviously, ignoring that and rebooting does show the grub menu, but doesn’t actually boot once I choose an entry. I think the only step that’s missing is to update the UUIDs in (sda2)/boot/grub/grub.cfg since the ones there are still the old ones. This is normally done with update-grub if I’m not wrong (?).
Can someone please help with a list of steps and commands? What am I missing?
FULL DISCLOSURE: I’m attempting this first in a VMware virtual machine, whose .vmx was modified to use UEFI firmware (add firmware = "efi"
in the .vmx). This fully emulates a UEFI machine as far as I’m aware.
Read more here: Source link