Notice: fwrite(): Write of 1126 bytes failed with errno=28 No space left on device in /var/www/news.numlock.ch/public_html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php on line 42

WordPress database error: [Disk full (/tmp/#sql-temptable-20e-40598-4e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")]
SHOW FULL COLUMNS FROM `wp_options`


Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the math-captcha domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/news.numlock.ch/public_html/wp-includes/functions.php on line 6114

WordPress database error: [Disk full (/tmp/#sql-temptable-20e-40598-4f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")]
SHOW FULL COLUMNS FROM `wp_wfLiveTrafficHuman`

WordPress database error: [Disk full (/tmp/#sql-temptable-20e-40598-50.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")]
SHOW FULL COLUMNS FROM `wp_wfLiveTrafficHuman`

WordPress database error: [Disk full (/tmp/#sql-temptable-20e-40598-51.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")]
SHOW FULL COLUMNS FROM `wp_options`

How to “reset” a Mac OS X installation – A changelog by Daniel Mettler

How to “reset” a Mac OS X installation

Here’s how to “reset” an installed Mac OS X and virtually return to a “virgin” state with a welcome screen prompting the user to setup and customize his Mac OS X installation:

0. To reset a Mac OS X v10.7 Lion installation to factory default, check Mark’s comment @ Apple forum (basically, deleting users before booting into single user mode seems to do the trick). For Mac OS X v10.6 Snow Leopard and older, follow the procedure below.

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. a) For Mac OS X 10.5 ‘Leopard’ and newer, do:
# launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist
Repeat for every user previously defined on the machine (replace {username} with the real user name):
# dscl . -delete /Users/{username}
# dscl . -delete /Groups/admin GroupMembership {username}

5. b) For older versions of Mac OS X, do:
# rm -rf /var/db/netinfo/local.nidb
6. Remove the home directories of users. For every user do (replace {username} with the real user name):
# rm -rf /Users/{username}
7. If applicable, remove already created files in root’s home directory, e.g.
# rm /root/.bash_history
8. Shutdown (or reboot to verify the procedure worked):
# shutdown -h now
-or-
# reboot

That’s it! :)

[Update 20081106]: Thanks to Macs R We for the update 5 a) regarding Mac OS X Leopard! See the comments below for more information.

[Update 20090429]: Added “dscl . -delete /Groups/admin GroupMembership {username}” to 5b) as suggested by rello (see rello’s comment below)

[Update 20110731]: Some updates about resetting Mac OS X v10.7 Lion (unverified) and a clarification that rebooting at the end isn’t strictly necessary (just to verify the procedure worked). Thanks to David, Adrien and Adam for the hints.

45 Replies to “How to “reset” a Mac OS X installation”

  1. I use this page ALL THE TIME. Thank you so much for making such a concise reference available.

    This script needs updating for Leopard machines, because netinfo is gone. To “revirginize” Leopard machines, replace step 5 with the following commands:

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

    (This enables the “dscl” command to run. Note that this is NOT identical to the command that OS X will ask you to run if you try to use dscl without doing this first — the command OS X suggests does not actually work!)

    Then, for every user previously defined on the machine, issue:

    dscl . -delete /Users/{username}

    Then go back to step 6.

    As an aside, I have never seen a system where step 7 was either necessary or possible.

  2. Thanks a lot for the hint! I’m glad you like this post and of course I highly appreciate any feedback regarding mistakes, updates or inaccuracies!

    I’ve tried to update the list accordingly while keeping it as concise and clear as possible. I hope that’s OK, if not, please let me know.

  3. I would add to point 5 b) the following command to delete the user(s) from the admin group:

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

    For the rest the script is working fine.
    To have the real \out of the box experience\ I would like to be presented with the choice of the OS language.
    Is there anyone who knows how to do it?

  4. I’ve modified step 5b) as suggested. Thanks for the hints to rello and to @fjoachim for the review!

    Unfortunately, I’ve no idea how to reset the OS language choice. Anybody?

  5. hi (thanks!)

    trying to change a lost admin password, I went this way:

    apple + S

    * mount -uw /
    * rm /var/db/.AppleSetupDone
    * shutdown -h now

    Got only – as you say : a “virgin” state with a welcome screen prompting the user to setup and customize his Mac OS X installation.

    But that is not what I want. I recovered HD data to an ext drive via Firewire.

    How do I get around this forced OSK reinstall request?

    (Leopard environment)

    any help much appd

    /d

  6. Ouch. You used an inappropriate procedure to address a lost admin password. That is done by opening up the Reset Password utility on the boot DVD. All you do when you delete .AppleSetupDone is to enable the introductory movie and setup session at boot. But this session was not designed to be run when there were already users defined on the machine, with existing user files. I don’t understand what part of the system is demanding that you reinstall, or what it is saying. I’m not keen to bollix up any of my working machines by duplicating your commands just to find out.

  7. ok thanks anyway. I still need helpç how to get rid of the movie intro without reinstalling OSX since I have all my data intact on the MAcBook.

  8. My first thought would be to do what you did before, except that the middle command should be

    * touch /var/db/.AppleSetupDone

  9. Hi there. Looking to sell my machine. Just wondering here, because I’ve never done this before. If I follow steps 1 through 8, this will get me back to the first time this machine is turned on? With the intro movie, all data erased from HD, original components? This is what I am hoping anyway…

  10. Not exactly. Step 6 will erase most of your user data, but not necessarily all (especially if you are sloppy or migrated from OS 9 where it was customary to leave lots of junk at the root level). It will also not erase any third-party software you added to the machine yourself.

    These instructions are actually for something different than you want to do. The best way to do what you want is to boot from the original system disk or a commercial OS disk, visit Disk Utility first to run a “security erase / write zeroes once” on the hard drive, then run the system installation, then shut the machine off without booting it from the hard drive.

  11. Can I do this while keeping my System Preferences intact?
    I wanted to do this for a friend by setting up her Mac with some settings in Sys Prefs (like Display Color, Appearance, etc.)
    but wanted the Startup animation to show up and allow her to create a username, password, etc.

    Is there any way to pre-install software, settings, etc. but also have this startup animation/user configuration work?

  12. Reflect on the following question: are the preferences you are trying to set per-system or per-user? Not that many preferences are actually per-system, and some of them may actually be set to defaults by the installation process anyway. I would expect you might be able to predefine printers, disable automatic login, and define a Time Machine disk, and these may survive the “new machine experience” (or they may not). Certainly you would be able to define a monitor calibration profile, but I think you’d still need to have at least one user choose it after users are defined. And of course you could add software to Applications and Utilities that would stick around for everybody to use. But most preferences are personal settings, so you wouldn’t get to set them beforehand.

    If you’re a keyboard goddess, or real adventurous, you could try your hand at modifying the default new-user profile in /System/Library/User Template, but 1, that’s way beyond the scope of this project, and 2, you can expect it to get changed back every time you to a software update.

  13. Ok here’s my situation, I hope you can help me out. I have a late-2008 MacBook Pro running the current version of Leopard. Like I said in my previous post, I am looking to erase ALL data to get the computer back to original state (never been used). And on top of that I am also looking to reset the installation, so when I give this to my friend he can have the WHOLE experience. Now my problem is I don’t have the restore discs with me and my SuperDrive is currently not working. So is there anyway to get around these hurdles? Any help you can give me would be MUCH appreciated! Thanks.

  14. @Macs R We: Thanks a lot C. D. for answering visitor questions!

    @MBP: Well, if your SuperDrive currently isn’t working you could try to re-install Mac OS X from an external DVD drive (e.g. a USB drive) instead, as Macs R We suggested. To do this, you’ll need some kind of installation media though. Alternatively, you could follow the steps described in this post and try to find and erase/overwrite all private data.

  15. You’re going to need installation media, there’s no way around that — either the original system disks, or a commercial copy of Leopard. If you have another Mac, you can boot it into Target Disk Mode to use its DVD drive from the first Mac, OR you can boot the first Mac into Target Disk Mode to install Leopard onto its disk from the second Mac. The advantage of the second technique is that you can then proceed to apply all the software updates to that disk without ever actually booting from it, leaving the “movie experience” for your friend.

  16. >Unfortunately, I’ve no idea how to reset the OS language choice. Anybody?

    Sorry for posting to an old thread, but the answer to this question is as simple as:
    touch /var/db/.RunLanguageChooserToo

  17. Hi, I have just been given a 13 inch Macbook (2Ghz Intel, 2 gig ram) but the person who gave it to me can not find the original disc and I am keen to try and reset it to factory so I can just go through the set up process (I am brand new to Mac’s, could do this on a PC with my eyes closed.) I understand that the only way I can do this is to buy a new copy of, say Snow Leopard, and going through the boot from disc process. I do not have a problem with this but can this be done with the cheaper upgrade disc or do I need to buy a more expensive version? As I say, I am so new to Macs and would just like to go through the whole brand new experience. Thanks obviously if there is a simpler way I will go with that…can an apple store do it for example?

  18. Any compatible install DVD will do this job. It’s not advertised, but the “upgrade” Snow Leopard disc will install a working Snow Leopard on an empty drive, though my experience is that certain nonessential support files (in particular, help files) will be missing.

  19. Thanks Macs R We, really appreciate the advice. Happily my colleague has found the original discs so I should be able to a nice ‘restart’ with that. Thanks again.

  20. I just rebooted from Snow Leopard DVD, cleaned the hard disk and installed Snow Leopard. After 30 Minutes, you are asked to enter your language, WiFi or other network etc. – Then, I simple shut down the machine. Upon restart, it feels like a brand new machine – with the welcome video etc. The only thing is that you have to eject the dvd before shutdown…
    For me, this seems to be a more “secure” way, because the hard disk is totally cleaned before (and if you are paranoid and have a little more time, you can overwrite the hard disk up to 37 times with highly sophisticated special patterns that make all previous data vanish even more – absolutly useless, in my point of view)
    Greetings,
    Andreas

  21. The problem with erasing the hard drive as a clean-up, is the you also remove the Diagnostic partition. This is present on the MacBook Core 2 Duo and newer. The right way to erase a hard drive is therefore the command:

    diskutil eraseVolume JHFS+ \Name-of-the-hard-drive\ /dev/disk0s2

    which can be run from the Terminal when your are about to install Mac OS X again. Note that \disk0s2\ is an example of what device ID the Mac OS X can have. You have to run \diskutil list\ to ensure the device ID is right, but it usually is \disk0\ with partition \s2\.

  22. (Sorry! The text got badly formatted)

    The problem with erasing the hard drive as a clean-up, is the you also remove the Diagnostic partition. This is present on the MacBook Core 2 Duo and newer. The right way to erase a hard drive is therefore the command:

    diskutil eraseVolume JHFS+ ”Name-of-the-hard-drive” /dev/disk0s2

    which can be run from the Terminal when your are about to install Mac OS X again. Note that ”disk0s2” is an example of what device ID the Mac OS X can have. You have to run ”diskutil list” to ensure the device ID is right, but it usually is ”disk0” with partition ”s2”.

  23. Thanks for sharing your Snow Leopard installation experience, Andreas.

    And thanks, Johan, for the important caveat and hint regarding the Diagnostic partition!

  24. Hi

    This is really great–however–I seem to be having a problem doing this with Snow Leopard.

    I repair and upgrade macs as a little side business and yesterday a gentlemen dropped of his new Mac Pro–still in the box–and asked me to prep it (install additional HD’s, software etc).

    I have done all this and have done all the updates for it as well. I have created only one generic user and left the password empty.

    I want him to be able to power it up just like it was new but with all software and updates intact.

    My problem is/was that it told me there was no file named AppleSetupDone

    Any advice?

    Thanks!

  25. Hi I tried this and it worked! Yay me. But is there a way to retrieve the other accounts? or undo the reset?

    If not im screwed, but oh well.

  26. I tried the procedure and went in trouble from step 5:
    the following command did not work for me (Snow Leopard 10.6.3.1):

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

    instead I typed dscl and I entered in interactive mode:
    then typed the following commands :

    delete Local/Default//Users/{username}
    delete Local/Default//Groups/admin GroupMembership {username}

  27. schlivo

    since you didn’t include it in your reply I’m assuming you left off the ‘ &’ and the end of the command. That keeps the DirectoryService daemon running in the background while you issue the remaining commands.

  28. I have a macbook pro that has the same problen and all u have said does not work turn on comes to the screen will not load it is a 2008 with tiger on it thats strange put it does its 10.4. my osx has gotten broken now I dont no what to do the permission were changed while I was out of the country by my brother I installed some programs on it and when shutdown and next day went to load would not load what can I do. Please can you respond as soon as you can to this post thanks so much I just love my Macboiok

  29. Not working with 10.7 Lion.

    So far the dscl command is failing, error message about it not being able to stat the plist file (sorry for not copy-pasting the error message here :) This is booting into single user mode, not using the restore partition…

    Also, any idea about handing off an install of Lion which may (or may not) have your AppStore ID signature stored somewhere? Also, the restore partition seems to remember my WiFi network *and* password, which is also not so great if you’re selling the computer on…

  30. Color me unimpressed with the Lion instructions at Apple Discussions. I followed them to the letter (I also deleted the user’s homedir, which wasn’t mentioned), only to be told upon reboot when I started the file migration that I was trying to load a user ID that already existed. Happily, it gave me the choice of creating a new user or blowing away the old one, so that’s what I did.

    From further study of the Apple note on the subject, it looks like simply substituting one comment in the old Snow Lion regimen would have made this all work:

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

    instead of com.apple.DirectoryServices.plist — I only had one machine to upgrade, so I haven’t yet tried that.

  31. Is there any way to undo the .AppleSetupDone one because I didn’t mean to reset my mac and now i might have to go to the apple store to see if they can fix it.

    Looking for a quick answer before we go to the apple store.

  32. Hi , i did buy an used mac mini ,when trying to install leopard(no os)it is asking me for password ,same thing happen with command+s,tried command+option+o+f went to open firmware ;but still asking for password when writing a command.
    Please somebody help me,thanks and blessings in advance.

  33. When I was trying to do the launchctl load……. plist step, it came back with msg saying “Socket is not connected”. What does that mean and what should i do? I have OS X 10.6.8

Leave a Reply

Your email address will not be published. Required fields are marked *

30 + = 34

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Notice: fwrite(): Write of 1126 bytes failed with errno=28 No space left on device in /var/www/news.numlock.ch/public_html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php on line 42

Fatal error: Uncaught wfWAFStorageFileException: Unable to verify temporary file contents for atomic writing. in /var/www/news.numlock.ch/public_html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php:51 Stack trace: #0 /var/www/news.numlock.ch/public_html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php(658): wfWAFStorageFile::atomicFilePutContents() #1 [internal function]: wfWAFStorageFile->saveConfig() #2 {main} thrown in /var/www/news.numlock.ch/public_html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php on line 51