diff options
-rw-r--r-- | docs/grub-2-guide.xml | 315 |
1 files changed, 315 insertions, 0 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- $Header: $ --> + +<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> + +<guide disclaimer="draft" link="/doc/en/grub-2-guide.xml" lang="en"> +<title>GRUB 2 Guide</title> + +<author title="Author"> + <mail link="matej@laitl.cz">Matěj Laitl</mail> +</author> + +<author title="Author"> + <mail link="scarabeus"/> +</author> + +<abstract> +This guide shows you how to install and configure GRUB 2 bootloader. +</abstract> + +<!-- The content of this document is licensed under the CC-BY-SA license --> +<!-- See http://creativecommons.org/licenses/by-sa/2.5 --> +<license/> + +<version>1</version> +<date>2011-08-26</date> + +<chapter> +<title>About</title> +<section> +<body> + +<p> +GRUB 2 is next generation bootloader that brings many long awaited features +that were not availible in Grub Legacy (0.9*). +</p> + +<p> +Some examples of new features: +</p> + +<ul> +<li>Booting from boot partition stored on LVM</li> +<li>Booting from encrypted boot partition</li> +<li>Booting from UEFI</li> +<li>Support for native screen resolution and theming</li> +</ul> + +</body> +</section> +</chapter> + +<chapter> +<title>Installation</title> +<section> +<title>Setting Useflags</title> +<body> + +<p> +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. +</p> + +<p>Description of mostly used values for GRUB_PLATFORMS as of =sys-boot/grub-1.99:</p> + +<ol> +<li>pc: normal BIOS pc</li> +<li>efi-64: EFI systems, their latest 64b version</li> +<li>coreboot: Coreboot replacement of BIOS</li> +<li>qemu: support for QEMU booting</li> +<li>yeelong: Support for MIPS loongson</li> + +</ol> + +<note> +Most users should just rely on platform detection or just use +GRUB_PLATFORMS="pc" +</note> + +<warn> +One should be really carefull with custom-cflags IUSE, as some CFLAGS can +easily render your system impossible to boot. +</warn> + +</body> +</section> + +<section> +<title>Configuring GRUB</title> +<body> + +<impo> +Gentoo installs grub renamed to grub2. So if you read any other guide you +should replace all grub mentions with grub2 <i>(grub-mkconfig -> grub2-mkconfig)</i>. +</impo> + +<p> +Compared to grub-legacy current grub uses automatic generation to generate +all the required entries for you to boot. This is handled by <i>grub2-mkconfig</i> +command that probes your system for all the required data. Cooperating with +<i>sys-boot/os-prober</i> it detects even other OSes on all disks. +</p> + +<impo> +If you updated from grub-legacy then your <path>/boot/grub/menu.lst</path> +Was converted to <path>/boot/grub2/grub.cfg</path> 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. +</impo> + +<pre caption="Generating the grub2 config"> +grub2-mkconfig -o /boot/grub2/grub.cfg +</pre> + +<p> +Tweaking the options is to be done in the <path>/etc/defaults/grub</path> file. +Simple text file configuration with description of some default values. +All the options are described in grub2 info pages. +</p> + +<note> +This file is created by Gentoo and if you find interesting option not used +in there just open bugreport (possibly with a patch). +</note> + +<p> +Sometimes if automatic detection of grub does not suffice the file <path> +/etc/grub.d/40_custom</path> should be used to store custom finder. Full +description how to configure such with example can be find in grub2 info +pages. +</p> + +<pre caption="Custom menu entry"> +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 +} +</pre> + +<warn> +Remember to replace the <i><UUID></i> with your device UUID. +</warn> + +</body> +</section> + +<section> +<title>Pre-Configuring GRUB to use EFI</title> +<body> + +<p> +Some newer PCs (and all Intel Macs) come with +<uri link="http://en.wikipedia.org/wiki/Extensible_Firmware_Interface">EFI</uri> +(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, <b>64bit +EFI firmware cannot run 32bit EFI bootloader.</b> 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) +</p> + +<p>First thing you need is EFI-enabled Linux kernel with +<c>CONFIG_EFI</c> and <c>CONFIG_EFI_PARTITION</c> options enabled, +<c>CONFIG_FB_EFI</c> and <c>CONFIG_EFI_VARS</c> being optional but recommended. +Some platforms (namely many boards designed for <e>Intel Sandy Bridge</e> +processor generation) have <uri link="https://lkml.org/lkml/2011/5/19/377"> +buggy EFI implementations</uri> and require at least kernel versions 2.6.39.1 +or 3.0 in order to successfully boot. +</p> + +<p> +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 <b>EFI System Partition</b>. During bootup, EFI +fimrmware can execute <e>EFI applications</e> stored in files in EFI System +Partition. One special EFI application is a bootloader. You may use the EFI +System Partition as your <c>/boot</c> 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 <c>/boot</c> for +mounting EFI System Partition. +</p> + +<p> +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 <c>gdisk</c> (CLI, sys-apps/gptfdisk), <c>parted</c> (CLI, +sys-block/parted) or <c>gparted</c> (GUI, sys-block/gparted) partitioning +tools; <c>fdisk</c>, <c>cfdisk</c> and <c>sfdisk</c> do not currently support +GPT. In the GPT case, create a partition at least 100 MiB in size with +<c>boot</c> flag (shown by (g)parted) or <c>EF00</c> Code (shown by gdisk). +</p> + +<note> +Replace <c>/dev/sda</c> with disk you want to have EFI System Partition on and +<c>/dev/sda1</c> with partition designated for it in all following samples. +</note> + +<pre caption="EFI System Partion on GPT disk as shown by gdisk"> +# <i>gdisk -l <keyword>/dev/sda</keyword></i> +<comment>(...)</comment> + +Number Start (sector) End (sector) Size Code Name +<ident> 1 34 411647 201.0 MiB EF00 </ident> +</pre> + +<pre caption="EFI System Partion on GPT disk as shown by parted"> +# <i>parted -l</i> +<comment>(...)</comment> + +Number Start End Size File system Name Flags +<ident> 1 17.4kB 211MB 211MB fat32 boot</ident> <comment># you may have File system field empty</comment> +</pre> + +<p> +In case the disk partition scheme is MBR (MS-DOS), EFI System Partition should +have type <c>EF</c>. Create or re-type it, again it should be at least 100 MiB +large. +</p> + +<pre caption="EFI System Partion on MBR disk as shown by fdisk"> +# <i>fdisk -l <keyword>/dev/sda</keyword></i> +<comment>(...)</comment> + + Device Boot Start End Blocks Id System +<ident>/dev/sda1 2048 206847 102400 ef EFI (FAT-12/16/32)</ident> +</pre> + +<p> +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 +<c>mkdosfs</c> is from package <c>sys-fs/dosfstools</c>. +</p> + +<pre caption="Creating FAT32 filesystem on EFI System Partition"> +# <i>mkdosfs -F 32 -n efi-boot <keyword>/dev/sda1</keyword></i> +mkdosfs 3.0.9 (31 Jan 2010) +</pre> + +<warn> +This command erases everything that previously was on <c>/dev/sda1</c>. +</warn> + +<p> +The <c>-F 32</c> option tells mkdosfs to create FAT32 filesystem and <c>-n +efi-boot</c> option tells mkdosfs to set partition label to <c>efi-boot</c>. +You may use atrbitrary string up to 11 characters long for label or you may not +use it at all. +</p> + +<p> +After you prepared your HDDs you can easily proceed with generating the +configuration. +</p> + +</body> +</section> + +<section> +<title>Configuring with LVM</title> +<body> + +<p> +Grub2 itself detects the LVM correctly, with no aditional setup required. +</p> + +<impo> +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. +</impo> + +</body> +</section> +</chapter> + +<chapter> +<title>Installation of grub2</title> +<section> +<title>Installing on some MBR/GPT directly</title> +<body> + +<p> +Installation of grub2 is similar to installation of grub-legacy. +</p> + +<pre caption="Installing grub2 on /dev/sda"> +grub2-install --no-floppy /dev/sda +</pre> + +<impo> +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. +</impo> + +</body> +</section> + +</chapter> + +</guide> |