Handbook:PPC/Blocks/Bootloader

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.

Introduction
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 and  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.

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 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 before proceeding. Now, install yaboot.

Now exit the chroot and run. First, the program will confirm the location of the bootstrap partition. When using the suggested disk partitioning scheme, the bootstrap partition should be. Type if the output is correct. If not, double check the file. yabootconfig will then scan the system setup, create 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.

Verify the contents of. When making changes to (like setting the default/boot OS), make sure to rerun   to apply changes to the Apple_Bootstrap partition. Whenever ya change is made to, like when testing a new kernel, always remember to run  to update the bootstrap partition.

Alternative: Manual yaboot configuration
First, install yaboot on the system:

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

Once is configured, run   to format the Apple_bootstrap partition and install the settings. If is changed after the Apple_bootstrap partition has been created, then update the settings by running.

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

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

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

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

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.

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:

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

{{File|/etc/quik.conf|Example Quik configuration|{{#tag:pre| init-message = "Gentoo Linux\n" partition = 2 root = {{#show: Handbook:{{ROOTPAGENAME}}|? root-partition}} timeout = 30 default = gentoo image = /kernel-{{#show: Handbook:{{ROOTPAGENAME}}|? kernel-version}} label = gentoo }}
 * 1) Example of quik.conf
 * 1) This is the boot partition
 * 1) This is your kernel

The {{Path|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.

{{RootCmd|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:

{{RootCmd|nvsetenv auto-boot true}}

Check the quirks page, there are many variations here:

{{RootCmd|nvsetenv output-device video}}

{{RootCmd|nvsetenv input-device kbd}}

For SCSI:

{{RootCmd|nvsetenv boot-device scsi/sd@1:0}}

For ATA:

{{RootCmd|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:

{{RootCmd|nvsetenv boot-file /boot/kernel-{{#show: Handbook:{{ROOTPAGENAME}}|? kernel-version}} root{{=}}/dev/sda4}}

Set this to bye for MacOS and boot for Linux:

{{RootCmd|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. 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 {{Key|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
First make sure to have bootcreator installed on the system:

Now copy the file into  and edit it to suit personal needs:

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

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: