3

I'm ready to resell my Mac, and I'd like to prepare it for the new user, giving them factory-like out of box experience. Even better, I'd like the system to be fully updated, yet come up with no user accounts, starting into the initial setup as if one just unboxed it. Of course performing the updates and software preinstallation requires to set up a temporary user account :(

2
  • To be clear - the bundled apps of iLife and iWork in a factory build are special. Do you wish to remove them entirely, hack the activation to re-grant those apps to the new user (likely illegal and/or highly difficult) or just have the setup wizard walk the new user through the setup steps as opposed to have a proper "factory" image on the hardware?
    – bmike
    Commented Feb 17, 2016 at 15:02
  • @bmike "the bundled apps of iLife and iWork in a factory build are special" How? Commented Feb 18, 2016 at 6:26

2 Answers 2

3

The instructions below were tested on OS X 10.6 and 10.7.

Preflight

  1. Back up any data you wish to retain.
  2. Make backup copies of iLife applications (iPhoto, GarageBand, iMovie, iWeb, iDVD).
  3. Deactivate relevant licensed software such Adobe CS.
  4. Unregister the machine from your iTunes account.

OS Cleanup

  1. Boot from an external OS X install media, if you wish to completely wipe the hard drive. Boot from the recovery partition (hold ⌘-R on power-up) if you wish to retain the recovery partition as-is.

  2. If booting from external media, use the Disk Utility to repartition the hard drive with one partition. Note: With SSDs, you ideally should first use a utility that lets you do a secure erase of the medium instead.

  3. Use the Disk Utility to erase (zero out) the hard drive. This will take an hour or longer on a mechanical drive, and at least several minutes on an SSD. If it takes just a minutes, you didn't zero the disk!

  4. Reinstall the OS X. Create a user account called factory.

  5. Reinstall iLife either from media, or by copying it from the backup you've made in preflight.

  6. Perform all system updates.

Restoring the Out-Of-Box Experience

Boot into the single-user mode by holding down ⌘-S during boot. A bare console will appear in a dozen seconds or so.

  • Remount the root partition in read-write mode.

    /sbin/mount -uw /

  • Start the directory services.

    • OS X Lion and higher:

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

    Ignore the error related to com.apple.DirectoryServicesLocal.plist

    • OS X Snow Leopard:

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

  • Access the directory services command line utility and remove the factory user:

    dscl . (that's dscl, space, period)

    list /Users shows the user list. The factory user should be there. That's the only one we care about. The usernames starting with an underline, those are system accounts that have to be left alone. Same goes for the daemon, Guest, messagebus, nobody and root accounts.

    read /Users/factory GeneratedUID shows the UID of the user, we'll need it below.

    delete /Groups/admin GroupMembers <uid>, where UID is given above. Don't worry if you enter it wrong, you'll receive an error message. Press to go back and edit the command.

    delete /Groups/admin GroupMembership factory

    delete /Users/factory

    exit

  • Remove the factory's home folder.

    rm -R /Users/factory/

  • Remove the caches.

    rm -R /Library/Caches/* rm -R /var/vm/swapfile*

  • Remove the flag indicating that the initial setup has been done.

    rm /var/db/.AppleSetupDone

  • Reboot or shutdown.

    reboot or shutdown -h now

1
  • The launchctl and dscl steps doesn't seem to work in macOS 10.12, at least not in Recovery mode
    – MiB
    Commented Oct 13, 2017 at 1:53
2

If you're on 10.7 or later and you don't need to perform any updates or install any software, you should normally just erase and reinstall OS X from the recovery partition.

  1. Hold command-R on startup
  2. Erase either the OS X partition or the whole drive from Disk Utility. If you don't have an SSD, press the "Security Options..." button and choose the single pass option. If you have an SSD, the "Security Options..." button is grayed out, but http://support.apple.com/kb/ht3680 says that "a standard erase makes it difficult to recover data from an SSD".
  3. Choose Install OS X.

See these Apple KB articles:

I'm not sure if you should erase the whole drive or just the OS X partition. The Apple KB articles tell you to erase the "startup disk", which generally means the OS X partition. If you have other partitions like a Windows partition, you should probably erase the whole drive.

If you erase the whole drive, the recovery partition (which is hidden from Disk Utility) is also erased. If you don't restart, the contents of the recovery partition will stay in memory and you can continue to the step for reinstalling OS X, which will also create a new recovery partition. If you do restart, your Mac can still download the contents of the recovery partition from Apple's servers if it supports Internet Recovery mode.

1
  • "you don't need to perform any updates or install any software" Doing precisely the opposite of it is the raison d'etre of the question :) Perhaps I wasn't clear enough. Commented Oct 16, 2014 at 20:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .