Checking Very Large Time Machine Volumes

Sep 06, '11 07:30:00AM

Contributed by: anscgn

Checking very large disk volumes with Disk Utility, especially Time Machine backup disks, can be painfully slow, taking many hours to complete, if it completes at all. This Terminal script vastly speeds up checking big volumes.

The tool behind Disk Utility's volume checking is fsck_hfs, which can also be run from the command line. The key to fast volume checking is a sufficiently large cache for the volume structures in memory, which Disk Utility obviously doesn't supply. This example uses 2.2 GB cache in RAM:

sudo fsck_hfs -f -c 2200m /dev/disk2

For a full 1TB Time Machine backup disk with many millions of files, this completes in about 10 minutes. A nice side effect is that this also puts less stress on the disk, as most reads are served from the cache.

Adding the little shell script below to your command line tools can make your life a lot easier. It takes the volume name as the single argument. The drive is unmounted during the check and remounted when finished.

#!/bin/bash
# Run a fast volume check on large Time Machine backup disks
export VOLUME=/Volumes/$1
echo "Determining disk device of $VOLUME"
export DISK=`diskutil info $VOLUME | sed -n '/ Device Node\:/s/.* \(\/dev\/disk.*\).*/\1/p'`
if [ "$DISK" = "" ]; then
  echo "Unable to determine device name!"
  exit 1
fi
echo "Performing filesystem check on $DISK"
diskutil unmountDisk $DISK
sudo fsck_hfs -f -c 2200m $DISK
diskutil mountDisk $DISK
I hope this will be useful for you.

[crarko adds: I haven't tried this, but the script looks sound.]

Comments (24)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20110829063745320