How to auto-run disk repair on OS X 10.8+ after each system crash?

Note: I am not looking for a manual solution.

  • 1
    Why - OSX will run it if needed? The file system is journalled so should not get corrupted
    – mmmmmm
    Apr 12, 2013 at 17:23
  • Are you wanting to auto-run Disk Utility after the computer starts up? If so there is likely some Automator steps you could take. Or are you wanting the computer to automatically boot into the Recovery Partition and run Disk Utility from that?
    – Shane
    Apr 12, 2013 at 18:00
  • What process will run the repair? The Mac mounts it's own filesystem before it knows whether it has crashed or not, so you could perhaps set your primary mount volume to be a small partition that runs fsck on the main partition and then commands a reboot to that partition. It seems like a lot of work for an edge case, but YMMV. I totally agree with @mark in this case. A journaled filesystem gets rolled to a consistent state at every mount whether you want it or not, so it's not clear what you mean by "auto-run disk repair" in the first place.
    – bmike
    Apr 12, 2013 at 18:48
  • I have an SSD and a problematic Mac, which gives a kernel panic every other day and if I do not run a disk repair by booting on the recovery I end-up having problems later. I just want to automate this, it seems crazy that Apple does not have this basic option that would fix the problems by default. Doing this manually if more than frustrating.
    – sorin
    Apr 15, 2013 at 12:18
  • 1
    You should be asking how to stop your kernel panics :-) have you run the Apple Hardware Test? Sounds like a hardware problem to me.
    – Josh
    Apr 15, 2013 at 13:18

3 Answers 3


I don't know if OS X already performs some extra checks after hard shutdowns or kernel panics. The verbose startup output looked the same after a normal restart, a hard restart, and a kernel panic:

The OS X volume is verified when starting up in safe mode:

Do you mean repairing the drive, repairing the main OS X volume, or running fsck? http://support.apple.com/kb/ts1417 recommends first starting up in safe mode (which includes repairing the OS X volume), or if that doesn't work, repairing the drive or OS X volume from Disk Utility on the recovery partition. It says that you don't normally need to run fsck with journaled HFS+ volumes.

From the diskutil man page:

repairDisk device
           Repair the partition map layout of a whole disk intended for
           booting or data use on a Macintosh.  The repairs further
           include, but are not limited to, the repair or creation of
           an EFI System Partition, the integrity of any Core Storage
           Physical Volume partitions, and the provisioning of space
           for boot loaders.  Ownership of the affected disk is
           required; it must be a whole disk and must have a partition


repairVolume device
           Repair the file system data structures of a volume.  The
           appropriate fsck program is executed and the volume is left
           mounted or unmounted at it was before the command.  Owner-
           ship of the affected disk is required.

You could try saving this as ~/Library/LaunchDaemons/repairdisk.plist, but I don't know how to run it only after unclean reboots (or why it would be needed).

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
<plist version="1.0">
        <string>yes | diskutil repairDisk /dev/disk0</string>

See diskutil list or df -h for the identifier of the drive.

diskutil repairDisk /dev/disk0 showed a warning like Repairing the partition map might erase disk0s1, proceed? (y/N), where disk0s1 is the EFI partition. But it seemed to do the same operations as repairing the drive from Disk Utility. repairVolume can't be used with the OS X volume after you have started up from it.

  • So, no solution yet? Clearly OS X does not seem to run as a server :) ... I am ondering if the server version does not have an option for this, both linux and windows do have this.
    – sorin
    Apr 15, 2013 at 12:21
  • Were you repairing the drive or the OS X volume from the recovery partition? If it was the drive, it can also be done with diskutil or Disk Utility after starting up normally.
    – Lri
    Apr 15, 2013 at 12:40

sudo nvram boot-args=-x would make OS X always start up in safe mode, which includes a disk check and repair.

Safe mode disables all startup items, some kernel extensions, and some peripherals, so you'd probably have to restart again in normal mode most of the time.

sudo nvram -d boot-args deletes the variable.

  • Hmm - this doesn't seem manual, but if the OP set a maintenance boot and then had a shutdown script to bypass the maintenance boot thus catching all uncommanded reboots this might be automatic depending on the skill of the programmer / scripter doing the work.
    – bmike
    Apr 12, 2013 at 18:49
  • So a LogoutHook? Aren't logouthooks still executed in SafeBoot? It is a function of the loginwindow process, which I'm sure is loaded in SafeBoot.
    – dpauken
    Apr 15, 2013 at 20:57

I don't know of anything, but I had a string of crashes. I made an appointment at Mac store, brought in my logs and they told me what the problem was. They also said that they usually don't do this unless you have an appointment. Be nice to them and they will bend over backwards to help.

  • 3
    This doesn't really answer the question
    – nohillside
    Apr 12, 2013 at 18:55
  • They helped me fix it. Mar 17, 2017 at 1:46

You must log in to answer this question.

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