Handbook:PPC/Blocks/Bootloader

From Gentoo Wiki
Jump to:navigation Jump to:search
This page contains changes which are not marked for translation.


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, grub needs to be selected. OldWorld Apple machines havs one option: BootX. The Pegasos does not require a boot loader, but it is necessary to emerge bootcreator to create SmartFirmware boot menus.

Default: Using GRUB

Installation

root #emerge --ask sys-boot/grub

Setup bootstrap partition

First, prepare the bootstrap partition that was created created during the preparing the disk step. Following the example, this partition should be /dev/sda2. Optionally, confirm this by using parted:

Replace /dev/sda with the correct device if required.

root #parted /dev/sda print
Model: ATA Patriot Burst El (scsi)

Disk /dev/sda: 120GB

Sector size (logical/physical): 512B/512B

Partition Table: mac

Disk Flags:

Number  Start   End     Size    File system  Name       Flags
 1      512B    32.8kB  32.3kB               Apple
 2      32.8kB  852kB   819kB   hfs          bootstrap  boot
 3      852kB   538MB   537MB   ext4         Boot
 4      538MB   54.2GB  53.7GB  ext4         Gentoo

In this output, partition 2 has the bootstrap information so /dev/sda2 is the correct path to use.

Format this partition as HFS using the hformat command which is part of the sys-fs/hfsutils package:

root #dd if=/dev/zero of=/dev/sda2 bs=512
root #hformat -l bootstrap /dev/sda2

Create a directory to mount the bootstrap partition and then mount it:

root #mkdir /boot/NWBB
root #mount --types hfs /dev/sda2 /boot/NWBB

Setup GRUB

root #grub-install --macppc-directory=/boot/NWBB /dev/sda2

If it installs without errors, unmount the bootstrap:

root #umount /boot/NWBB

Next, bless the partition so it will boot:

root #hmount /dev/sda2
root #hattrib -t tbxi -c UNIX :System:Library:CoreServices:BootX
root #hattrib -b :System:Library:CoreServices
root #humount

Finally, build the grub.cfg file:

root #grub-mkconfig -o /boot/grub/grub.cfg

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-6.6.21-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-6.6.21-gentoo "/mnt/mac/System Folder/Linux Kernels"
cdimage ~#cp /mnt/gentoo/boot/initramfs-genkernel-ppc-6.6.21-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 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-6.6.21-gentoo video=radeonfb:1024x768@70 root=/dev/sda3
  
[SECTION]
Local HD -> Genkernel (Normal)
ide:0 kernel-genkernel-ppc-6.6.21-gentoo root=/dev/ram0
root=/dev/sda3 initrd=initramfs-genkernel-ppc-6.6.21-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.