2012-04-10

First-time-user boot trick for Mac OS X

So it is time to say goodbye to the Mac companion of the last year and upgrade to the newest. Old Faithful goes up for sale, but being the conscientious Mac user you are, you would like to hand it over with all the latest updates already installed. Normally this can be tricky to do and leave it set up so that when the new owner gets it they see the "Welcome" movie and can set things up their own way.

Here's what you need to do to achieve just that. Be warned, this is all text commands that are executed in OSX's single user mode – if the commandline scares you (as it should) then triple-check everything you are told to type (written in BOLD) before pressing the Return key.

First thing, of course, is to boot from your handy OSX installer, erase the hard drive, and install a fresh Mac OS. Endure the Welcome movie, make a new user account (call it 'Set Up'), log in and install all available updates either with Software Update or any stand-alone downloads that you had saved from last time. Once you have run Software Update and it tells you you are up to date, time to restart.

Be brave, my mouse-lovers! This won't hurt, I promise ...

(BTW: the '#' is the command prompt for single user mode. Type everything in after it, check your work, then press Return and go to the next step. If a command is long enough to wrap around to the next line in your browser, do not press Return, just keep typing. Remember, every new command starts at the #)

1 Press Command-S during startup to get into single user mode.

2 Check the filesystem:

# /sbin/fsck -fy

3 Mount the root partition as writable:

# /sbin/mount -uw /

4 Remove the hidden .AppleSetupDone file:

# rm /var/db/.AppleSetupDone

5 Reset the OS language choice.

# touch /var/db/.RunLanguageChooserToo

6a For Mac OS X 10.5 abd 10.6, do:

# launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist

For Mac OS X 10.7, do:

# launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist

Repeat for every user previously defined on the machine:

# dscl . -delete /Users/{username}

# dscl . -delete /Groups/admin GroupMembership {username}

6b For older versions of Mac OS X, do:

# rm -rf /var/db/netinfo/local.nidb

7 Remove the home directories of users. For every user do:

# rm -rf /Users/{username}

8 If applicable, remove already created files in root’s home directory,

# rm /root/.bash_history

9 Shutdown (or reboot to verify the procedure worked):

# shutdown -h now
-or-
# reboot

No comments: