On any Mac OS X box, you can enter single-user mode
by holding down command-S at startup. This gives you a root prompt and a read-only hard drive, from which you can commence your life of quiet desperation, er, troubleshooting.
Normally, you would do this to repair the drive:
# fsck -y
This is exactly equivalent to booting off the install CD and repairing your disk using Disk Utility. In Mac OS X, Disk Utility is a graphical frontend on top of fsck. It works just as well in single-user mode because the drive is mounted read-only, so there’s no chance of files being modified while the repair is running.
If fsck tells you that the file system was modified, reboot immediately:
# reboot
Repeat until fsck reports no errors. It is now safe to exit single-user mode and continue booting normally:
# exit
If you can not get to the login prompt, or your login window appears but shows no users and no username/password boxes, your NetInfo directory is probably corrupted. Reboot into single-user mode and trash it:
# cd /var/db/netinfo
# mv local.nidb local.nidb.corrupted
# reboot
Upon rebooting, Mac OS X will notice the missing NetInfo directory and will create a new blank one. This will not actually let you log in, however, since the new NetInfo directory contains no users. (Technically it contains a root user, but with login disabled.) Assuming you get to a login prompt, reboot once again into single-user mode and add a root password. This is trickier in 10.2 than it was in 10.1, but I believe this technique works in both (I’ve tested it personally in 10.2):
# SystemStarterWatch the status messages. When you see
Starting NetInfo, hit CTRL+C to get back to a prompt, then type:
# passwd root
Password: (enter new password)
Verify password: (re-enter new password)
# reboot
Here you are essentially hacking your way into your own computer by changing the root password. (And if root was previously disabled, this has the side-effect of enabling it.) Rebooting should get you to a login prompt where you can log in as root and get to work recreating your other users or recovering your data or whatnot.
(It should be noted that the above method will also work on anyone else’s computer, but don’t do that. If this scares you, install Open Firmware Password Protection, which is essentially a BIOS password for Macs, and prevents booting into single-user mode without a password.)
Another fun thing you can do is force your Mac to always boot into single-user mode, without holding down any keys at startup:
# nvram boot-args="-s"
# reboot
Your computer should always boot into single-user mode from now on. To put it back to normal:
# nvram boot-args=""
Again, you can do this on anyone else’s Mac too, but don’t do that.
§
I am no longer accepting public comments on this post, but you can use this form to contact me privately. (Your message will not be published.)
§
© 2001–9 Mark Pilgrim