This post will tell you how to repair / fix Mac HFS+ partition using Ubuntu CD (Live CD or Install CD).
What do you need to do this?
Ubuntu CD (I used Ubuntu 8.10 Desktop Edition Install/Live CD)
Mac
Internet Connection (Wired)
Few days back I had installed Debian 5.0 lenny on my MacBook. Because, I don’t have much hard disk capacity (only 80 GB), I had to delete the Linux partition (waiting for Ubuntu 9.04). I used BootCamp Utility (in Mac) to delete the Linux partition. It wipes off all the linux data & restores Mac partition (ex: I had 60GB Mac + 20GB Linux, After restore 80GB* Mac).
I was happy that it was restored. But, the partition had errors after restores. I was not able to copy/store the any data if it exceeds 60GB on Mac, it says the Mac startup disk is full. Then I realized that the Mac file system (i.e., HFS+) had errors. Yes, the Ubuntu CD is there to rescue me. Enough story… follow this to proceed…
1. Disable journaling on Mac parition before booting into Ubuntu CD
Use this command on your Mac terminal
- sudo diskutil disableJournal /dev/disk0s2
where disk0s2 is your Mac partition (use ‘df’ command to find out the root disk name, it should be mounted on ‘/’)
2. Boot from Ubuntu CD
Insert the Ubuntu CD, press ‘C’ on startup to boot from CD.
3. Connect to Internet & Install HFSprogs
After Boot connect to Internet, Yeah! I know the wireless won’t work now. I suggest you to connect from Wired.
I assume that you are connected to Internet now.
Then enable Universe packages using ‘Software Sources’.
Then, Install hfsprogs package
- sudo apt-get install hfsprogs
This will enable you to check & repair the HFS+ paritions.
4. Check & Repair
You need to do fsck check on your Mac partition. Use fdisk command to find the Mac device.
abhinay@ubuntu:~$ fdisk -l
WARNING: GPT (GUID Partition Table) detected on ‘/dev/sda’! The util fdisk doesn’t support GPT. Use GNU Parted.Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sda1 1 9730 78150743+ ee GPT
using fdisk didn’t show the Main Partition of mac, It shows only one partition. The above partition sda1 is the EFI partition (boot partition).
That means, /dev/sda2 is your Mac partition.
Perform fsck on sda2
abhinay@ubuntu:~$ sudo fsck.hfsplus /dev/sda2
** /dev/sda2
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Checking multi-linked files.
** Checking Catalog hierarchy.
** Checking Extended Attributes file.
** Checking volume bitmap.
Volume Bit Map needs minor repair
** Checking volume information.
** Repairing volume.
** Rechecking volume.
** Checking HFS Plus volume.
** 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 was repaired successfully.
Hurray! It is repaired now…!
One more last thing you ‘ll have to do.
5. Enable the journaling on Mac Partition
use this command on Mac to enable the journal back.
sudo diskutil enableJournal /dev/disk0s2
You are done! :)
**This worked for me!
Comment me if you have any troubles or suggestions. Thanks for reading my blog!
Awesome! Worked for me as well. Was missing about 20GB from a power outage during partitioning and this did the job and brought the free space back! Thanks!
Nice to know that it worked for you!
Thanks!
Hi Abhinay,
I want to format the hard drive having Linux partition. My niece got the mini with the Linux. She want xp on it.
Now the linux installer is not running after one point.
How to use your method to format the linux partition to FAT32 or ntfs.
Your help will be great. I have spend lots of time but no help.
At work and home I am using Fedora 10.
Thank you in advance.
Best regards Logi
I’m unsure if I understood your problem.
If she is having only one Linux partition, I would suggest to boot using Ubuntu Live CD and use gparted to edit the paritions. Backup any important data and delete the Linux partition and then create a new partition for FAT32/NTFS. I would suggest her to use latest Ubuntu Version: http://www.ubuntu.com/getubuntu
Thanks!
I have a crashed HDD on a mac. How can I get the data back to an external HDD after booting from ubuntu. I have done it with windows but how do I get Ubuntu automount my HFS partition?
Try to recover your Mac Harddisk using above process. If you are still not able to recover, I would suggest to contact Apple Customer Service to protect your data. If you are able to mount the Mac partition from Ubuntu then you can backup your data to your External HDD.
This should help: https://help.ubuntu.com/community/AutomaticallyMountPartitions
Thanks!
mkdir /mnt/sda2
modprobe hfsplus
mount -t hfsplus /dev/sda2 /mnt/sda2
I used the above running puppy linux cd to mount the mac drive. This will allow you to read and copy from your hard drive to usb or what have you.
Hope this helps
if you cannot deactive the journaling and received this error.
yourcomputer:~ youruser$ sudo diskutil disableJournal /Volumes/Janice
Password:
An error occured journaling the filesystem: The underlying task reported failure on exit (-9972)
Let’s try. Unmount your drive — “Eject” in the Leopard finder. Then form a slightly different command by inserting the term ‘force’ after the disableJournal command, and by replacing the mounted volume name with the partition identifyer that you use before
yourcomputer:~ youruser$ sudo diskutil disableJournal force /dev/disk1s10
Password:
Journaling has been disabled for volume Janice on disk1s10
nothing says my disks are clean and A-ok – although i could not dejournalise them before doing the fsck procedure (i did use the -f attribute (force) and got the same result). i reboot and just get the spinning wheel of death .. for hours (5 or so now to be exact) … i di a check of the disk using macdrive under my bootcamp partition as well and it says the drive is unreadable due to structural corruption -> i think i’m f*ked
Doesn’t work for me. I’m still getting the same error as running fsck straight in OSX.
ubuntu@ubuntu:~$ sudo fsck.hfsplus /dev/sda2
** /dev/sda2
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
Keys out of order
(4, 1084)
** Rebuilding Catalog B-tree.
** The volume Macintosh HD could not be repaired.
ubuntu@ubuntu:~$
I’m so grateful, thanks a lot!
How do I disable journaling If my Mac won’t actually boot up from the OsX hard drive?
Good question. i would like to know the answer for that.
Boot from the OSX install DVD. You can access Terminal from the Utilities menu.
Execute “sudo diskutil disableJournal /dev/disk0s2” in Terminal.
Pingback: repair mac login failure due to invalid home directory « just do IT
Can’t you bypass turning on and off journaling by using
sudo fsck.hfs -fy /dev/"your device"
where the -f flag forces checking even if it is journaled?One of my partition of external HDD isn’t recognized by Mac. It appears on disk utility but won’t mount. I try to repair disk using disk utility function, but it took long time. It looks like my Mac having hard time for doing the work. In the middle of the process, it ejected itself.
So I want to try your option, using Ubuntu for repair the partition. But one of your step including disable journaling on that partition. Yes, I’m aware from some forum, Ubuntu is capable read and write HFS+ but not with journaling enabled.
Before I try this method I want to ask this question. Is it still possible to disable journaling when my partition didn’t mount? I’ve already check on disk utility it only appear as gray. Via terminal, it reads as disk0s2 or something.
How fast this disable journaling is? Is it less than a minute? I will assume if it tooks longer than 5 minutes, then my Mac truly cannot access that partition thus unable to disable journaling.
Actually my problem is more severe than one partition not able to mount, but at least I want one of my partition able to mount again.
Thanks in advance.
PS: my actual problem you could read it apple discussion board( http://goo.gl/uCiGf ), username omega8719.
Pingback: Mounting HFS+, from Mac to RPi | Just starting out with Linux and the Raspberry Pi