|
|
Log in / Subscribe / Register

Also on Debian based systems

Also on Debian based systems

Posted Jul 30, 2020 17:34 UTC (Thu) by zlynx (guest, #2285)
In reply to: Also on Debian based systems by Smon
Parent article: Grub2 updates for Red Hat systems are making some unbootable

For anyone reading that, never do that grub install command on a UEFI boot system. It will ruin it forever in hard to fix ways.


to post comments

Also on Debian based systems

Posted Jul 30, 2020 20:02 UTC (Thu) by leromarinvit (subscriber, #56850) [Link] (6 responses)

Interesting. Both the Debian wiki and the Arch wiki suggest using exactly this command. What does it break, and what should be used instead to (re-)install GRUB on UEFI systems?

Also on Debian based systems

Posted Jul 30, 2020 21:43 UTC (Thu) by hmh (subscriber, #3838) [Link] (5 responses)

The correct command on Debian/Ubuntu, for EFI systems, is just "grub-install", and let it auto-detect what it should do. Unless you unmounted /boot/efi and removed its definition in /etc/fstab, in which case you're on your own. Do yourself a favor and ensure /boot and boot/efi are mounted read-write first. Feel free to change them back to a much safer read-only afterwards, though.

I have no idea where that /dev/sda in the wiki came from. It is never right for an EFI install, hopefully grub-install will ignore it, because if it doesn't, well, the result won't be pretty.

Heck, you don't tell anyone to grub-install /dev/sda *even* for grub-pc (the "PC BIOS" edition), you say something like /dev/<boot device>...

Also on Debian based systems

Posted Jul 30, 2020 21:46 UTC (Thu) by hmh (subscriber, #3838) [Link]

Fixed the Debian wiki page.

Also on Debian based systems

Posted Jul 30, 2020 22:56 UTC (Thu) by leromarinvit (subscriber, #56850) [Link] (3 responses)

> The correct command on Debian/Ubuntu, for EFI systems, is just "grub-install", and let it auto-detect what it should do.

Good to know, thanks.

> I have no idea where that /dev/sda in the wiki came from. It is never right for an EFI install, hopefully grub-install will ignore it, because if it doesn't, well, the result won't be pretty.

What would it do? Treat the GPT partition table as MBR and corrupt it? While definitely not pretty, that should be recoverable as GPT has a backup table hopefully not located in the first few sectors.

> Heck, you don't tell anyone to grub-install /dev/sda *even* for grub-pc (the "PC BIOS" edition), you say something like /dev/<boot device>...

That's definitely a useful clarification. While it's probably obvious to the average LWN reader that a bootloader needs to be installed on whatever drive the system wants to boot from, people blindly following instructions might run into trouble here.

Also on Debian based systems

Posted Jul 31, 2020 20:58 UTC (Fri) by kreijack (guest, #43513) [Link] (2 responses)

> > I have no idea where that /dev/sda in the wiki came from. It is never right for an EFI install, hopefully grub-install will ignore it, because if it doesn't, well, the result won't be pretty.

> What would it do? Treat the GPT partition table as MBR and corrupt it? While definitely not pretty, that should be recoverable as GPT has a backup table hopefully not located in the first few sectors.

Apart the fact that boot device could not be /dev/sda, the GPT table would be not affected. In fact both GPT and MBR partition can co-exist together (and say the same thing or different thing ! more often the latter).

I think that the real risk is that some bios doesn't start in UEFI mode if a MBR partition table is available. My BIOS (which is quite old) didn't show any UEFI related option until I removed all MBR partition table.

Also on Debian based systems

Posted Jul 31, 2020 21:23 UTC (Fri) by anselm (subscriber, #2796) [Link] (1 responses)

In fact both GPT and MBR partition can co-exist together (and say the same thing or different thing ! more often the latter).

Theoretically, GPT-partitioned disks have a fake MBR with one huge untouchable “partition” that covers all the space within the GPT partitions. (This only gets you so far if your disk is bigger than MBR will support.)

Also on Debian based systems

Posted Aug 2, 2020 6:05 UTC (Sun) by kreijack (guest, #43513) [Link]

> Theoretically, GPT-partitioned disks have a fake MBR with one huge untouchable “partition” that covers all the space within the GPT
> partitions. (This only gets you so far if your disk is bigger than MBR will support.)

Correct.

To complete the answer, I have to point out that below of the "MBR" label there are two kind if information:
- the partition table
- the boot loader

Both are stored in the first sector. Grub-install change only the latter. So in any case grub-installer can't change nor damage the GPT table. However installing a MBR boot loader, could start the bios in legacy mode (and not uefi one).

Also on Debian based systems

Posted Jul 30, 2020 21:28 UTC (Thu) by cjwatson (subscriber, #7322) [Link] (3 responses)

No it won't - on UEFI, grub-install (for better or worse, but in this case better) just ignores any device name you give it and installs to the EFI System Partition anyway.

Also on Debian based systems

Posted Jul 30, 2020 21:53 UTC (Thu) by zlynx (guest, #2285) [Link]

Well that's good.

As I remember things it did not always do that check for UEFI. Or perhaps it was someone booting an OS that didn't understand UEFI and it did it.

That kind of thing is what leads people to get upset with Windows because it will repeatedly repair the corrupted boot records. Which is not Windows' fault when it is the Linux users doing it wrong.

Also on Debian based systems

Posted Jul 31, 2020 8:55 UTC (Fri) by Wol (subscriber, #4433) [Link] (1 responses)

Well, I don't understand UEFI and all that stuff, but ...

When I tried to install SUSE on this laptop, it quite happily installed - UEFI - pointing to the UEFI partition it created on sdb. Of course, the laptop boots Windows off sda, so SUSE-install (presumably grub) put it in the wrong place and the laptop doesn't even realise SUSE is there :-(

Cheers,
Wol

Also on Debian based systems

Posted Aug 1, 2020 5:36 UTC (Sat) by gfernandes (subscriber, #119910) [Link]

I did that at first, the first time I installed to a UEFI laptop. And ended up using the UEFI boot menu to switch.

I later realised that all OSs should _add_ to the same UEFI partition, that should already be there if you got an off the shelf laptop with WhineDoze preinstalled.

So I now first increase the size of the UEFI partition, and then install Fedora on another disk with /boot/efi pointing to the same UEFI partition. And since then, dual boot works fine and can be driven from the grub menu.

Also on Debian based systems

Posted Jul 30, 2020 23:19 UTC (Thu) by dmoulding (subscriber, #95171) [Link] (3 responses)

This is giving me a mental segfault.

There should be nothing wrong with doing "grub-install /dev/sda", assuming /dev/sda is the disk that contains the ESP. And, in fact, if you're running grub-install from a rescue system (which is UEFI) against another UEFI system's disk (such that the system currently has *two* disks attached to it, each one containing an ESP), then specifying the disk should be *mandatory* because otherwise grub-install has to choose which of the two it should install to, and it's almost certainly not going to guess that correctly every time. I would think the same would apply if you've got a rescue USB stick plugged into the system, which also contains an ESP.

Also on Debian based systems

Posted Jul 31, 2020 2:20 UTC (Fri) by nivedita76 (guest, #121790) [Link] (2 responses)

grub-install takes an --efi-directory argument to specify where the ESP has been mounted.

Also on Debian based systems

Posted Jul 31, 2020 3:16 UTC (Fri) by dmoulding (subscriber, #95171) [Link] (1 responses)

Oh, for sure. But if you tell it which disk you want to install it to, it can easily find the ESP on that disk (by looking for the one with the ESP type UUID) and mount it itself. Then you don't need to bother mounting it in advance, nor telling it where you've mounted it.

I suppose it's still got to know which file system has the contents of /boot so that it knows where to put its modules, and the other things it wants to put in /boot/grub. That's a little harder since there isn't a designated type UUID for the partition containing /boot (and it could be on an LVM volume or something else that's not a GPT partition). So you might have to in some cases give it the --boot-directory option, as well (or mount the desired file system at /boot in advance).

Nevertheless, I still don't see how specifying a disk (as long as it's not wrong), could be more harmful than not specifying a disk.

Also on Debian based systems

Posted Jul 31, 2020 15:38 UTC (Fri) by nivedita76 (guest, #121790) [Link]

Right, I was just explaining how you can tell it which ESP if there's more than one. It could be doing that if you just supply the device name as well, just unsure if it does.

Also on Debian based systems

Posted Jul 31, 2020 12:29 UTC (Fri) by cortana (subscriber, #24596) [Link]

Someone should update the GRUB manual then!

23 Invoking grub-install
************************

The program 'grub-install' generates a GRUB core image using
'grub-mkimage' and installs it on your system.  You must specify the
device name on which you want to install GRUB, like this:

     grub-install INSTALL_DEVICE

   The device name INSTALL_DEVICE is an OS device name or a GRUB device
name.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds