Summary: This post explains the four easy ways to repair corrupt HFS file system. This is purely an information based article.
Tech-savvy Mac users often experiment with their machines in order to enhance their knowledge. In the process, they sometimes inadvertently cause damage to the Mac file system which can lead to temporary or even permanent data loss. Consider this sample scenario: suppose you installed Linux or Windows OS one of your Mac volumes, but later while trying to upgrade it to a more recent version, you experienced errors resulting in damage to the underlying Mac HFS file system. What would you do to repair HFS file system on your Mac at your end?
This post tries to answer the above question through four fairly simple solutions which you can attempt on own without having to rush off to the Apple service center. Let’s look at each:
(1) Format the drive & restore Time Machine backup
The safest and simplest way to repair Mac drive that has corrupt HFS file system is to completely format it and restore the data on it through a recent Time Machine backup. Follow the steps below:
i. Insert OS X CD / DVD / USB and hold down the C key while the Mac is starting
ii. Go to Utilities -> Disk Utility
iii. Select Macintosh HD on the sidebar
iv. Erase the drive by selecting the ‘Erase’ option
v. Close Disk Utility
vi. Go to Utilities -> Restore Time Machine Backup
vii. Follow the steps indicated therein
If this doesn’t seem to fix the issue or you experience errors in any step, try the next fix.
(2) Repair Mac with Ubuntu CD
Another way to fix corrupt HFS partition is by using Ubuntu CD in combination with an active Internet connection (wired connection is preferred since Wireless won’t work while booting with Ubuntu CD). Here’s how:
i. Use Mac command line to disable journaling on the affected partition. For this, type sudo diskutil disableJournal /dev/disk0s2 on Mac command line, where disk0s2 is the affected partition’s name. If you’re unaware of the partition’s name, use the ‘df’ command to find it; it should be mounted on ‘/’.
ii. Insert the Ubuntu CD and hold down the C key while your Mac starts up
iii. Once Mac boots from the CD, connect it to the Internet. Thereafter, enable Universe packages using ‘Software Sources’ and then install hfsprogs package through the command sudo apt-get install hfs progs. This will enable you to check and repair the HFS+ partitions.
iv. Now you’ll need to perform an fsck check on your Mac partition. For this, first find the Mac device through fdisk command and then perform fsck on it.
v. Once the Mac partition or volume is repaired, re-enable journaling on it through the sudo diskutil enableJournal /dev/disk0s2 command.
If this doesn’t work too, then go for the next fix.
(3) Repair Mac drive with FSCK command
To use the fsck command, you’ll need to pull up the Mac shell. Also, you will need the name of the partition or drive on which the command needs to be executed. Follow the steps listed below:
i. Power on Mac and hold down the Apple key + s on its keyboard; this should open the text-based Mac shell we need
ii. Type the command fsck_hfs -fy /dev/disk0s2 in the shell where disk0s2 is the affected disk / partition
iii. Press ‘Enter’ key. After a few minutes, the command should complete its task and end with the message “disk modified”
iv. Issue ‘reboot’ command to restart the Mac If it still doesn’t work, try the same procedure with the command fsck_hfs -fry /dev/disk0s2.
(4) Mount Broken Partitions
If the disk utility and fsck command are unable to fix a broken Mac partition, try to force mount the partition manually. Thereafter, use Finder to access it and copy all data from it to a safe location. Once you have all your data safe, erase it and restore from Time Machine backup.
Here’s how you can manually mount the corrupt volume / partition:
i. Type ‘df’ in the terminal to know the name of the damaged partition
ii. Then type the following in the terminal:
- sudo mkdir /Volumes/broken
- sudo mount -t hfs /dev/disk0s2 /Volumes/broken
where disk0s2 is the affected partition
The first command line above creates the mount point for the drive and the second line mounts the drive manually. It is advisable to mount the drive in read-only mode. For this, insert an -o rdonly into the mount command line.
Note: This method should only be used as a last resort.
We hope that at least one of the above-mentioned tips will help you fix your broken Mac HFS partitions. However, if none of them work, then stop using the hard drive immediately, and take it to the nearest Apple service center for an expert opinion.