From 5abf098f57d8a974a663384c4c755cefbab290f2 Mon Sep 17 00:00:00 2001 From: Tomas Chvatal Date: Fri, 30 Sep 2011 14:12:41 +0200 Subject: Add grub2 xml guide. --- docs/grub-2-guide.xml | 315 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 315 insertions(+) create mode 100644 docs/grub-2-guide.xml diff --git a/docs/grub-2-guide.xml b/docs/grub-2-guide.xml new file mode 100644 index 0000000..ca0bc89 --- /dev/null +++ b/docs/grub-2-guide.xml @@ -0,0 +1,315 @@ + + + + + + +GRUB 2 Guide + + + Matěj Laitl + + + + + + + +This guide shows you how to install and configure GRUB 2 bootloader. + + + + + + +1 +2011-08-26 + + +About +
+ + +

+GRUB 2 is next generation bootloader that brings many long awaited features +that were not availible in Grub Legacy (0.9*). +

+ +

+Some examples of new features: +

+ +
    +
  • Booting from boot partition stored on LVM
  • +
  • Booting from encrypted boot partition
  • +
  • Booting from UEFI
  • +
  • Support for native screen resolution and theming
  • +
+ + +
+
+ + +Installation +
+Setting Useflags + + +

+By default grub tries to detect the desired platform during configure from your +toolchain and CPU. If you want support for other platforms or just don't want +to use the autodetection you should use GRUB_PLATFORMS use expand. This variable +should be set in /etc/make.conf. +

+ +

Description of mostly used values for GRUB_PLATFORMS as of =sys-boot/grub-1.99:

+ +
    +
  1. pc: normal BIOS pc
  2. +
  3. efi-64: EFI systems, their latest 64b version
  4. +
  5. coreboot: Coreboot replacement of BIOS
  6. +
  7. qemu: support for QEMU booting
  8. +
  9. yeelong: Support for MIPS loongson
  10. + +
+ + +Most users should just rely on platform detection or just use +GRUB_PLATFORMS="pc" + + + +One should be really carefull with custom-cflags IUSE, as some CFLAGS can +easily render your system impossible to boot. + + + +
+ +
+Configuring GRUB + + + +Gentoo installs grub renamed to grub2. So if you read any other guide you +should replace all grub mentions with grub2 (grub-mkconfig -> grub2-mkconfig). + + +

+Compared to grub-legacy current grub uses automatic generation to generate +all the required entries for you to boot. This is handled by grub2-mkconfig +command that probes your system for all the required data. Cooperating with +sys-boot/os-prober it detects even other OSes on all disks. +

+ + +If you updated from grub-legacy then your /boot/grub/menu.lst +Was converted to /boot/grub2/grub.cfg to ensure that your system +can boot even if you forget to generate the config. Never the less you should +take time and migrate the configuration to be automatically generated, because +next time grub2 is installed it will use automatic generation and ignore +grub-legacy files. + + +
+grub2-mkconfig -o /boot/grub2/grub.cfg
+
+ +

+Tweaking the options is to be done in the /etc/defaults/grub file. +Simple text file configuration with description of some default values. +All the options are described in grub2 info pages. +

+ + +This file is created by Gentoo and if you find interesting option not used +in there just open bugreport (possibly with a patch). + + +

+Sometimes if automatic detection of grub does not suffice the file +/etc/grub.d/40_custom should be used to store custom finder. Full +description how to configure such with example can be find in grub2 info +pages. +

+ +
+menuentry "My Shiny Gentoo Kernel" {
+	set root=(hd0,1)
+	search --no-floppy --fs-uuid --set <UUID>
+	linux /boot/gentookernel-5.3.2-generic root=UUID=<UUID>
+	initrd /boot/initrd.img-5.3.2
+}
+
+ + +Remember to replace the <UUID> with your device UUID. + + + +
+ +
+Pre-Configuring GRUB to use EFI + + +

+Some newer PCs (and all Intel Macs) come with +EFI +(UEFI to be correct) as a replacement for lagacy +and aging BIOS firmware. EFI usually can emulate BIOS environment for OS, but +that also hides some unique features of EFI such as faster boot times, support +for GPT partition tables etc. EFI firmware comes in two flavours - 32bit and +64bit and unless you have early Intel-based Mac with 32bit processor, your +firmware will be likely 64bit. Please note that unlike in user-space, 64bit +EFI firmware cannot run 32bit EFI bootloader. This section will guide you +through installing GRUB 2 on such EFI-capable boards; it assumes that your +firmware adheres to UEFI 2.0 standard or newer (virtually every PC with EFI +support; Intel Macs do not entirely conform to the specification and may need +special treatment in some places) +

