Gentoo Logo

1.  Making your Choice

Introduction

Now that your kernel is configured and compiled and the necessary system configuration files are filled in correctly, it is time to install a program that will fire up your kernel when you start the system. Such a program is called a bootloader.

The bootloader that you use will depend upon the type of PPC machine you have.

If you are using a NewWorld Apple or IBM machine, you need to use yaboot. OldWorld Apple machines have two options, BootX (recommended) and quik. The Pegasos does not require a bootloader, but you will need to emerge bootcreator to create SmartFirmware boot menus.

1.  Default: Using yaboot

Introduction

Important: yaboot can only be used on NewWorld Apple and IBM systems!

In order to find the boot devices, yaboot needs access to the device nodes created by udev on startup and the sysfs filesystem. These two filesystems are found at /dev and sys respectively. To do this, you will need to "bind mount" these filesystems from the Installation CD's root to the /dev and /sys mount points inside the chroot. If you have already bind mounted these filesystems, there is no need to do it again.

Code Listing 1.1: Bind-mounting the device and sysfs filesystems

# exit  # this will exit the chroot
# mount --rbind /dev /mnt/gentoo/dev
# mount --rbind /sys /mnt/gentoo/sys
# chroot /mnt/gentoo /bin/bash
# /usr/sbin/env-update && source /etc/profile 

To set up yaboot, you can use yabootconfig to automatically create a configuration file for you. If you are installing Gentoo on a G5 (where yabootconfig does not always work), or you plan to boot from FireWire or USB, you will need to manually configure yaboot.

Note: You will need to manually edit the yaboot.conf when using genkernel, even if yabootconfig is used. The kernel image section of yaboot.conf should be modified as follows (using vmlinux and initrd as the name of kernel and initrd image):

Code Listing 1.1: Adding genkernel boot arguments to yaboot.conf

###########################################################
## This section can be duplicated if you have more than one
## kernel or set of boot options - replace the image and initrd
## with the exact filename of your kernel and initrd image.
###########################################################
image=/boot/${genkernel-name}
  label=Linux
  root=/dev/ram0
  partition=3
  initrd=/boot/${genkernel-initrd}
  # You can add additional kernel arguments to append such as 
  # rootdelay=10 for a USB/Firewire Boot
  append="real_root=/dev/sda3"  
  read-only
##########################################################

Default: Using yabootconfig

yabootconfig will auto-detect the partitions on your machine and will set up dual and triple boot combinations with Linux, Mac OS, and Mac OS X.

To use yabootconfig, your drive must have an Apple_Bootstrap partition, and /etc/fstab must be configured to reflect your Linux partitions (note that the Bootstrap partition should not be in your fstab). These steps should have already been completed before, but check /etc/fstab before proceeding. Now, install yaboot.

Code Listing 1.1: Installing yaboot

# emerge yaboot

Now exit the chroot and run yabootconfig --chroot /mnt/gentoo. First, the program will confirm the location of the bootstrap partition. If you are using the suggested disk partitioning scheme, your bootstrap partition should be /dev/sda2. Type Y if the output is correct. If not, double check your /etc/fstab. yabootconfig will then scan your system setup, create /etc/yaboot.conf and run mkofboot for you. mkofboot is used to format the Apple_Bootstrap partition, and install the yaboot configuration file into it. After this enter the chroot again.

Code Listing 1.1: Re-enter the chroot

# chroot /mnt/gentoo /bin/bash
# /usr/sbin/env-update && source /etc/profile

You should verify the contents of /etc/yaboot.conf. If you make changes to /etc/yaboot.conf (like setting the default/boot OS), make sure to rerun ybin -v to apply changes to the Apple_Bootstrap partition. Whenever you make a change to yaboot.conf, like when testing a new kernel, always remember to run ybin -v to update the bootstrap partition.

Now continue with Rebooting the System.

Alternative: Manual yaboot Configuration

First, install yaboot on your system:

Code Listing 1.1: Installing yaboot

# emerge yaboot

An example yaboot.conf file is given below, but you will need to alter it to fit your needs.

Code Listing 1.1: /etc/yaboot.conf

## /etc/yaboot.conf
##
## run: "man yaboot.conf" for details. Do not make changes until you have!!
## see also: /usr/share/doc/yaboot/examples for example configurations.
##
## For a dual-boot menu, add one or more of:
## bsd=/dev/sdaX, macos=/dev/sdaY, macosx=/dev/sdaZ

## The bootstrap partition:

boot=/dev/sda2

## ofboot is the Open Firmware way to specify the bootstrap partition.
## If this isn't defined, yaboot fails on the G5 and some G4s (unless 
## you pass the necessary arguments to the mkofboot/ybin program).
## hd:X means /dev/sdaX.
## 
## G5 users should uncomment this line!!

