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.
In fact, Disk Utility does use fsck to check the disk in question. "Verify Disk" uses
while "Repair Disk" runs
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.