PowerBook G4 5,4
From NetBSD Wiki
User:Kernigh has a PowerBook G4 5,4 with NetBSD/macppc. This model has a 15-inch monitor and a 1.33 GHz processor. This page is about how to install and run NetBSD on this model. This information might also help with other PowerBook G4 models.
Major caveat now: The Xorg server of NetBSD 5.0 cannot transfer control back to genfb(4). If I try to exit the X server, then the machine hangs and the display begins to glow brighter and brighter. Then I must hold down the power button to force the machine to power off. Now I avoid exiting from X, and I just force the machine to power off. NetBSD cannot do a normal reboot or halt, unless I never start X. At the next boot, I must endure a filesystem check. (I have not yet checked NetBSD Problem Reports for this bug.)
Contents |
Overview of the machine
$ uname -a NetBSD ghostborough.local 5.0 NetBSD 5.0 (GENERIC) #0: Sun Apr 26 22:53:55 UTC 2 009 builds@b4.netbsd.org:/home/builds/ab/netbsd-5-0-RELEASE/macppc/200904260229 Z-obj/home/builds/ab/netbsd-5-0-RELEASE/src/sys/arch/macppc/compile/GENERIC macp pc
Hardware:
Config for X:
CPU speed
The model name (at the Open Firmware prompt and in the ofctl -p output) is PowerBook5,4. The model appears in the list of supported models with the note: "There may be some issues with the CPU speed"
This machine has a single Freescale MPC7447A processor at 1.33 GHz, but the processor seems to be stuck in "powersave" mode and runs at only 668.73 MHz (though this is plenty fast). NetBSD seems to have no way to set the processor to full speed.
Partitions of disk
Partition map (with 512 byte blocks) on '/dev/wd0c' #: type name length base ( size ) 1: Apple_partition_map Apple 63 @ 1 2: Apple_UNIX_SVR2 Swap 262144 @ 64 (128.0M) S1 SFS k0 (swap) 3: Apple_HFS Apple_HFS_Untitled_1 41680896 @ 262208 ( 19.9G) 4: Apple_UNIX_SVR2 NetBSD 20971520 @ 41943104 ( 10.0G) S0 RUFS k0 / 5: OpenBSD OpenBSD 54295616 @ 62914624 ( 25.9G)
NetBSD (in partition 4) shares the disk with Mac OS X (in partition 3) and OpenBSD (in partition 5). The NetBSD bootloader ofwboot.xcf lives in partition 3 with Mac OS X, because Open Firmware likes to load the bootloader from the first HFS partition.
Apple's Disk Utility created this partition map. I ordered Disk Utility to create a 20G HFS+ partition and leave the remainder of the disk as free space. For unknown reason, Disk Utility left an extra 128M of free space before the HFS+ partition. I installed Mac OS X to the HFS+ partition.
Then I used NetBSD pdisk to add a 10G root partition and convert the 128M to swap. Then I installed NetBSD. Finally I used the OpenBSD installer to add the OpenBSD partition and install OpenBSD.
Booting NetBSD
The bootloader is at hd:,ofwboot.xcf which is the /ofwboot.xcf file in the first HFS partition. The bootloader tries to boot /netbsd in the HFS partition by default; but I have /netbsd in the NetBSD partition, so I must specify hd:4/netbsd which is the /netbsd file in partition 4.
The machine boots Mac OS X by default; to boot NetBSD, I use Command-Option-O-F to reach the Open Firmware command and use the boot command
> boot hd:,ofwboot.xcf hd:4/netbsd
Installing NetBSD
I installed NetBSD 4.0 on this machine. Later I upgraded to NetBSD 4.0.1 and then NetBSD 5.0.
The PowerBook G4 is a "New World" machine with Open Firmware 3, which means that the normal sysinst procedure does not work. Instead, the user must carefully follow the instructions in INSTALL.html to manually create and format the partitions and /etc/fstab, and then use "Re-install sets or install additional sets".
The install procedure is strange because one must not write a disklabel to the disk. INSTALL.html says, "Do not use disklabel ... unless you will use one drive for NetBSD only and have another drive which will have the bootloader."
I prefer to install NetBSD from an HFS partition, which does not require me to burn or use a CD. I use an internet connection and Mac OS X to put a bootloader and install kernel in the first HFS partition; from there I can boot the install kernel and use the internet connection to fetch NetBSD. The internet connection is through the gem0 Ethernet interface.
Reinstall Mac OS X
If the HFS partition for Mac OS X fills the entire disk, then you need to erase the disk and reinstall Mac OS X on a smaller HFS+ partition so that you have free space for NetBSD. You can boot the Mac OS X installation DVD and use the Disk Utility to create one HFS+ partition that is smaller than the entire disk.
Obtain the bootloader and install kernel
- Boot Mac OS X.
- Use Firefox or any web browser to visit http://www.netbsd.org/mirrors/ and pick a mirror.
- Use Firefox or any FTP program to visit /pub/NetBSD/NetBSD-5.0/macppc and fetch these files:
- installation/ofwboot.xcf, the boot loader
- binary/kernel/netbsd-GENERIC_MD.gz, the install kernel for machines with Open Firmware 3
- Move these two files to the root of the HFS partition. INSTALL.html says, "Place ofwboot.xcf and the installation kernel netbsd-GENERIC_MD.gz at the top level of your Macintosh file system. That is, drag the two icons onto your hard drive icon (not the desktop). Make sure they're both on the same partition."
- Rename netbsd-GENERIC_MD.gz to a simpler name like install.gz
- Remember the location of the mirror, so that you can respond when the NetBSD installer asks where to obtain the sets.
- If the Ethernet interface uses DHCP, then you need to copy the IP address, subnet mask and DNS servers from DHCP, because the NetBSD installer still lacks a DHCP client. In Mac OS X, you can get these numbers from Networking in System Preferences. Keep these numbers on paper until the NetBSD installer asks for them.
Boot the install kernel
Reboot the machine and hold Command-Option-O-F to reach Open Firmware. (The INSTALL.html document has more details about "Getting to Open Firmware 3".) Then boot the install kernel with
> boot hd:,ofwboot.xcf /install.gz
(If the HFS partition is partition 3, then the full command would be boot hd:3,\ofwboot.xcf /install.gz. The backslash seems to be optional. If you omit the partition number, then Open Firmware picks the first HFS partition. The bootloader likes to load /install.gz from the same partition as the bootloader.)
Go from sysinst to pdisk
Carefully read the INSTALL.html section for "Running the sysinst installation program", especially step 6 about "Preparing a disk which will be used for Open Firmware 3 systems". Here is the procedure in brief.
- Use "Utility Menu" then "Run /bin/sh" to get the shell.
- Run pdisk /dev/wd0c now. (Can you run pdisk from the ramdisk? I do not remember exactly.)
- Create partitions with pdisk. Instructions are at NetBSD/macppc Partitioning HOW-TO.
In pdisk, you can use ? to get help, then you can use P or p to look at your disk.
Command (? for help): P Partition map (with 512 byte blocks) on '/dev/wd0c' #: type name length base ( size ) 1: Apple_partition_map Apple 63 @ 1 2: Apple_Free Extra 262144 @ 64 (128.0M) 3: Apple_HFS Apple_HFS_Untitled_1 41680896 @ 262208 ( 19.9G) 4: Apple_Free Extra 75267136 @ 41943104 ( 35.9G) Device block size=512, Number of Blocks=117210240 (55.9G) DeviceType=0x0, DeviceId=0x0
You can use c to create the NetBSD partitions. Foor this machine, I made one root filesystem (which will contain /usr, /home, everything). I copied 41943104 from the base of the Apple_Free partition, though I can use 4p instead. To make partition 2 into swap, I copied both the base and length values.
Command (? for help): c First block: 41943104 Length in blocks: 10G Name of partition: NetBSD Available partition slices for Apple_UNIX_SVR2: a root partition b swap partition c do not set any bzb bits g user partition Other lettered values will create user partitions Select a slice for default bzb values: a Command (? for help): c First block: 64 Length in blocks: 262144 Name of partition: Swap Available partition slices for Apple_UNIX_SVR2: a root partition b swap partition c do not set any bzb bits g user partition Other lettered values will create user partitions Select a slice for default bzb values: b
Finally, you must use w to save the partition map and q to quit pdisk.
Format the NetBSD partitions
After you quit pdisk, you return to the shell that you launched from sysinst.
- Run disklabel wd0 to see what partitions you have. The disk actually has no disklabel; NetBSD instead loks at the Apple_UNIX_SVR2 partitions in the Apple partition map and uses the information to produce a fictitious disklabel.
- Run newfs /dev/wd0a to format the partition.
- Run mount /dev/wd0a /mnt to mount that partition.
- Create a /mnt/etc/fstab for the 4.2BSD and swap partitions. INSTALL.html shows how to use mkdir and cat to create the fstab. If you forgot how to make an fstab then there is no help from the installer. You need to print out the relevant part of INSTALL.html, or make some notes about fstab before you boot the installer, or use a web browser from a second computer.
I had only two partitions so here is my fstab.
/dev/wd0a / ffs rw 1 1 /dev/wd0b none swap sw 0 0
If you have more 4.2BSD filesystems, then you also need to newfs them, add them to fstab and create their mount points, as INSTALL.html explains.
Install the sets
- Run umount /mnt to unmount the filesystem.
- Run exit to leave the shell and return to sysinst.
- From sysinst, you can use "Re-install sets or install additional sets" to install the sets. Now the installer will guide you.
- Follow the instructions in INSTALL.html for "Making the device nodes"; but you might find that sysinst already created the device nodes so that you can skip this step.
Boot NetBSD
From OpenFirmware, if you do boot hd:,ofwboot.xcf, then the bootloader will try to boot /netbsd from the HFS partition. There is more convenience to have /netbsd in the root NetBSD partition, which is where sysinst always installs the kernel.
If the root NetBSD partition is partition 4, then this command will boot the kernel. For more help, read ofwboot(8.macppc).
> boot hd:,ofwboot.xcf hd:4/netbsd
NetBSD will go to single-user mode. You need to do the usual configuration for a new NetBSD system (like useradd the first user, and edit /etc/rc.conf).
