Installing NetBSD Power Macintosh Machines

  1. 1.0 Preparing the disc (skip this part if install on OF 1.0.5 as it will …
    1. 1.1 Booting the installation cd.
    2. 1.1.1 Things to remember about the installer
    3. 1.2 Setting the boot sequence.
      1. 1.2.0 Longer, better method
      2. 1.2.1 Simple boot method
      3. 1.2.2 Outdated method
      4. 1.2.3 Single User Boot
  2. 2.0 Configuration
    1. 2.1 CPU Optimization
    2. 2.2 OpenFirmware Colors
    3. 2.3 Kernel Config
    4. 2.4 Mounting AppleParitionMap? formated drives under i386
  3. Other stuff…

1.0 Preparing the disc (skip this part if install on OF 1.0.5 as it will only support partition 0 bootstrap)

First in OS X you need to format the drive with 1 UFS partition and no classic drivers, make sure you set the partition map as "Apple Partition Map".
Then go to the terminal and type :

$ pdisk /dev/disk3

Then create a partition map that's something similar to this one:

Partition map (with 512 byte blocks) on '/dev/disk3'
 #: 		type name	length		base ( size )
 1: Apple_partition_map	Apple			     63 @ 1      
 2:           Apple_HFS	hfs_boot		   4096 @ 64		  (  2.0M)
 3:     Apple_UNIX_SVR2	canaille		7937235 @ 4160	  (  3.8G) S0 RUFS k0  /
 4:     Apple_UNIX_SVR2	swap			1572864 @ 7941395 (768.0M) S1  SFS k0  (swap)

Now format that drive:

$ newfs /dev/disk3s3 & newfs_hfs /dev/disk3s2 & sync & sync

You need to put the 'ofwboot.xcf' bootstrap on the HFS partition. So mount it and copy it

$ mkdir /Volumes/hfs_boot & mount /dev/disk3s2 /Volumes/hfs_boot

Get the ofwbooot.xcf file from the installation CD:

$ cp /Path/to/ofwboot.xcf /Volumes/hfs_boot/ofwboot.xcf

1.1 Booting the installation cd.

Go to the open firmware and type:

0 > boot cd:,\ofwboot.xcf netbsd.macppc

(cd:,\OFWBOOT.XCF NETBSD.GZ with macinbest's boot cd for "Old World" machines)

The cd should now boot.

Select reinstall sets. Use customs sets, otherwise the installer will format the drive with disklabel which will render the HFS bootstrap useless.

1.1.1 Things to remember about the installer

Backspace won't work in the shell unless you do:

# stty erase ^? (^H on the Gigabit G4, just hit your backspace key)

1.2 Setting the boot sequence.

1.2.0 Longer, better method

See this post: http://mail-index.netbsd.org/port-macppc/2005/02/28/0014.html and create the bootbsd.of file on the hfs_boot partition. Make sure to set the boot partition properly. This technique allows for better flexibility with some hardware bugs (this one corrects some video issues). It can be used to slow down the boot process of machines that have drives with high spin up delays.

Once you have the bootbsd.of copied, do this in the OF:

0 > boot hd:,\bootbsd.of
# If it worked
0 > setenv boot-device hd:,\bootbsd.of
0 > setenv boot-command boot
0> setenv auto-boot? true

1.2.1 Simple boot method

0 > boot hd:,\ofwboot.xcf hd:3,/netbsd 
# Or
0 > boot hd:,\ofwboot.xcf

1.2.2 Outdated method

This method is out dated, see below. It is kept here because it could be useful on other macs

Go to the OF and type:

0 > setenv auto-boot? true
0 > setenv boot-device ide0/disk@0:2,\ofwboot.xcf
0 > setenv boot-file ide0/disk@0:3,/netbsd
0 > reset-all

1.2.3 Single User Boot

0 > boot hd:,\ofwboot.xcf hd:3,/netbsd -s

You should now be booting in your fresh NetBSD install.
If not, verify you've set the boot-device and boot-file properly and accordingly to your partitions.

2.0 Configuration

See Notes on Installing and Using NetBSD.

2.1 CPU Optimization

Add the following to /etc/mk.conf
For the PowerMac G4 and G3:

CFLAGS+=-mcpu=750 -mtune=750 -O2 -pipe -fforce-addr
CXXFLAGS+=-mcpu=750 -mtune=750 -O2 -pipe -fforce-addr
COPTS+=-mcpu=750 -mtune=750 -O2 -pipe -fforce-addr

PKG_OPTIONS.bash=multibyte static # Important for bash

For the Cobalt Qube:

CFLAGS+=-march=mips3 -mtune=r5k -mabi=32 -O2 -fforce-addr
CXXFLAGS=-march=mips3 -mtune=r5k -mabi=32 -O2 -fforce-addr

2.2 OpenFirmware Colors

$ cd /root
$ wget http://trac.mlalonde.net/basedoc/computing/netbsd/cmap.tbz
$ gunzip cmap
$ chmod +x cmap
$ nano -w /etc/rc.local
$ /root/cmap 0 255:255:255 >/dev/null 2>&1 // Text Color
$ /root/cmap 15 0:0:0 >/dev/null 2>&1
$ /root/cmap 255 0:0:0 >/dev/null 2>&1 // Background

Note that if you're going to do this manually you should first set a text color that's *readable* with both black and white backgrounds

You can get the source here /basedoc/computing/netbsd/cmap.tbz or here http://geekrants.com/francis/archive/cmap.c

2.3 Kernel Config

Current configuration file for Fripouille (PowerMac G4 DigitalAudio).

2.4 Mounting AppleParitionMap? formated drives under i386

Use apmlabel (available in 5.0 as of this writing) to convert the APM to disklabel.

Other stuff…

Quick guide to install completely from CD if you can't mount the hfs partition on another volume to copy the OFWBOOT.XCF

Boot from the CD
Enter the shell
Use the pdisk utility on the CD to partition your HD with:
- HFS partion for ofwboot.xcf (2MB, MUST BE HFS)
- / FFS partition for NetBSD (rest of disk)
- swap partion (also FFS, 1-2x the size of your physical RAM)
newfs your / partition (ignoring errors) and mount it on /mnt
mkdir /mnt/etc and create an etc/fstab file for your / and swap partitions,
(using cat or echo since no editor will be available)
umount the HD, and invoke sysinstall
CHOOSE REINSTALL SETS, and proceed with the installation
when the install completes the re-enter shell and re-mount the HD
edit rc.conf using sed (still no editor available) to rc_configured=YES
shutdown system and reboot from the CD to the HD e.g.
0 > boot cd:,\ofwboot.xcf hd:3,/netbsd
Your system should now boot multi-user
pkg_add hfsutils via ftp (and rehash)
mount the CD on /mnt and cd /mnt
hformat and hmount your hfs partition, e.g.
hformat /dev/wd0d && hmount /dev/wd0d
hcopy ofwboot.xcf :ofwboot.xcf
This copies ofwboot.xcf from the CD to your HFS partion
Only now can OpenFirmware boot from your HD
reboot into OpenFirmware:
setenv boot-device hd:2,\ofwboot.xcf
setenv boot-file hd:3,/netbsd