Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

How can I run fsck on a disk image via Mac Terminal?

Writer Emily Wong

I want to run fsck on a disk image before I use it to restore (replace) a corrupted volume. Using Terminal, what would be the proper command, syntax, and options for this operation?

I've just recently become acquainted with Terminal and line commands, so syntax and specific options aren't part of my computing vocabulary. I'm using Terminal 2.1.2, bash, OS 10.6.8.

Ultimately, I'm trying to restore an image to a secondary startup volume (external drive). The image is mounted on my desktop and I want to check it for errors before I use it. Disk Utility runs "repair disk" successfully but the integrity of the image is suspect.

1

1 Answer

You first need to associate the image with a device, then pick the correct fsck tool for the file system type and run it against the device.

Using hdid to map the dmg to a device:

# hdid Silverlight.dmg
/dev/disk1 Apple_partition_scheme
/dev/disk1s1 Apple_partition_map
/dev/disk1s2 Apple_HFS /Volumes/Silverlight

Note the Apple_HFS on disk1s2. Now we can fsck it:

# fsck_hfs /dev/disk1s2
** /dev/rdisk1s2 (NO WRITE) Executing fsck_hfs (version diskdev_cmds-540.1~34).
** Checking Journaled HFS Plus volume.
fsck_hfs: Volume is journaled. No checking performed.
fsck_hfs: Use the -f option to force checking.
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy