Difference between pages "GUID Booting Guide" and "Package:Boot-Update"

From Funtoo
(Difference between pages)
Jump to navigation Jump to search
 
 
Line 1: Line 1:
{{Article
{{Ebuild
|Keywords=GPT, GUID, UEFI, EFI, Linux, Funtoo, Gentoo
|Summary=Funtoo Core Boot Framework for global boot loader configuration
|Article Category=General
|CatPkg=sys-boot/boot-update
|Author=Drobbins
|Maintainer=Drobbins
|Repository=Funtoo Overlay
|Organization=Funtoo Technologies
|Overlay=Funtoo
}}
}}
== Introduction ==
Funtoo boot-update provides a unified mechanism for configuring the GRUB 1.9x ({{Package|sys-boot/grub}}) and GRUB 0.97 ({{Package|sys-boot/grub-legacy}}) boot loaders. It is the recommended, official way to configure Funtoo Linux systems for booting.


GPT, which stands for GUID Partition Table, is a disk partitioning scheme that was introduced by Intel for Itanium architecture systems, as part of EFI, the Extensible Firmware Interface. While you are probably not using an Itanium architecture computer, and you are likely using a BIOS-based rather than an EFI-based system, you still may want to use GPT partitioning. Why? Because the standard MBR-based partitioning scheme only supports system disks that are less than 2TiB in size. On modern systems, especially systems with hardware RAID logical volumes, it is very easy to go beyond the 2TiB limit. GUID partition tables support disks that are larger than 2TiB in size.
== Current Version ==


=== GPT Technology Overview ===
* {{Package|sys-boot/boot-update}}


This section contains a technical overview of GPT technology.
== Man Pages ==
Consult the following man pages for detailed, up-to-date information on configuration file settings and command-line arguments:


GUID partition tables support up to 512 partitions. GPT data structures are stored in the first sectors of the drive with a secondary copy stored at the end of the drive. This allows the partitioning scheme of your disk to be recovered in situations where the primary partition table has been corrupted.
* boot-update(8)
* boot.conf(5)


For compatibility with legacy partitioning tools, GPT partitioning tools typically rewrite the MBR partition table (generally located in the first sector of the disk) in a way those tools will interpret it like ''"This disk has only one partition (of an unknown type) covering the whole disk".''
{{:Install/BootLoader}}


It is possible to convert an existing MBR-partitioned disk to GPT format using the <tt>gdisk</tt> command. Please carefully read the <tt>gdisk</tt> man page before using this capability, as it is potentially dangerous, particularly if you are performing it on your boot disk.
=== GRUB 0.97 (grub-legacy) Quick Start ===


{{ important|Funtoo Linux fully supports GPT on x86-32bit and x86-64-bit systems.
If using <code>sys-boot/grub-legacy-0.97</code>, perform the following steps:
}}
 
=== Booting GPT ===
 
If you decide to use a GPT-based partitioning scheme for your system disk, either out of necessity due to a 2TiB+ disk, or because you want to try GPT out, then the question arises -- how do you get the darn thing to boot? This is where the new <tt>GRUB</tt> boot loader comes in. The new {{c|GRUB}} (version 2.0, found at <tt>sys-boot/grub</tt>) is a redesign of the original {{c|GRUB}} (version 0.9x, now called {{c|sys-boot/grub-legacy}} in Funtoo) boot-loader that includes very mature support for booting from GPT-based disks.
 
Now, let's take a look at how to get GPT-based booting working under Funtoo Linux.
 
== Getting Started ==
 
The first thing you'll need to do is to use a LiveCD. I recommend [http://www.sysresccd.org/Main_Page System Rescue CD] for this task as it is Gentoo-based and includes all the proper tools. Go ahead and boot the LiveCD, and then get to the point where you are ready to partition your system disk.
 
At this point, you have two choices as to what partitioning tool to use. You can use either <tt>gdisk</tt> or <tt>parted</tt>. <tt>gdisk</tt> is a very nice <tt>fdisk</tt>-like partitioning tool that supports GPT partitioning. It is rather new software but seems to work quite well. The other tool you can use, GNU <tt>parted</tt>, has been around for a while and is more mature, but is harder to use.


We'll take a look at how to create partitions using <tt>gdisk</tt>. Alternatively, <code>cgdisk</code>, curses-based gdisk for users familiar with cfdisk or <code>sgdisk</code>, command-line tool can be used for creating and managing GPT partitions.
* Partition disk using MBR partitions '''(GPT not supported)'''
* Install kernel/initrd to <code>/boot</code>


== Partitioning Using Gdisk ==
<console>
###i## emerge sys-boot/boot-update
###i## emerge ">=sys-boot/grub-legacy-0.97-r11"
###i## grub-install-legacy /dev/sda
</console>
Due to an issue with <code>grub-legacy</code>, you may see the following message:
<console>
###i## grub-install-legacy /dev/sda
The file /boot/grub-legacy/stage1 not read correctly.
</console>
Should you receive this message, you will have to install <code>grub-legacy</code> from the grub shell.
Assuming <code>/boot</code> is the partition <code>/dev/sda1</code> and you want to install grub to the MBR, you would run the following:
<console>
###i## grub-legacy
root (hd0,0)
setup (hd0)
quit
</console>
When adjusting to fit your setup, remember 'root' is the location of your boot partition, 'setup' is where you want to install grub, and don't forget about grub's unique naming conventions for hard drives / partitions. For more information run:
<console>
###i## info grub-legacy
</console>


