Running Apple Hardware Test When Your Hard Drive is Freaky Screwed

Modern versions of the OS X install CD contain two bootable volumes: one which runs the OS X installer, and one which runs the little-known Apple Hardware Test (AHT). You can read plenty about this elsewhere, but it's basically a way to, er, test your hardware that, usefully, doesn't need you to boot from your hard disk. This makes it useful for diagnosing problems with your machine when it's screwed in such a way that you can't boot from the disk, or use the disk at all.

Unless your disk is freaky screwed.

The way you get into AHT is to put the install DVD in, restart, and hold down option during boot. This brings you into the firmware Startup Manager; this scans for bootable volumes, shows you a list of them, and lets you pick which one you want to boot from. You just pick the AHT volume from this list and go. However, for this to work, Startup Manager has to be able to successfully scan for bootable volumes. It doesn't matter if it doesn't find your hard disk, but it has to finish the scan. It is possible for a hard disk to get screwed in a freaky way, such that the Startup Manager hangs while trying to check it, and thus never finishes its scan; you then can't get into AHT. I don't really understand how this could happen, but that's the state my disk is in. I suspect what's happening is that the disk subsystem is not signalling failure to the upper levels, it's somehow saying or implying that it's going very slowly, and the Startup Manager isn't smart enough to time out (although actually, it seems like it does eventually - but after quite a while).

So what do you do? Stop! Open Firmware time!

  1. Reboot or start up, and old down the command, option, O and F keys until you see the Open Firmware prompt come up.
  2. Insert install DVD.
  3. Type boot cd:4,\\:tbxi and hit return

Huge caveat: the '4' in the boot path indicates the partition on the install DVD that has the AHT in it. On the disc i have (came with a 15" G4 PowerBook - it says Z691-5221-A on the disc), this is partition number 4. It won't necessarily be 4 on any other version of the DVD! Infuriatingly, there's no way to look at the partition map from within Open Firmware, so there's no direct way to work out the partition number. However, you can use trial and error: pick a number (say, 1), call it n, and do dir cd:n,\\; this will give you a listing of the system folder on that partition, and if it looks good, go for it - if it doesn't, increment the number and try again.

Alternatively, if you think ahead, you can look at the DVD's partition table ahead of time using some kind of partition editing tool and write the partition number down (on the DVD, in permanent marker!).

Incidentally, the 'cd' means the optical drive, the \\ means the system folder (it's apparently equivalent to \System\Library\CoreServices\, although i'm not sure if it's a straightforward alias, or if Mac partitions have some way of specifying where their system folder is), and :tbxi means the file with type tbxi in the specified folder, tbxi being the magic type for bootable things.

If your hard drive is so screwed that it's giving AHT trouble, you can take it out of the picture altogether: in OF, do devalias hd somedevicenamewhichdoesnotexist (you can use that as-is, or use a shorter made-up device name). That will change the 'hd' device, which should be the hard disk, to be some nonexistent nonsense device, so AHT et al will ignore the real hard drive. This remapping is not permanent; when you reboot the machine, 'hd' will be the hard disk again.

Note that this doesn't work at all on Intel Macs. Suckers!

Props to Open Firmware (OF): An introduction for users, Recovering from a Blinking "?", Technical Note TN1061 - Fundamentals of Open Firmware, Part I: The User Interface, and NetBSD/macppc Frequently Asked Questions - Open Firmware, some of which were helpful. Extra super double props to Marc Herbert for the disk disabling and CD listing tricks.