Score:1

Restore/copy GPT+EFI disk backups to new disk and make bootable

sd flag

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.

oldfred avatar
cn flag
Looks like you did things correctly. What exactly is error? But if saying i386, have you booted in BIOS mode? Please copy & paste the pastebin link to the Boot-info summary report ( do not post report), do not run the auto fix till reviewed.Lets see details, use ppa version with your USB installer (2nd option) or any working install, not Boot-Repair ISO (unless 21.10) https://help.ubuntu.com/community/Boot-Repair
sd flag
@oldfred just as you replied I had edited my question to specify I'm in a vmware VM, which I just realized was left in BIOS. I changed it to UEFI (added `firmware = "efi"` in .vmx) and then booted the Ubuntu .iso again. After installing grub-efi-amd64 and trying again `grub-install /dev/sda` then error is *Installing for x86_64-efi platform grub-install: error: cannot find EFI directory*
sd flag
@oldfred here's the bootinfo summary https://paste.ubuntu.com/p/vnXJt2pzGy/ ... many thanks for your prompt reply (it already nudged me forward reading that report)
oldfred avatar
cn flag
You are showing an ESP, but 16.04 is obsolete and you will not get repository to have updated software. Use 20.04 or other current version. https://wiki.ubuntu.com/Releases
sd flag
@oldfred sure 16.04 is dated (though still supported), but it's besides the point -- the question was about how to make the new disk bootable
Score:0
sd flag

Answering my own question, but I'm not accepting it as answer yet, because I'm still interested in a clear set of steps to fix it manually.

Using the pointers by @oldfred in a comment above, I used boot-repair which fixed it in one go.

I installed boot-repair after booting from a live CD, using the ppa (and not the ISO, which apparently is buggy), i.e.

sudo apt-add-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install boot-repair
sudo boot-repair

then chose to apply all default fixes, which worked in my case (note that I had backups and was in a VM so I could afford to be adventurous).

In the end it seems that it did was what I suspected: updated the UUIDs in grub.cfg, which would have been a bit of a pain to do manually, so I was indeed close.

Score:-1
bd flag

You need like:

pacstrap /mnt base linux linux-firmware
pacstrap /mnt grub-bios

when startup PC also configure bios to Bios in secure boot (not EFI or how there...)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.