Bootloader GRUB

Nachdem ich jahrelang den Linux-loader LILO verwendet habe, habe ich irgendwann auf GRUB gewechselt, hauptsächlich weil ich es leid war nach jedem Kernelupdate daran zu denken "lilo" einzugeben.

Notwendige Pakete installieren

pacman -S grub efibootmgr

Hinweis zur Partitionierung von GPT Datenträgern

Wenn GRUB2 auf einem Datenträger installiert werden soll, welcher mit GPT partitioniert ist, wird eine separate Partition für den Bootloader benötigt. Für den älteren BIOS Modus ist das eine Partition des Typs ef02 (BIOS boot partition), für den neuen UEFI Modus ist dies eine FAT32 Partition. Für Artix Linux, siehe auch meine Hinweise zur Partitionierung.

Konfiguration bei verschlüsseltem root-device

Damit das Booten mit verschlüsseltem root-device klappt, muss in der Datei /etc/default/grub dem Kernel mittels dem Parameter GRUB_CMDLINE_LINUX das korrekte Cryptodevice übergeben werden, zum Beispiel wenn root auf /dev/sda2 liegt so:

/etc/default/grub
... GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root" ...

Grub veranlassen, die configuration neu zu bilden

grub-mkconfig -o /boot/grub/grub.cfg

GRUB auf UEFI Systemen installieren

Zuerst muss die EFI Partition auf /efi gemountet sein. Dann:

grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=GRUB

Grub in den MBR installieren (bei msdos partitionierung)

grub-install --target=i386-pc --recheck /dev/sda

Eine GRUB floppy disk erstellen

# /sbin/grub --batch --device-map=/dev/null << EOF > device (fd0) /dev/fd0 > root (fd0) > setup (fd0) > quit > EOF

Eine bootfähige GRUB CD-ROM erstellen

First of all, I have to say that I did not manage to find a way to create a CD-R that will boot on all my Computers.
Especially the Laptops are picky, and each in it's own way.
Anyway, something like this is supposed to work:

$ mkdir -p boot_cd/boot/grub $ cp /usr/lib/grub/i386-pc/stage2_eltorito boot_cd/boot/grub ## Optional: Configuration create/copying: $ vim boot_cd/boot/grub/menu.lst ## Now copy desired CD content: $ cp -vdpR cd_content boot_cd ## Variant 1: $ mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \ -boot-load-size 4 -boot-info-table -o grub.iso boot_cd

This creates the file grub.iso that can be burned on a CD-R as it is. There is no need for further modifications by grub.
The option "-boot-load-size 4" is meant to be used for compatibility with the BIOS of older computers.
Trying to boot a CD-R created with variant #1 has those results:

Beispiel /boot/grub/menu.lst Konfiguration

/boot/grub/menu.lst
default 0 timeout 10 color green/black light-green/black title Linux root (hd0,0) kernel /kernel root=/dev/hda4 vga=0 title Linux with initramfs root (hd0,0) kernel /kernel-2.6.xx initrd /initramfs_data.cpio.gz title Load kernel and initramfs from floppy root (hd0,0) kernel (fd0)/kernel-2.6.xx root=/dev/ram0 # TODO: Check which one of those actually works # prompt "Now insert disk with the initrd image" # pause Insert disk with the initrd image, then press enter initrd (fd0)/initrd.img.gz title Windows 98 hide (hd0,0) unhide (hd0,2) rootnoverify (hd0,2) chainloader +1 makeactive title Memdisk floppy emulator root (hd0,0) kernel /memdisk initrd /bootdisk.img

Using GRUB and Memdisk to boot a floppy image

Most modern computers (especially "netbooks") come without a floppy drive. If you need to boot DOS to flash the BIOS (or for other reasons), this can be done with Memdisk. Memdisk is part of the Syslinux package, which can be found on the Syslinux homepage.
Memdisk puts the image of the floppy disk (which must be passed to it with the GRUB "initrd" parameter) to the Highmem and installs a small driver (typically about 2K) in Lowmem.

Hide the GRUB boot menu

add GRUB_FORCE_HIDDEN_MENU="true" to /etc/default/grub then run grub-mkconfig -o /boot/grub/grub.cfg