OK, the first step is using <tt>gdisk</tt> is to start it up, specifying the disk you want to modify:
Ensure that <code>/etc/fstab</code> is correct, and edit <code>/etc/boot.conf</code> to reflect your installation.
 
Ensure a <code>generate grub-legacy</code> setting in the <code>boot</code> section. Then run:
{{console|body=# ##i##gdisk /dev/sda}}
You should find <tt>gdisk</tt> very familiar to <tt>fdisk</tt>. Here is the partition table we want to end up with:
 
{{console|body=Command (? for help): ##i##p
Disk /dev/sda: 312581808 sectors, 149.1 GiB
Disk identifier (GUID): 17
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 312581774
Total free space is 0 sectors (0 bytes)
 
Number  Start (sector)    End (sector)  Size      Code  Name
  1              34          204833  100.0 MiB  0700  Linux/Windows data
  2          204834          270369  512.0 kiB  EF02  BIOS boot partition
  3          270370        1318945  512.0 MiB  8200  Linux swap
  4        1318946      312581774  148.4 GiB  0700  Linux/Windows data
 
Command (? for help): }}
 
Above, you'll see that we have a 100 MiB boot partition, a 512 kiB &quot;BIOS boot partition&quot;, 512 MiB of swap, and the remaining disk used by a 148.4 GiB root partition.
 
The one new thing here is the &quot;BIOS boot partition.&quot; What is it? In GRUB-speak, this BIOS boot partition is basically the location of the meat of GRUB's boot loading code - the quivalent of the <tt>stage1_5</tt> and <tt>stage2</tt> files in legacy GRUB. Since GPT-based partition tables have less &quot;bonus&quot; space than their MBR equivalents, and explicit partition of code <tt>EF02</tt> is required to hold the guts of the boot loader.
 
In all other respects, the partition table is similar to that of an MBR-based disk. We have a boot and root partition with code <tt>0700</tt>, and a Linux swap partition with code <tt>8200</tt>. One this partition table has been written to disk and appropriate <tt>mkfs</tt> and <tt>mkswap</tt> commands are issued, <tt>/dev/sda1</tt> will be used to hold <tt>/boot</tt>, <tt>/dev/sda2</tt> will be used by the new GRUB directly, <tt>/dev/sda3</tt> will house our swap and <tt>/dev/sda4</tt> will hold our root filesystem.
 
Go ahead and create filesystems on these partitions, and then mount the root and boot filesystems to <tt>/mnt/gentoo</tt> and <tt>/mnt/gentoo/boot</tt> respectively. Now go ahead and unpack a stage3 tarball to <tt>/mnt/gentoo</tt> and chroot in as you normally do.
 
== Configuring The Kernel ==
 
Your kernel will need a couple of extra GPT-related options enabled in order for it to make sense of your GPT partitions and find your filesystems.  
 
{{kernelop|title=Enable the block layer,Partition Types|desc=
[*] Advanced Partition Selection (PARTITION_ADVANCED)
[*] EFI GUID Partition Support (EFI_PARTITION)
}}
 
If you are using a non-Funtoo distribution then you may need to append a proper <tt>rootfstype=</tt> option to your kernel boot options to allow Linux to properly mount the root filesystem when <tt>Advanced Partition Selection</tt> is enabled. [[Boot-Update]] does this for you automatically.
 
Now just go ahead and compile and install your kernel, and copy it to <tt>/boot/bzImage</tt>.
 
== Booting The System ==
 
To get the system booted, you will want to first edit <tt>/etc/fstab</tt> inside the chroot so that it reflects the partitions and filesystems you just created. For Funtoo Linux systems, this is done by emerging {{c|boot-update}}, which is the universal boot loader configurator for Funtoo Linux.
 
{{console|body=# ##i##emerge boot-update}}
 
[[Boot-Update]] is a front-end for the GRUB 1.9x boot loader and provides a necessary simplified configuration interface. <tt>boot-update</tt> is used to generate boot loader configuration files. But before we get to <tt>boot-update</tt>, we first need to install GRUB to your hard disk. This is done as follows:
 
{{console|body=# ##i##grub-install /dev/sda}}
<tt>grub-install</tt> will detect and use <tt>/dev/sda2</tt> and use it to store its boot loader logic.
 
Now it's time to create an <tt>/etc/boot.conf</tt> file. For more information on all available options, consult the [[Boot-Update]] guide -- I'll show you a sample configuration for the sample GPT partition scheme above:
 
{{file|name=/etc/boot.conf|body=boot {
        generate grub
        default bzImage
}
 
&quot;Funtoo Linux&quot; {
        kernel bzImage
}
}}
Once <tt>/etc/boot.conf</tt> has been created, then type:


{{console|body=# ##i##boot-update}}
<console>
This will auto-generate a <tt>/boot/grub/grub.cfg</tt> file for you, and you will now be able to reboot into Funtoo Linux using a GPT partitioning scheme.
###i## boot-update
</console>
This will auto-generate the <code>/boot/grub-legacy/grub.conf</code> required for booting. Note that <code>grub-legacy-0.97-r11</code> and later stores <code>grub.conf</code> in the <code>/boot/grub-legacy</code> directory.


For more information on all the options available for <tt>/etc/boot.conf</tt>, please consult the [[Boot-Update]] guide.
Re-run <code>boot-update</code> every time your available kernels / initrds or <code>/etc/boot.conf</code> configuration changes.


[[Category:Articles]]
[[Category:Projects]]
{{ArticleFooter}}
[[Category:Funtoo features]]
{{EbuildFooter}}

Revision as of 18:18, January 11, 2015

Boot-Update

   Tip

We welcome improvements to this page. To edit this page, Create a Funtoo account. Then log in and then click here to edit this page. See our editing guidelines to becoming a wiki-editing pro.

Funtoo boot-update provides a unified mechanism for configuring the GRUB 1.9x (No results) and GRUB 0.97 (No results) boot loaders. It is the recommended, official way to configure Funtoo Linux systems for booting.

Current Version

Man Pages

Consult the following man pages for detailed, up-to-date information on configuration file settings and command-line arguments:

  • boot-update(8)
  • boot.conf(5)

Installing a Bootloader

These install instructions show you how to use GRUB to boot using BIOS (old-school) or UEFI (new-school). As of boot-update-1.7.2, now in Portage, the steps are very similar.

First, emerge boot-update. This will also cause grub-2 and efibootmgr to be merged, since they are dependencies:

(chroot) # emerge boot-update

Then, edit /etc/boot.conf using nano and specify "Funtoo Linux genkernel" as the default setting at the top of the file, replacing "Funtoo Linux".

/etc/boot.conf should now look like this:

   /etc/boot.conf
boot {
	generate grub
	default "Funtoo Linux genkernel" 
	timeout 3 
}

"Funtoo Linux" {
	kernel bzImage[-v]
}

"Funtoo Linux genkernel" {
	kernel kernel[-v]
	initrd initramfs[-v]
	params += real_root=auto 
} 

"Funtoo Linux better-initramfs" {
	kernel vmlinuz[-v]
	initrd /initramfs.cpio.gz
}

If you are booting a custom or non-default kernel, please read man boot.conf for information on the various options available to you.

Old School (BIOS) MBR

When using "old school" BIOS booting, run the following command to install GRUB to your MBR, and generate the /boot/grub/grub.cfg configuration file that GRUB will use for booting:

(chroot) # grub-install --target=i386-pc --no-floppy /dev/sda
(chroot) # boot-update

New School (UEFI) Boot Entry

If you're using "new school" UEFI booting, run of the following sets of commands, depending on whether you are installing a 64-bit or 32-bit system. This will add GRUB as a UEFI boot entry.

For x86-64bit systems:

(chroot) # grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id="Funtoo Linux [GRUB]" --recheck /dev/sda
(chroot) # boot-update

For x86-32bit systems:

(chroot) # grub-install --target=i386-efi --efi-directory=/boot --bootloader-id="Funtoo Linux [GRUB]" --recheck /dev/sda
(chroot) # boot-update

First Boot, and in the future...

OK -- you are ready to boot!

You only need to run grub-install when you first install Funtoo Linux, but you need to re-run boot-update every time you modify your /etc/boot.conf file or add new kernels to your system. This will regenerate /boot/grub/grub.cfg so that you will have new kernels available in your GRUB boot menu, the next time you reboot.

GRUB 0.97 (grub-legacy) Quick Start

If using sys-boot/grub-legacy-0.97, perform the following steps:

  • Partition disk using MBR partitions (GPT not supported)
  • Install kernel/initrd to /boot
root # emerge sys-boot/boot-update
root # emerge ">=sys-boot/grub-legacy-0.97-r11"
root # grub-install-legacy /dev/sda

Due to an issue with grub-legacy, you may see the following message:

root # grub-install-legacy /dev/sda
The file /boot/grub-legacy/stage1 not read correctly.

Should you receive this message, you will have to install grub-legacy from the grub shell. Assuming /boot is the partition /dev/sda1 and you want to install grub to the MBR, you would run the following:

root # grub-legacy
root (hd0,0)
setup (hd0)
quit

When adjusting to fit your setup, remember 'root' is the location of your boot partition, 'setup' is where you want to install grub, and don't forget about grub's unique naming conventions for hard drives / partitions. For more information run:

root # info grub-legacy

Ensure that /etc/fstab is correct, and edit /etc/boot.conf to reflect your installation. Ensure a generate grub-legacy setting in the boot section. Then run:

root # boot-update

This will auto-generate the /boot/grub-legacy/grub.conf required for booting. Note that grub-legacy-0.97-r11 and later stores grub.conf in the /boot/grub-legacy directory.

Re-run boot-update every time your available kernels / initrds or /etc/boot.conf configuration changes.