RabbitFarm
2020-11-30
NetBSD/MacPPC 9.1 Installation on a Power Macintosh G4
Summary
A Power Macintosh G4 system is so named because it is powered by a PowerPC G4 CPU. The G4 chip powered several Apple systems for roughly a five year period (1999 - 2004). After the G4 era Apple used another PowerPC chip, the G5, and then transitioned to Intel based chips until 2020 with the introduction of ARM based systems. The history of the PowerPC family of chips and the collaboration between IBM, Motorola, and Apple is well worth reading up on if you are a fan of computing history.
In any event, Apple’s G4 based product line was very popular and there are many available cheaply on the second hand market. A PowerPC based Apple computer running NetBSD is a nice low cost platform for hobby and research projects!
Using some rough benchmarks my G4 system is about 15 times slower than a modern (lower end) dual core Windows 10 computer I have. Still, for computers which are roughly twenty years old (as of this writing) they are surprisingly performant. NetBSD is as lean and mean of an Operating System as you can get and you can be assured you are getting about as much computational horsepower as possible out of these machines.
An outline of what follows:
- The NetBSD installer can be booted from a variety of media. Here I describe using a USB drive. If you use a CD or other installation media these steps will still mostly be the same, albeit it with minor modifications.
- The target system had no OS on it at the time of installation. I do not describe the use of Mac OS X based tools on the target system. That is certainly a viable option but not one I am as familiar with.
- I assume that you will be using this system exclusively for NetBSD. Multibooting will either require either a different partitioning scheme than what I describe here or separate drives for each OS.
- Disk partitioning was done using pdisk in the installer.
- Once the installation is completed several steps still need to be done in order to have NetBSD boot normally. These systems boot using Open Firmware v3.0 which requires slightly different steps than systems with older Open Firmware versions.
- Make sure you do some reading and understand pdisk and Open Firmware before proceeding.
- You should absolutely expect to start/stop this process a few times as you hit snags and deepen your knowledge of the process. Consider this a good thing! You are getting a valuable experience in hardware and processes known to only a relatively small number of people!
Creating Bootable Media
I did not happen to have any CD-R media available so I decided to boot the installer off of a USB drive. Surprisingly this method is not covered at all in the official docs but I eventually found something done for FreeBSD which described the necessary process.
- Download the installer .iso. I used this one.
- Write this to a USB drive. On Linux or OS X you would use the
dd
command. On Windows there is a tool called rufus for doing this. I used an OS X computer for creating the installation media. - In the Terminal I used
diskutil
to confirm the device for my USB drive. In the output below you can see that/dev/disk8
is the USB drive I want to use.
$ diskutil list
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *121.3 GB disk0
1: EFI EFI 314.6 MB disk0s1
2: Apple_APFS Container disk1 121.0 GB disk0s2
/dev/disk1 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +121.0 GB disk1
Physical Store disk0s2
1: APFS Volume Macintosh HD 37.9 GB disk1s1
2: APFS Volume Preboot 44.1 MB disk1s2
3: APFS Volume Recovery 512.3 MB disk1s3
4: APFS Volume VM 2.1 GB disk1s4
/dev/disk2 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *2.0 TB disk2
1: EFI EFI 209.7 MB disk2s1
2: Apple_HFS FantomHD 2.0 TB disk2s2
/dev/disk3 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: CD_partition_scheme Audio CD *590.9 MB disk3
1: CD_DA 43.7 MB disk3s1
2: CD_DA 45.1 MB disk3s2
3: CD_DA 40.0 MB disk3s3
4: CD_DA 55.0 MB disk3s4
5: CD_DA 37.4 MB disk3s5
6: CD_DA 26.5 MB disk3s6
7: CD_DA 21.8 MB disk3s7
8: CD_DA 41.7 MB disk3s8
9: CD_DA 30.9 MB disk3s9
10: CD_DA 151.3 MB disk3s10
11: CD_DA 36.7 MB disk3s11
12: CD_DA 60.9 MB disk3s12
/dev/disk4 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *2.0 TB disk4
1: EFI EFI 209.7 MB disk4s1
2: Apple_APFS Container disk6 2.0 TB disk4s2
/dev/disk5 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: CD_partition_scheme *7.2 MB disk5
1: Apple_partition_scheme 6.2 MB disk5s0
2: Apple_partition_map 32.3 KB disk5s0s1
3: Apple_HFS magicJack 165.9 KB disk5s0s2
/dev/disk6 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +2.0 TB disk6
Physical Store disk4s2
1: APFS Volume LaCie - Data 644.0 GB disk6s1
2: APFS Volume Preboot 81.0 MB disk6s2
3: APFS Volume Recovery 529.0 MB disk6s3
4: APFS Volume VM 6.4 GB disk6s4
5: APFS Volume LaCie 11.3 GB disk6s5
/dev/disk7 (disk image):
#: TYPE NAME SIZE IDENTIFIER
0: Apple_partition_scheme +18.0 MB disk7
1: Apple_partition_map 32.3 KB disk7s1
2: Apple_HFS Flash Player 18.0 MB disk7s2
/dev/disk8 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *4.0 GB disk8
1: EFI EFI 209.7 MB disk8s1
2: Apple_HFS Untitled 1 3.7 GB disk8s2
- The next step is to use the
dd
command to write the installer .iso to the USB drive.
$ sudo diskutil unmountDisk /dev/disk8
Password:
Unmount of all volumes on disk8 was successful
$ sudo dd if=NetBSD-9.1-macppc.iso of=/dev/disk8 bs=1m conv=sync
382+1 records in
383+0 records out
401604608 bytes transferred in 162.164966 secs (2476519 bytes/sec)
$ sudo diskutil eject /dev/disk8
Disk /dev/disk8 ejected
- Remove the USB drive, it is now ready to boot the installer.
Booting the installer
Ok, this is perhaps the trickiest part because the information anyone reading this might need most likely will vary!
Put the USB drive into one of the Mac’s USB ports. Power on the system and hold down the CMD+Option+O+F keys until you are dropped into the Open Firmware prompt.
Now you need to identify a few things using the
devalias
command. Typedevalias
and hit enter and inspect the output. Can you see the USB devices? You might see two, one for your keyboard and the other is your drive. Can you see one namedhd
? That is your harddrive. You might havew multiple harddrives installed though. Which one do you plan on installing the system on? In the References section at the end of this article check out and read the Open Firmware pages I link to. Consider this required homework for a successful NetBSD/MacPPC installation!After understanding the device IDs for your USB drive with the installer and the drive you will be installing to you can boot with a command that looks like this:
boot usb1/disk:,\ofwboot.xcf netbsd.macppc
If this is successful you should see a bunch of boot messages and then the initial installer screen.
If you’ve made it this far, to a booted installer, savor your success before moving on to the next step.
Partitioning
In the installer menu choose the option to drop to a shell. Alternatively you could have chosen to drop to a shell immediately before the installer fully loads. Either one is fine. If you chose to drop to a shell instead of the installer you will need to run the
sysinst
command when you are done partitioning to get back to the installer.Execute the
pdisk
command. Your command will look something likepdisk /dev/rwd0c
. In fact that might be exactly it, but to be sure you can look through the output ofdmesg
orls /dev
. Keep in mind that this is the same drive referred to ashd
in Open Firmware and that the partitions you create here will map to, for example,hd:2
orhd:3
when you get around to the final boot configurations.You can experiment with
pdisk
and partitioning schemes but for simplicity’s sake let’s say you initialize a new partition map with thei
command and then create a small 4MB partition with theC
command, setting the type to Apple_HFS. You then create another partition with thec
command that uses up the rest of the disk. You can see the length of the unused space and just set the partitition size to match. If done this way on a system with a single hard drive you can refer to the first small Apple_HFS partition ashd:2
in Open Firmware and the rest of the disk where your system installs ashd:3
. Be sure to read a more detailed description of this step here. You can also create other parititions. See here for another example.Run
newfs
on the partitions you just created. You get the letters from pdisk. In my case of just one partition I just needednewfs /dev/rwd0a
but be sure to do them all if you create others. The Apple_HFS partition will be handled later. That is your boot partition and requires more work.Write an /etc/fstab file. Here is what I did but you will need more if you created other partitions. This also assumes that your root partition is the a partition, which it almost surely is!
$ mount /dev/wd0a /mnt $ mkdir /mnt/etc $ ed /mnt/etc/fstab a /dev/wd0a / ffs rw 1 1 . wq $ umount /mnt
If you started out in the installer then
exit
will get you back in. If you initially dropped into a shell executesysinst
to get the installer screen.I did a network install. I went into the utilities menu and set a static IP for the ethernet interface. The installer does not seem to have a dhcp option. If you do not know the name of your ethernet interface inspecting
ifconfig
output in the shell would help here. A few times during this I used the installer’s utilities menu to drop to a shell to get additional information.Most instructions say to go straight to the Re-install or install additional sets option but this did not work for me. I got an error saying that no root partition could be found. I resolved this by choosing the first “install” option and making sure that my root partition had a proper mount point of
/
set and then saved and exited, ignoring the warnings about overlapping sectors. I then went back to Re-install or install additional sets and did a Full Installation via FTP.Assuming the installation exits OK (and it really should unless you run out of disk space or lose your network connection or something else similarly catastrophic) you are now able to proudly say you are about 75% of the way done. Savor the milestone! Take a break if needed.
Setting up a bootable system
You will still need to boot from the USB drive. Assuming you are still in the installer, exit and reboot
the system. Do the four fingered salute of CMD+Option+O+F and get revisit our new friend Open Firmware.
In Open Firmware let’s get back into our system with boot usb1/disk:,\ofwboot.xcf hd:3,/netbsd
. hd:3
is our newly installed NetBSD system which we are booting using our installer. We want to boot off that Apple_HFS partition instead!
This initial boot of your new system will be in Single User/Read Only mode.
You may need to export TERM=vt100
before using the shell
For whatever reason the Full Installation did not install pkgsrc
which is necessary to get some required utilities for completing the process.
The pkgsrc installations steps are here but to summarize what I did:
- Mount the filesystem in read/write
mount -uw /
- Make sure that my network interface was still configured as before.
- Manually ftp and install pkgsrc as described in the previous link.
- Install hfsutils.
# cd /usr/pkgsrc/sysutils/hfsutils # make # make install # make clean
- manually ftp the bootloader ofwboot.xcf
# ftp https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.1/macppc/installation/ofwboot.xcf
# hformat /dev/wd0d # hcopy ofwboot.xcf :
- In that last step you can use
disklabel
to confirm the Apple_HFS partition.
You can now get your system out of single user mode and set up networking with dhcp.
# cd /etc
# vi rc.conf
Add the following to your rc.conf. Come up with whatever creative hostname you like!
rc_configured=YES
wscons=YES
hostname=G4
dhcpcd=YES
Finally, reboot
and enter Open Firmware and set the following:
reset-nvram
setenv auto-boot? false
setenv boot-device hd:2,ofwboot.xcf
setenv boot-file hd:3,/netbsd
reset-all
And from now on you will be sent straight to the Open Formware prompt when you reboot your system. From there just type boot
and your NetBSD system will come up!
Next Steps
Some suggested things to do with your new installation:
- Read the The Guide! (Ignore anything non-MacPPC specific when it comes to booting though.)
- Read the afterboot manpage.
- In particular, if you are new to NetBSD make sure you know how to install software with pkgsrc!
- Add additional users
- Set up sshd to remotely connect
- Configure a GUI Environment
At this point you now have a NetBSD system perfectly designed to foster any professional, hobby, or research activity you wish. Enjoy!
References
- The official installation guide.
- A summary of commonly used Open Firmware commands.
- Installation review for a similar G4 system.
- The best MacPPC installation report I’ve seen yet.
- An excellent tutorial on installing on Power Macintosh G4s.
posted at: 14:59 by: Adam Russell | path: /netbsd | permanent link to this entry