Handbook:PPC/Installation/Bootloader

From Gentoo Wiki
Jump to: navigation, search
Other languages:
Deutsch • ‎English • ‎español • ‎日本語 • ‎한국어 • ‎polski • ‎русский • ‎українська • ‎中文(中国大陆)‎
PPC Handbook
Installation
About the installation
Choosing the media
Configuring the network
Preparing the disks
Installing stage3
Installing base system
Configuring the kernel
Configuring the system
Installing tools
Configuring the bootloader
Finalizing
Working with Gentoo
Portage introduction
USE flags
Portage features
Initscript system
Environment variables
Working with Portage
Files and directories
Variables
Mixing software branches
Additional tools
Custom package repository
Advanced features
Network configuration
Getting started
Advanced configuration
Modular networking
Wireless
Adding functionality
Dynamic management



Making a choice

Now that the 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 the kernel when the system is started. Such a program is called a boot loader.

The boot loader to use depends upon the type of PPC machine.

For a NewWorld Apple or IBM machine, yaboot needs to be selected. OldWorld Apple machines have two options, BootX (recommended) and quik. The Pegasos does not require a boot loader, but it is necessary to emerge bootcreator to create SmartFirmware boot menus.

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. Early in the installation, these locations have already been bind-mounted into the chroot.

To set up yaboot, either use yabootconfig to automatically create a configuration file or manually configure the boot loader. When installing Gentoo on a G5 (where yabootconfig does not always work), or when the system needs to boot from FireWire or USB, then manually configuring yaboot is mandatory.

Note
It is necessar 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):
FILE yaboot.confAdding genkernel boot arguments
###########################################################
## 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/kernel-genkernel-ppc-3.4.9-gentoo
  label=Linux
  root=/dev/sda3
  partition=3
  initrd=/boot/initramfs-genkernel-ppc-3.4.9-gentoo
  # You can add additional kernel arguments to append such as 
  # rootdelay=10 for a USB/Firewire Boot
  append="root=/dev/sda3"  
  read-only
##########################################################

Default: Using yabootconfig

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

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

root #emerge --ask sys-boot/yaboot

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

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

Verify the contents of /etc/yaboot.conf. When making 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 ya change is made to yaboot.conf, like when testing a new kernel, always remember to run ybin -v to update the bootstrap partition.

Alternative: Manual yaboot configuration

First, install yaboot on the system:

root #emerge --ask sys-boot/yaboot

An example yaboot.conf file is given below, but it will need to be altered to fit personal preference.

FILE /etc/yaboot.confExample configuration
## /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-3.4.9-gentoo
  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 yaboot.conf is changed after the Apple_bootstrap partition has been created, then update the settings by running ybin -v.

root #mkofboot -v

For more information on yaboot, take a look at the yaboot project.

Alternative: Using 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.

root #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-3.16.5-gentoo"

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

root #exit
cdimage ~#mkdir /mnt/mac
cdimage ~#mount /dev/sda6 /mnt/mac -t hfs
cdimage ~#cp /mnt/gentoo/boot/kernel-genkernel-ppc-3.16.5-gentoo "/mnt/mac/System Folder/Linux Kernels"
cdimage ~#cp /mnt/gentoo/boot/initramfs-genkernel-ppc-3.16.5-gentoo "/mnt/mac/System Folder"

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

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. When not using genkernel, select Options and uncheck Use specified RAM disk. If genkernel is used, 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 this is done, then the machine will boot into MacOS first and, during startup, BootX will load and start Linux. See the BootX home page for more information.

Important
Make sure to include support for the HFS and HFS+ filesystems in the kernel, otherwise upgrades or changes to the kernel on the MacOS partition will not be possible.

Alternative: Using Quik

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

First, install quik:

root #emerge --ask sys-boot/quik

Next, set it up. Edit /etc/quik.conf and set the image to the kernel that was copied to the boot partition earlier on.

FILE /etc/quik.confExample Quik configuration
# Example of quik.conf
init-message = "Gentoo Linux\n"
# This is the boot partition
partition = 2
root = /dev/sda3
timeout = 30
default = gentoo
# This is your kernel
image = /kernel-3.16.5-gentoo
  label = gentoo

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

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

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

Set to false to boot into OF, not all models can display the OF output:

root #nvsetenv auto-boot true

Check the quirks page, there are many variations here:

root #nvsetenv output-device video
root #nvsetenv input-device kbd

For SCSI:

root #nvsetenv boot-device scsi/sd@1:0

For ATA:

root #nvsetenv boot-device ata/ata-disk@0:0

Next, the first item is the path to the kernel, the second is the root partition. Append any kernel options to the end of this line:

root #nvsetenv boot-file /boot/kernel-3.16.5-gentoo root=/dev/sda4

Set this to bye for MacOS and boot for Linux:

root #nvsetenv boot-command boot
Note
It is also possible to change the 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 the 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 that it has installed the first stage QUIK boot block.

Note
If something has gone wrong, it is always possible to reset the PRAM back to the default values by holding down Command+Option+p+r before powering on the machine. This will clear the values set with nvsetenv and should allow the user to boot either a MacOS bootdisk or a Linux bootdisk.

Alternative: Using BootCreator

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

First make sure to have bootcreator installed on the system:

root #emerge --ask sys-boot/bootcreator

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

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

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

FILE /etc/bootmenuExample bootcreator configuration 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-3.16.5-gentoo video=radeonfb:1024x768@70 root=/dev/sda3
  
[SECTION]
Local HD -> Genkernel (Normal)
ide:0 kernel-genkernel-ppc-3.16.5-gentoo root=/dev/ram0
root=/dev/sda3 initrd=initramfs-genkernel-ppc-3.16.5-gentoo

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

root #bootcreator /etc/bootmenu /boot/menu
Note
Be sure to have a look into the SmartFirmware's settings when rebooting, that menu is the file that will be loaded by default.


Rebooting the system

Exit the chrooted environment and unmount all mounted partitions. Then type in that one magical command that initiates the final, true test: reboot.

root #exit
cdimage ~#cd
cdimage ~#umount -l /mnt/gentoo/dev{/shm,/pts,}
cdimage ~#umount -R /mnt/gentoo
cdimage ~#reboot

Do not forget to remove the bootable CD, otherwise the CD might be booted again instead of the new Gentoo system.

Once rebooted in the freshly installed Gentoo environment, finish up with Finalizing the Gentoo installation.