Speeding Up fsck/fsck_hsfs on OSX

January 10, 2010

in sysadmin

Here’s a quick tip on how to make an fsck (or specifically an fsck_hsfs) run much faster. I learned this as part of debugging some corruption with the backup image on my Time Capsule.

/bin/fsck_hfs -f -d -c {%mem} /dev/rdisk{N}

where {%mem} is ½ to 1⁄3rd the amount of memory you have in your computer. If you need to determine the amount of memory in a machine from the command line, a great blog post on Mac OS X Command Line Goodies suggests you can use:

/usr/sbin/system_profiler SPHardwareDataType | grep Memory

For example, you can use -c 512m if you have a 1GB machine.

and

{N} is the correct device node. This command will show you the list of disk nodes:

diskutil list

For example, you might use /dev/rdisk0s2.

The -d turns on debugging and -f instructs fsck_hsfs to force a repair if it finds any problems.

In case you were curious, the -c setting is the part of the incantation that gives it its real magic. It lets the command cache a considerable amount of information in memory and that speeds up any scan a tremendous amount. If you ever run a disk repair from Disk Utility, you’ll notice the fsck_hsfs command it spawns lacks this option and hence is much slower.

Be Sociable, Share!

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: