I mistakenly disabled all services in Yosemite (10.10), now it can't boot

Solution 1:

The command sudo launchctl unload -w /System/Library/LaunchDaemons/ will force-disable all launch daemons in /System/Library/LaunchDaemons/ and add respective entries in a disabled.plist. The command – entered accidentally – doesn't affect the "unforced" load state of a system daemon but overrides any existing state (loaded/unloaded). Removing the disabled.plist will restore an almost default system configuration – except those daemons or agents which have been forced to one of the two states in the initial configuration of the system or after the installation of a third-party app. This can be salvaged by either restoring the file from a backup or – partly – by copying a disabled.plist file from a similar system.

To get your system booting again you have to remove this special file in Recovery Mode.

  • Boot to Recovery Mode
  • Open Terminal in the menubar Utilities > Terminal
  • cd to /Volumes/NameOfMainSystemVolume/private/var/db/com.apple.xpc.launchd
    Replace NameOfMainSystemVolume by the name of your main volume (e.g. Macintosh\ HD)
  • list all files with ls -la. You will get a list containing ~20 files - all related to user IDs - and a large file disabled.plist (~10-15 KB)
  • remove the files with rm *.plist
  • Reboot, edit /private/var/db/com.apple.xpc.launchd/disabled.plist with sudo nano … and replace the existing content – probably some basic xml plist header and one or more daemon, which may have been added by the system while booting - by the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>com.apple.ManagedClientAgent.enrollagent</key>
        <true/>
        <key>com.apple.ftpd</key>
        <true/>
        <key>com.apple.rpmuxd</key>
        <false/>
        <key>com.apple.usbmuxd</key>
        <false/>
        <key>com.apple.mrt</key>
        <false/>
        <key>com.apple.stackshot</key>
        <false/>
        <key>org.ntp.ntpd</key>
        <false/>
        <key>com.apple.pacemaker</key>
        <true/>
    </dict>
    </plist>
    

    This should be the default content of the file in Yosemite. If you had installed additional 3rd-party apps, it probably contained more daemons previously. E.g I had to remove a Little Snitch and a XQuartz related system daemon to get a somehow "default" disabled.plist.