Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for the CLI equivalent of "Check disk" and "repair disk" in Disk Utility. I think fsck is involved but I don't know with which options, and if it's the only program run.

share|improve this question
up vote 5 down vote accepted

In fact, Disk Utility does use fsck to check the disk in question. "Verify Disk" uses

 /sbin/fsck_hfs -fn -x /dev/diskX

while "Repair Disk" runs

/sbin/fsck_hfs -fy -x /dev/diskX

These are the options used:

-f: 'f'orces a check, even if the disk seems to be clean

-n: 'n'ever attempts to repair any found issues

-y: says 'y'es to any question whether an issues should be repaired (as you might have guessed, -n and -y are exact opposites)

-x: generates output in XML format, which is parsed by Disk Utility

/sbin/fsck (as opposed to /sbin/fsck_hfs) is a wrapper that calls /sbin/fsck_XXX for the type of file system in question. You'll get more information in the man pages for fsck and fsck_hfs, from which I've borrowed a lot of information for my reply.

share|improve this answer
Hum, it seems that the disk utility is doing much more than the single fsck_hfs -fy. The former worked, while the latter failed with the message 'Disk reparation faild. Aborting.'. – gregseth Sep 5 '11 at 21:20

/usr/sbin/diskutil is what you are looking for.

Checkout man diskutil and look at the repairVolume command.

share|improve this answer
The advantage of using diskutil over fsck_hfs, is that where for example $ fsck_hfs -fy /dev/disk1s2 might not fix errors found "** Cannot repair volume when it is mounted with write access. ** The volume Backup could not be repaired.", where $ diskutil repairVolume /Volumes/Backup unmounts the Volume and fixes the problems found. – Pro Backup Jun 24 '12 at 11:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.