Talk:GRUB2 Quick Start

From Gentoo Wiki
Jump to: navigation, search
Note
This is a MediaWiki talk page. Please add newer comments below older ones, and sign your comments using four tildes (~~~~). When adding a new section (at the bottom of the page), please mark it as "open for discussion" by using {{talk|open}} so it will show up in the list of open discussions.

UEFI/GPT

I miss some more compact information about UEFI/GPT or in other words: I would have liked to see it here when I set up my first UEFI/GPT boot:

  1. EFI boot entries are saved in the EFI NVRAM. They specify the location (disk and partition) of the boot loaders.
  2. Bootloaders (i.e. windows bootloader, grub binary) are stored in a EFI vfat partition. It is recommened to use only one EFI vfat partition (my mainboard firmware shows a huge growing list of the same boot entries if I have more than one EFI partition). If you have installed an OS via UEFI previously (like Windows), you already have an EFI partition, that you can use.
  3. If you want to use features like "grub2-reboot" or GRUB_SAVEDEFAULT=true, your /boot must be placed on a file system on which grub has write support (it does not have write support vfat partitions (It fails on "save_env" with "malformed file")). In this case the EFI partition should be mounted to /boot/efi (and not directly to /boot). A typical partition table would look like
    CODE
    /dev/sda1 EFI vfat
    /dev/sda2 /boot ext2
    /dev/sda3 swap
    /dev/sda4 /
    
  4. You should check the EFI boot menu entries after grub installation: efibootmgr -v. The path \EFI\gentoo\grubx64.efi must correspond with your /boot/efi/EFI/gentoo/grubx64.efi. If not, create an entry efibootmgr --create --disk /dev/sda --part 2 --label gentoo --loader "\EFI\gentoo\grubx64.efi"
  5. If you want multiple boots you should check: If the other OSs have their own EFI boot loader (like windows) or if you can boot them directly from grub (like a linux kernel). To add an EFI bootloader to your grub boot menu, list your EFI boot entries with "efibootmgr -v" and you will see something like "\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI". You should check the partition and location of the bootloader (i.e. /boot/efi/EFI/Microsoft/Boot/bootmgfw.efi). Now you can create your boot entry in /etc/grub.d/40_custom:
    CODE
    menuentry "Windows" {
        root=hd0,2 #the partition where the bootloader is located
        chainloader /EFI/Microsoft/Boot/bootmgfw.efi
    }
    
    To add another linux boot entry it would look like
    CODE
    menuentry "Linux" {
        root=hd0,3
        linux	/vmlinuz-4.1.12-gentoo root=/dev/sda3
    }
    
  6. UEFI_Dual_boot_with_Windows_7/8 should be tidied up/changed/updated. As you see above it is in most cases not that complicated to chainload the windows bootloader.

--Mattenklicker (talk) 18:34, 28 January 2016 (UTC)

The no-maintenance approach

I'm not sure where to put this right now - this seems to be as good a place as any:

I don't like that I have to auto-generate the grub config every time I update my kernel, that's so LILO. For me, GRUB is something I set up at the beginning, and then never think about it again. With a setup as described in this article, and in the main GRUB2 article, as well as the guide, the user is forced to do the grub2-mkconfig dance every time after a kernel update.

I solved the problem by having a menu entry that boots '/boot/vmlinuz' - the good old symlink generated by the kernel's 'make install', that always points to the newest kernel:

root #chmod -x /etc/grub.d/10_linux

and instead use

FILE /etc/grub.d/10_current_linux_simple
#!/bin/sh
echo "Adding Linux... [$0]" >&2
echo "
menuentry 'Linux' {
        set root=(hd0,1)
        linux /boot/vmlinuz ${GRUB_CMDLINE_LINUX_DEFAULT}
}
"

That's better than editing /boot/grub2/grub.cfg directly, as proposed in the Manual Configuration section, because you can still change stuff in /etc/default/grub or elsewhere and rebuild the config, without having to edit grub.cfg again afterwards. And it's just much more KISS than that huge /etc/grub.d/10_linux.

--Padde (talk) 02:19, 3 January 2013 (UTC)