Major Corrections (to my own material below)! Please Check!

I can't resist adding a few specific commands to mcc's excellent writeup. This came up (for me) because I was trying to install a boot loader onto my PowerMac G4/500 AGP (single processor). Naturally, I found myself at several points staring at a machine that would obstinately only boot into what was the absolutely wrong partition. Sigh. So, in the hopes of sparing some of you the angst, here is what I have learned mucking about in Open Firmware.

WARNING! This information is presented for you to use at your own risk! Mucking around in Open Firmware can make your Mac unbootable! In other words, you should only try this if all else has failed. I take no responsibility for what happens to you.

To begin with, I must reiterate one of mcc's tips. To actually get into Open Firmware at boot time, you need to do one of two things. The first thing to try (and safest) is to hold down 'Command-Option-o-f' at boot (all four keys). This should bring you to OF. If not, reboot the machine, and as soon as you hear the startup chord, press and hold the programmer's switch (the convex button on the right, of the two just below the power switch on the case). If nothing happens after ten seconds, release the programmer's switch, then press it once and let go. The machine should boot into OF.

The most useful command I found, if everything hasn't gone south, is mac-boot. This will tell OF to attempt to find a MacOS bootable partition on an internal drive and boot from it. This is useful if, for example, you've used Startup Disk to set the startup volume to one that now doesn't work; the mac-boot command will usually get the Mac to boot into MacOS so that you can undo the Startup Disk setting.

If you need to boot off another device, here's the skinny. The command is boot . Open Firmware device paths are funny things. Here are some examples of aliases, which function as shortcuts to full device paths, that are present on the PowerMac G4:

  • ultra0: - this is the master drive of the first internal IDE controller (usually the Mac OS drive as it's shipped from the factory).
  • ultra1: - this is a slave drive on the same controller.
  • cd: - the cdrom (or DVD), as shipped.
  • zip: - the internal Zip drive as shipped.

These are (very, very) shorthand. As an example, the full OF device path to my primary IDE drive (referred to as ultra0 above) is:

/pci@f2000000/@d/mac-io@7/ata-4@1000/disk@0

Those handy aliases above were placed in my PowerMac G4 by Apple so as to not force their techs to need to remember the above monstrosity, especially since the path will change from machine to machine depending on its configuration. To get a list of the aliases on your machine, enter OF and type devalias and hit return.

Open Firmware looks for a boot script of type 'tbxi' on the partitions it finds on that device. If it finds one, it boots that partition immediately. You can force a specific partition by inserting the partition number immediately after the colon, remembering that partition numbers start at '1' not '0'. So, for example, to boot off the second partition of the slave IDE hard drive on interface 0, you'd use: boot ultra1:2

Useful, huh? :-) Okay, what else. It's possible you have a SCSI drive on your machine, attached to a PCI SCSI card like the Adaptec 2930. You can still get to this device from open firmware. You'll just need to specify the entire OF device path. To find the device path, use the command dev / ls. The spaces between the three terms are essential! This should produce an enormous listout of your hardware, done as a tree. At the root level (leftmost column) somewhere will be your pci bus, labeled something like pci@f2000000. Traverse the tree down from there until you locate the adaptec card (labeled either 'scsi' or 'adaptec'. The complete path can then be used to boot the machine, adding the requisite drive number on at the end. Note that you should first check devalias; it's possible there's an alias defined for it already.

If you think the machine has gone totally strange on you, the command reset-all will restore all settings as if you'd just powered on, and reboot the machine.

Here's a list of some commands:

  • setenv variable value: set an environment variable variable to value.
  • printenv variable: list out the contents of environment variable. With no variable, lists all.
  • devalias: print out list of current aliases
  • devalias device alias: create an alias for the device at OF path device
  • dev device: set the 'current device' to device
  • ls: list subdevices of current device (listing device '/' lists all)
  • properties: list properties of current device (Note:Potatoswatter informs me this should be .properties - note period!)

Hope this helps someone!


Sources include FAQs from the Linux on PowerPC Faq-o-matic, Yellow Dog Linuxand LinuxPPC, and mucking around with my PowerMac G4.