#ofboot=hd:2

## Users booting from firewire should use something like this line:
# ofboot=fw/node/sbp-2/disk@0:

## Users booting from USB should use something like this line:
# ofboot=usb/disk@0:

## hd: is shorthand for the first hard drive Open Firmware sees
device=hd:

## Firewire and USB users will need to specify the whole OF device name
## This can be found using ofpath, which is included with yaboot.

# device=fw/node@0001d200e00d0207/sbp-2@c000/disk@0:


delay=5
defaultos=macosx
timeout=30
install=/usr/lib/yaboot/yaboot
magicboot=/usr/lib/yaboot/ofboot

############################################################
## This section can be duplicated if you have more than one
## kernel or set of boot options - replace the image variable
## with the exact filename of your kernel.
###########################################################
image=/boot/${kernel-name}
  label=Linux
  root=/dev/sda3
  partition=3
#  append="rootdelay=10"  # Required for booting USB/Firewire
  read-only
##################

## G5 users and some G4 users should set 
##   macos=hd:13/
##   macosx=hd:12
## instead of the example values.
macos=/dev/sda13
macosx=/dev/sda12
enablecdboot
enableofboot

Once yaboot.conf is configured, run mkofboot -v to format the Apple_bootstrap partition and install the settings. If you change yaboot.conf after the Apple_bootstrap partition has been created, you can update the settings by running ybin -v

Code Listing 1.1: Setting up the bootstrap partition

# mkofboot -v

For more information on yaboot, take a look at the yaboot project. For now, continue the installation with Rebooting the System.

1.  Alternative: BootX

Important: BootX can only be used on OldWorld Apple systems with MacOS 9 or earlier!

Since BootX boots Linux from within MacOS, the kernel will need to be copied from the Linux Partition to the MacOS partition. First, mount the MacOS partition from outside of the chroot. Use mac-fdisk -l to find the MacOS partition number, sda6 is used as an example here. Once the partition is mounted, we'll copy the kernel to the system folder so BootX can find it.

Code Listing 1.1: Copying the kernel to the MacOS partition

# exit
cdimage ~# mkdir /mnt/mac
cdimage ~# mount /dev/sda6 /mnt/mac -t hfs
cdimage ~# cp /mnt/gentoo/usr/src/linux/vmlinux "/mnt/mac/System Folder/Linux Kernels/${kernel-name}"

If genkernel is used, both the kernel and initrd will need to be copied to the MacOS partition.

Code Listing 1.1: Copying the Genkernel kernel and initrd to the MacOS partition

# exit
cdimage ~# mkdir /mnt/mac
cdimage ~# mount /dev/sda6 /mnt/mac -t hfs
cdimage ~# cp /mnt/gentoo/boot/${genkernel-name} "/mnt/mac/System Folder/Linux Kernels"
cdimage ~# cp /mnt/gentoo/boot/${genkernel-initrd} "/mnt/mac/System Folder"

Now that the kernel is copied over, we'll need to reboot to set up BootX.

Code Listing 1.1: Unmounting all partitions and rebooting

cdimage ~# cd /
cdimage ~# umount -l /mnt/gentoo/dev{/pts,/shm,}
cdimage ~# umount -l /mnt/gentoo{/proc,/sys,}
cdimage ~# umount -l /mnt/mac
cdimage ~# reboot

Of course, don't forget to remove the bootable CD, otherwise the CD will be booted again instead of MacOS.

Once the machine has booted into MacOS, open the BootX control panel. If you're not using genkernel, select Options and uncheck Use specified RAM disk. If you are using genkernel, ensure that the genkernel initrd is selected instead of the Installation CD initrd. If not using genkernel, there is now an option to specify the machine's Linux root disk and partition. Fill these in with the appropriate values. Depending upon the kernel configuration, additional boot arguments may need to be applied.

BootX can be configured to start Linux upon boot. If you do this, you will first see your machine boot into MacOS then, during startup, BootX will load and start Linux. See the BootX home page for more information.

Important: Make sure that you have support for HFS and HFS+ filesystems in your kernel, otherwise you will not be able to upgrade or change the kernel on your MacOS partition.

Now reboot again and boot into Linux, then continue with (Finalizing your Gentoo Installation).

1.  Alternative: quik

quik allows OldWorld Macs to boot without MacOS. However, it isn't well supported and has a number of quirks. If you have the option, it is recommended that you use BootX instead since it is much more reliable and easier to set up than quik.

First, we'll need to install quik:

Code Listing 1.1: Emerge quik

# emerge quik

