Checking for errors on your HFS Plus filesystem (used by Mac OSX is very simple.
Just follow these easy steps and you’re on your way to ensuring you have a properly maintained filesystem.
How often should you do this? As often as you see fit. You might doe this once per month, or once per year. I just learned this little technique and it’s the first time I’ve run it ever, on my 3-year old MacBook Pro. Despite a few hard crashes and running the battery to zero quite a few times, my file system had ZERO errors.
The only reason I really did this, was to provide documentation for a client on checking their X-Servers for file corruption. They recently had two cases where the Data Center that houses their equipment lost power (UPS and Generators failed to pick up load after Utility power as interupted). Pathetic. At any rate, here is the 411:
Checking your HFS+ filesystem
Filesystem check on MAC OSX systems is performed using the fsck command, and it must be run in single-user mode following a system start/restart. Here are the simplest step.
Reboot system from console
While screen blanks and shutdown/restart chime is heard, hold down COMMAND-S.
This will boot the system in to single user mode. If you have succeeded in this, you will see a black screen running in terminal mode, with the following prompt:
Execute the filesystem check.
At the prompt, run fsck with the -y and -f options. This will remove the need for you to continue pressing the RETURN key if any nodes need repair.
:/root# /sbin/fsck -fy
** Root file system
Executing fsck_hfs (version diskdev_cmds-540.1~34).
** Checking Journaled HFS Plus volume.
The volume name is Macintosh HD
** Checking extents overflow file.
** Checking catalog file.
** Checking multi-linked files.
** Checking catalog hierarchy.
** Checking extended attributes file.
** Checking volume bitmap.
** Checking volume information.
** The volume Macintosh HD appears to be OK.
If the message “The volume … appears to be OK” does not appear, you will need to run the check again, and possibly repeated times until the message does appear, indicating a clean filesystem.
Reboot system into normal multi-user mode
Type reboot at the prompt. System will reboot into it’s normal mode.
It’s just THAT SIMPLE. Now run with the confidence that you have a solid filesystem under the awesome OSX Operating System.