You are not logged in.

#1 2017-11-22 12:06:05

dvw10984
Member
Registered: 2013-02-16
Posts: 28

UEFI: grub lost after disk removal

I'm using a UEFI system, with GRUB.

I find that I can reliably reproduce the following steps:

1. Install Arch Linux with GRUB, UEFI, reboot and verify it works
2. Power off the machine
3. Remove the disk
4. Boot up the machine, and expect no OS could be found
5. Power off the machine
6. Put the disk back
7. Boot up the machine, and now GRUB is lost (not in the UEFI entries)

I'd like to know how this happened.
Are the UEFI entries stored somewhere in the motherboard,
and when it is detected that a entry is no longer valid, the motherboard removes it?

Thank you.

Offline

#2 2017-11-22 12:28:57

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,668

Re: UEFI: grub lost after disk removal

dvw10984 wrote:

Are the UEFI entries stored somewhere in the motherboard,
and when it is detected that a entry is no longer valid, the motherboard removes it?

Yes they are, you will want to read up on NVRAM. And that is likely what is happening, how this is implemented is of course motherboard specific and it looks like removing the entries upon not seeing the disc is what your UEFI firmware does.

Offline

#3 2017-11-23 02:43:52

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: UEFI: grub lost after disk removal

Note that you have not really lost grub. You've lost the firmware entry for grub. Grub is still there, just where it was before.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#4 2017-11-23 07:18:55

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: UEFI: grub lost after disk removal

Grub's .efi loader can be copied to the EFI system partition at /EFI/BOOT/BOOTX64.EFI, this should be booted automatically even in the absence of any NVRAM entries and so will allow you to remove and replace the drive without having to create a new NVRAM entry.

See also http://www.rodsbooks.com/efi-bootloader … ive-naming

Offline

#5 2017-11-24 05:47:35

dvw10984
Member
Registered: 2013-02-16
Posts: 28

Re: UEFI: grub lost after disk removal

Thanks all, now it makes sense!

Just learned something new about NVRAM.

/EFI/BOOT/BOOTX64.EFI seems also to be used by archiso

Offline

#6 2017-11-24 17:21:12

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: UEFI: grub lost after disk removal

Head_on_a_Stick wrote:

Grub's .efi loader can be copied to the EFI system partition at /EFI/BOOT/BOOTX64.EFI, this should be booted automatically even in the absence of any NVRAM entries and so will allow you to remove and replace the drive without having to create a new NVRAM entry.

As I understand it, this is permitted by the spec, but not required. While it usually works, therefore, it can't be guaranteed.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#7 2017-11-24 21:25:01

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: UEFI: grub lost after disk removal

cfr wrote:

While it usually works, therefore, it can't be guaranteed.

The Arch ISO image boots with the same method (albeit via PreLoader.efi) so it will probably work  wink

Offline

#8 2017-11-25 02:05:17

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: UEFI: grub lost after disk removal

Head_on_a_Stick wrote:
cfr wrote:

While it usually works, therefore, it can't be guaranteed.

The Arch ISO image boots with the same method (albeit via PreLoader.efi) so it will probably work  wink

I agree it will probably work. But removable devices are treated differently and I think this *is* part of the spec in this case, though I'm not certain. See the refind web pages for details.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB