Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Mount broken partitions or drives via the command line System

This tip comes with no guarantees, but should be worth a try given the usage circumstances.

I recently ran into a problem with a partition on one of my drives that reported a bad block. Running Disk Utility or fsck_hfs from the command line couldn't fix the problem, and the OS refused to mount the partition. I don't have Norton or other disk utilities, so I was almost resigned to the idea that the data was gone and I was about to re-format the partition. Before this, though, I thought it was worth forcing a manual mount ... and it worked!

First you need to know the filesytem device for the drive. In my case it was on an external firewire drive (/dev/disk1s12). You can probably guess by typing df in terminal and looking for the next or missing device in the listed sequence. Then all you need to do is to type the following in terminal:

 % sudo mkdir /Volumes/broken
 % sudo mount -t hfs /dev/disk1s12 /Volumes/broken 
The first line creates the mount point; the second line mounts the drive - you should substitute for the correct device for /dev/disk1s12, of course.

That's it! If the mount is successful, you should be able to see the partition. It took a while for the Finder to recognise the mount, but it did so eventually. I copied the data to a safe location from the command line with ditto, then erased and restored the drive partition.

    •    
  • Currently 2.71 / 5
  You rated: 5 / 5 (7 votes cast)
 
[28,095 views]  

Mount broken partitions or drives via the command line | 11 comments | Create New Account
Click here to return to the 'Mount broken partitions or drives via the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
read-only
Authored by: SOX on Oct 14, '03 11:27:10AM

It probably would be advisable to mount it read-only. Can anyone suggest how to do this with HFS?



[ Reply to This | # ]
read-only
Authored by: LC on Oct 14, '03 11:37:50AM
I was thinking to insert an -o rdonly into the mount command line. Is that right? Larry.

[ Reply to This | # ]
read-only
Authored by: scottboms on Oct 14, '03 03:46:19PM

You could alternatively use the -r flag instead of -o rdonly. Type 'man mount' in the Terminal to get more information.



[ Reply to This | # ]
Mount broken partitions or drives via the command line
Authored by: willjwade on Oct 14, '03 04:29:03PM
If you are mounting e2fs (linux drives) using perhaps ext2fsx (http://sourceforge.net/projects/ext2fsx) then you must do something like:
 sudo /usr/local/sbin/e2fsck /dev/disk1s1
where disk1s1 is the partition. To discover these partitions do a
sudo pdisk
. then type L. This will list all your drives currently being seen by the machine and their partitions. Infact this is quite handy to find your partition if you cant figure it out using the df technique above. to remount try disktool -r once all fixed. if that doesnt work try
disktool -m disk1s1 
hth w

[ Reply to This | # ]
Mount broken partitions or drives via the command line
Authored by: bclingan on Oct 15, '03 12:33:16PM

I have couple CDs that I can't mount (I'm guessing because of a • (bullet) character in the title of the CD). Is there anyway I can force them to mount? They work on fine on older systems running OS 9. I know I can just burn new correct ones, but I was just curious....



[ Reply to This | # ]
Why do it the hard way?
Authored by: paulio on Oct 14, '03 07:29:30PM
Whoa! Wouldn't it just be easier to run Disk Warrior to fix the partition? Or am I missing something?

The down side of this could be that forcing a volume to mount could cause the OS to make a bad directory even worse. The next time it might not forcibly mount and it might not even be fixable with Disk Warrior.

I consider my data to be very valuable so I like turning on journaling to protect from this kind of problem in the first place.

See this hint (among others) to turn on journaling.

[ Reply to This | # ]

Why do it the hard way?
Authored by: CaptDeuce on Oct 14, '03 11:51:22PM

Whoa! Wouldn't it just be easier to run Disk Warrior to fix the partition? Or am I missing something?

You missed something; the poster doesn't have any third party utilities.

Reminds me of the time I had a corrupted disk but had to wait four weeks for Alsoft to ship me a Disk Warrior upgrade CD.. Fortunately for me, I was able to boot off a second drive and mount the necessary partitions of the bad drive to access my data. In other words, not everybody has those nifty third party tools -- or the time or resources to acquire them -- in a crisis.

---
--
"Where's my other sock?" - A. Einstein

[ Reply to This | # ]

Why do it the hard way?
Authored by: foobar104 on Oct 14, '03 11:55:18PM

You can get Disk Warrior via a five-minute download now. Check the web site.



[ Reply to This | # ]
Mount broken partitions or drives via the command line
Authored by: themexican on Oct 15, '03 02:42:53AM

Norton and Disk Warrior are virtually useless against many types of partition damage and force-mounting a damaged partition in the terminal is often an exercise in frustration.

I recently had a disk with damaged partitions that I thought was beyond repair (or beyond expensive data recovery service repair)... After a quote for $700 + a new drive from drive savers I was about to give up... but then someone recommend Data Rescue. This little genius program saved most of the data on the drive and managed to save all of the data on a firewire drive I had given up for dead over a year ago. I have since rescued several friends drives. If you deal with lots of drives or are an admin, this program (which I had never heard of) should be an essential part of your toolkit.

http://www.prosoftengineering.com/products/data_rescue.php

Note: this program does not repair your partitions, it just extracts data, but it is very good at doing this. If your drive is sound you can simply reformat and move on, if not, well then at least you have your data.



[ Reply to This | # ]
Mount broken partitions or drives via the command line
Authored by: garbanzito on Oct 15, '03 01:50:08PM

if you really had bad blocks, you should do a full format of the partition (or maybe the drive), otherwise problems will return.. simply initializing a volume won't map out bad blocks



[ Reply to This | # ]
disktool
Authored by: iixhd on Apr 26, '04 09:04:59PM

willjwade mentioned this Mac OS X (or is it really Darwin?) utility called disktool. With disktool, without sudo, you can list recognized disks, mount disks, and unmount attached disks/partitions with it. Unfortunately there is no man page (in 10.2.8) but if you type disktool with no parameters it prints out instructions.

Try "disktool -l" to list all attached drives (not mounted), instead of just guessing from df. Disktool also allows you to mount drives, but I'm not sure if this would work in your case. "sudo mount" may be a stronger way force a mount in the case where the finder refuses to mount the partition. "sudo pdisk" is also probably a more direct (stronger) way to see all recognized disks.

Finally, disktool has a "notify" function (-a) that might decrease the ammount of time it takes for the finder to recognize the mount.



[ Reply to This | # ]