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:

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.

  1. Download the installer .iso. I used this one.
  2. 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.
  3. 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
  1. 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
  1. 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!

  1. 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.

  2. Now you need to identify a few things using the devalias command. Type devalias 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 named hd? 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!

  3. 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

  1. 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.

  2. Execute the pdisk command. Your command will look something like pdisk /dev/rwd0c. In fact that might be exactly it, but to be sure you can look through the output of dmesg or ls /dev. Keep in mind that this is the same drive referred to as hd in Open Firmware and that the partitions you create here will map to, for example, hd:2 or hd:3 when you get around to the final boot configurations.

  3. You can experiment with pdisk and partitioning schemes but for simplicity’s sake let’s say you initialize a new partition map with the i command and then create a small 4MB partition with the C command, setting the type to Apple_HFS. You then create another partition with the c 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 as hd:2 in Open Firmware and the rest of the disk where your system installs as hd:3. Be sure to read a more detailed description of this step here. You can also create other parititions. See here for another example.

  4. Run newfs on the partitions you just created. You get the letters from pdisk. In my case of just one partition I just needed newfs /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.

  5. 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
    

  6. If you started out in the installer then exit will get you back in. If you initially dropped into a shell execute sysinst to get the installer screen.

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

  8. 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.

  9. 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:

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:

At this point you now have a NetBSD system perfectly designed to foster any professional, hobby, or research activity you wish. Enjoy!

References

posted at: 14:59 by: Adam Russell | path: /netbsd | permanent link to this entry