Next, we'll need to set it up. Edit /etc/quik.conf and set your image to the kernel that we copied to your boot partition.

Code Listing 1.1: Configuring quik.conf

# Example of quik.conf
init-message = "Gentoo Linux\n"
# This is the boot partition
partition = 2
root = /dev/sda4
timeout = 30
default = gentoo
# This is your kernel
image = /${kernel-name}
  label = gentoo

Your quik.conf file must be on the same disk as the quik boot images, however it can be on a different partition on the same disk, although it is recommended to move it to your boot partition.

Code Listing 1.1: Moving quik.conf to /boot

# mv /etc/quik.conf /boot/quik.conf

We will now set your boot variables so that quik loads on boot. To do this, we'll use a program called nvsetenv. The variables that you want to set vary from machine to machine, it's best to find your machine's quirks before attempting this.

Code Listing 1.1: Setting the boot variables

# nvsetenv auto-boot true # Set to false if you want to boot into OF, not all models can display the OF output
# nvsetenv output-device video # Check the quirks page, there are many variations here
# nvsetenv input-device kbd
# nvsetenv boot-device scsi/sd@1:0 # For SCSI
# nvsetenv boot-device ata/ata-disk@0:0 # For ATA
# nvsetenv boot-file /boot/${kernel-name} root=/dev/sda4 First item is the path to the kernel, the second is the root partition.  You may append any kernel options to the end of this line.
# nvsetenv boot-command boot # Set this to bye for MacOS and boot for Linux

Note: It is also possible to change your boot variables from MacOS. Depending upon the model, either bootvars or Apple System Disk should be used. Please see the quik quirks page above for more information.

Now that we've set up our machine to boot, we'll need to make sure the boot images are installed correctly. Run quik -v -C /boot/quik.conf. It should tell you that it has installed the first stage QUIK boot block.

Note: If something has gone wrong, you can always reset your PRAM back to the default values by holding down command + option + p + r before powering on your machine. This will clear the values you set with nvsetenv and should allow you to boot either a MacOS bootdisk or a Linux bootdisk.

Now, continue the installation with Rebooting the System.

1.  Alternative: BootCreator

Important: BootCreator will build a nice SmartFirmware bootmenu written in Forth for the Pegasos.

First make sure you have bootcreator installed on your system:

Code Listing 1.1: Installing bootcreator

# emerge bootcreator

Now copy the file /etc/bootmenu.example into /etc/bootmenu and edit it to suit your needs:

Code Listing 1.1: Edit the bootcreator config file

# cp /etc/bootmenu.example /etc/bootmenu
# nano -w /etc/bootmenu

Below is a complete /etc/bootmenu config file. vmlinux and initrd should be replaced by your kernel and initrd image names.

Code Listing 1.1: bootcreator config file

#
# Example description file for bootcreator 1.1
#

[VERSION]
1

[TITLE]
Boot Menu

[SETTINGS]
AbortOnKey = false
Timeout    = 9
Default    = 1

[SECTION]
Local HD -> Morphos      (Normal)
ide:0 boot2.img ramdebug edebugflags="logkprintf"

[SECTION]
Local HD -> Linux (Normal)
ide:0 ${kernel-name} video=radeonfb:1024x768@70 root=/dev/sda3

[SECTION]
Local HD -> Genkernel (Normal)
ide:0 ${genkernel-name} root=/dev/ram0
real_root=/dev/sda3 initrd=${genkernel-initrd}

Finally the bootmenu must be transferred into Forth and copied to your boot partition, so that the SmartFirmware can read it. Therefore you have to call bootcreator:

Code Listing 1.1: Install the bootmenu

# bootcreator /etc/bootmenu /boot/menu

Note: Be sure to have a look into the SmartFirmware's settings when you reboot, that menu is the file that will be loaded by default.

For now, continue the installation with Rebooting the System.

1.  Rebooting the System

Exit the chrooted environment and unmount all mounted partitions. Then type in that one magical command you have been waiting for: reboot.

Code Listing 1.1: Exiting the chroot, unmounting all partitions and rebooting

# exit
livecd ~# umount -l /mnt/gentoo/dev{/pts,/shm,}
livecd ~# umount -l /mnt/gentoo{/proc,/sys,}
livecd ~# reboot

Once rebooted in your Gentoo installation, finish up with (Finalizing your Gentoo Installation).

Page updated May 9, 2011

Summary: Several bootloaders exist. Each one of them has its own way of configuration. In this chapter we'll describe all possibilities for you and step you through the process of configuring a bootloader to your needs.

Donate to support our development efforts.

Copyright 2001-2014 Gentoo Foundation, Inc. Questions, Comments? Contact us.