Score:0

Grub / boot partition repair on dual-boot UEFI system

gf flag

In Ubuntu on a 64-bit dual-boot UEFI bios system with Windows 10 and Ubuntu installed, I recently made a mistake when trying to format a USB key in the disks tool.

I accidentally formatted Partition 1 on the hard disk to which Ubuntu is installed. I think that is the boot partition. When I boot to a live USB and view the disks I can still see the other partitions with my Windows and Ubuntu files - they seem to be intact.

I've tried to use Ubuntu boot repair tool here https://help.ubuntu.com/community/Boot-Repair

However during the process of using it the tool keeps warning me that I have booted using EFI not legacy from bios and that I should switch to legacy. At the end of the repair process I get a text summary which states that I should boot to legacy to get the Windows system available in the grub menu.

My bios does not have a legacy bios option.

Is there a way to repair grub and the boot partition on a system with UEFI bios?

cc flag
You might want to at least reformat the ESP (?) to something valid for an EFI partition, like fat. Ensure the partition still has the boot and efi flags. Then boot repair might recognize that you need an UEFI repair.
oldfred avatar
cn flag
No need to post link to Boot-Repair, post link to summary report from Boot-Repair. Boot-Repair cannot create partitions. So if you deleted the ESP - efi system partition, you have to recreate it with gparted. And update fstab with new UUID, as it mounts ESP. Then Boot-Repair can reinstall grub correctly. But you will also have to run Windows repairs to reinstall Windows UEFI boot files to ESP.
casperso avatar
gf flag
@ubfan1 Thank you. Could you please share how to distinguish which is the ESP? I guess it's the one I accidentally formatted is that right? I did use GPT to flag that with boot flag but not EFI flag. Will test the latter and revert.
casperso avatar
gf flag
@oldfred thanks for your message. Could you please share how to update fstab with the new UUID? I will post a link to the summary report from Boot-repair later tonight when I have the opportunity.
cc flag
The ESP is pretty small, from 100-500MB. Usually pretty obvious which partition from the size (after the flags and filesystem are gone). The ESP filesystem gets mounted at /boot/efi, so the /etc/fstab file should have a mount there, but using the former UUID, which was lost with the format (if that is the partition you formatted).
casperso avatar
gf flag
@ubfan1 thank you for your follow-up message. In the Ubuntu Live CD I went to Computer /etc/fstab and opened it with gedit. I only see 2 rows in it (overlay and tmpfs). Is that where you mentioned that the boot/efi mount details should be? Or perhaps this is the one for the Live CD O/S rather than the installed O/S and that's why it's not showing there?
cc flag
Right, you were looking at the live system's files. You'd have to mount the internal disk's root and the partition you think is the internal EFI, ususally done under live system's /mnt directory -- make dirs there like root and efi and mount there (/mnt/root, /mnt/efi etc.).
casperso avatar
gf flag
Thanks @ubfan1. When I tried to do this, boot repair seemed to run successfully in Ubuntu but then the system didn't boot, claiming no boot media present. When I relaunched into a Ubuntu live USB OS and view the partition which I had mounted to /mnt/efi, nothing is in the partition. Is it possible that boot repair is repairing the Live USB disk in a similar manner to what was happening when I first looked for /etc/fstab? Would I have to specify that I want to repair the startup files I have mounted at /mnt/efi rather than repairing the files that are used to start the live USB OS?
cc flag
I have zero experience with boot repair, but it's expected to work from a boot media. Your mounts would have to be re-done each time you boot the boot media, maybe you looked into the empty mount points, /mnt/efi etc.
I sit in a Tesla and translated this thread with Ai:

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.