+ +

First thing you need is EFI-enabled Linux kernel with +CONFIG_EFI and CONFIG_EFI_PARTITION options enabled, +CONFIG_FB_EFI and CONFIG_EFI_VARS being optional but recommended. +Some platforms (namely many boards designed for Intel Sandy Bridge +processor generation) have +buggy EFI implementations and require at least kernel versions 2.6.39.1 +or 3.0 in order to successfully boot. +

+ +

+One big difference between BIOS and EFI is that EFI is able to read partition +table (both MBR and GPT formats should be supported) and to read from specially +labelled FAT32 partition called EFI System Partition. During bootup, EFI +fimrmware can execute EFI applications stored in files in EFI System +Partition. One special EFI application is a bootloader. You may use the EFI +System Partition as your /boot partition if you don't mind limitations +of FAT32 filesystem such as no support for symlinks and per-file owner and +permissions. The rest of this section assumes that you use /boot for +mounting EFI System Partition. +

+ +

+If you don't already have EFI System Partition, let's create one. The procedure is +different for GPT and MBR-formatted disks. The partition need not be the first +one on disk as in our examples. In case it is GPT-partitioned you'll need one +of the gdisk (CLI, sys-apps/gptfdisk), parted (CLI, +sys-block/parted) or gparted (GUI, sys-block/gparted) partitioning +tools; fdisk, cfdisk and sfdisk do not currently support +GPT. In the GPT case, create a partition at least 100 MiB in size with +boot flag (shown by (g)parted) or EF00 Code (shown by gdisk). +

+ + +Replace /dev/sda with disk you want to have EFI System Partition on and +/dev/sda1 with partition designated for it in all following samples. + + +
+# gdisk -l /dev/sda
+(...)
+
+Number  Start (sector)    End (sector)  Size       Code  Name
+   1              34          411647   201.0 MiB   EF00  
+
+ +
+# parted -l
+(...)
+
+Number  Start   End     Size    File system  Name  Flags
+ 1      17.4kB  211MB   211MB   fat32              boot # you may have File system field empty
+
+ +

+In case the disk partition scheme is MBR (MS-DOS), EFI System Partition should +have type EF. Create or re-type it, again it should be at least 100 MiB +large. +

+ +
+# fdisk -l /dev/sda
+(...)
+
+   Device Boot      Start         End      Blocks   Id  System
+/dev/sda1            2048      206847      102400   ef  EFI (FAT-12/16/32)
+
+ +

+Next create FAT32 filesystem on it if you already haven't done so. From now on, +procedure is the same for both GPT and MBR-formatted disks. Program +mkdosfs is from package sys-fs/dosfstools. +

+ +
+# mkdosfs -F 32 -n efi-boot /dev/sda1
+mkdosfs 3.0.9 (31 Jan 2010)
+
+ + +This command erases everything that previously was on /dev/sda1. + + +

+The -F 32 option tells mkdosfs to create FAT32 filesystem and -n +efi-boot option tells mkdosfs to set partition label to efi-boot. +You may use atrbitrary string up to 11 characters long for label or you may not +use it at all. +

+ +

+After you prepared your HDDs you can easily proceed with generating the +configuration. +

+ + +
+ +
+Configuring with LVM + + +

+Grub2 itself detects the LVM correctly, with no aditional setup required. +

+ + +If you placed your root and boot partitions inside LVM make sure that disk +you plan to use as booting one has at least few MBs of space before first +partition, because grub2 needs more space to store lvm loader. In other +words if you install it with not enough space it will just break your +partition. + + + +
+
+ + +Installation of grub2 +
+Installing on some MBR/GPT directly + + +

+Installation of grub2 is similar to installation of grub-legacy. +

+ +
+grub2-install --no-floppy /dev/sda
+
+ + +If you get ANY errors during this step do not reboot your computer, +but make sure it is fixed. Your computer won't boot if installation +fail. + + + +
+ +
+ +
-- cgit v1.2.3-65-gdbad