Recover from a single-user password-protected boot

Sep 07, '04 08:40:00AM

Contributed by: dolfs

I recently was faced with a hanging login window on boot. After reading, it seemed the netinfo db was correcupt and I needed to boot single-user to fix it. When I tried, it was asking for a password. Using the install disk to reset the password did not work. What was going on?

After a lot of reading and inspecting found out that I had (a while ago) made an error adding a logouthook in the /etc/ttys file and instead of adding the -LogoutHook etc stuff before the closing quote of the loginwindow.app, added it after. The net result was that the "secure" option on the console was not seen anymore and a password was required.

Problem 1 How to even be able to check files on the machine?

The answer: Boot from CD and right after the gray screen appears, but before the Apple logo does, hold down command-S and boot in single user mode from the CD. Once there, issue this command:

mount -t hfs /dev/disk0s9 /Volumes
Your file system is now mounted on /Volumes and you can do some primitive stuff to it. You do not have editors available (ed is there, but /tmp is not writable). You can, however, cat files and inspect them. I used sed to edit the problem away (because it does not need a temp file). Now I could boot in single-user mode without the CD. If you need to mount multiple partitions, you need more directories for mount points. You can't create them, though, because the root file system on the CD is read-only. Here is the trick (instead of the above command):
mount -t synthfs /dev/null /Volumes<br>
mkdir /Volumes/m1<br>
mkdir /Volumes/m2<br>
mount -t hfs /dev/disk0s9 /Volumes/m1<br>
Additional disks can be mounted on /Volumes/m2, and if you need more, create more directories. The synthfs is a file system that cannot hold files, just directory structures, but that is all you need here.

Problem 2 Restore a good netinfo database. The OSXFAQ Mac OS X UNIX tip of the day from June 28th gives instructions that worked well for me.

Problem 3 Upon multi-user boot, the setup assistant runs.

I did not want to go through that, in particular because I did not know for sure the user directories would not be wiped (of course, I did not have a real current backup). The solution is to create a file like this:
touch /var/db/.AppleSetupDone
That's what did it for me.

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040905055904855