ハンドブック:PPC/ブロック/ブートローダー

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Handbook:PPC/Blocks/Bootloader and the translation is 28% complete.


選択する

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 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 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)
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Disk /dev/sda: 120GB
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Sector size (logical/physical): 512B/512B
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Partition Table: mac
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Disk Flags:
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
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

重要
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.

重要
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.

ファイル /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-6.6.21-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

SCSI の場合:

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

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-6.6.21-gentoo root=/dev/sda4

Set this to bye for MacOS and boot for Linux:

root #nvsetenv boot-command boot
メモ
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.

メモ
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

重要
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.

ファイル /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
メモ
Be sure to have a look into the SmartFirmware's settings when rebooting, that menu is the file that will be loaded by default.