Parted. It’s awesome.
I did something stupid last night. I tried to make a modification to the partition table of a drive while it was in use. For obvious reasons, this was not what I had intended and I corrupted the partition table and lost all my data on that drive — temporarily. Then, I fixed it with parted.
I keep an external hard drive attached to my powerbook, almost permanently. While working at my desk, this drive provides an expanse of disk space that seems endless when compared to the 60GB drive that my notebook contains. It serves as the home of a nightly backup and a repository of every application (for both pc and mac) that I have ever used or conceivably have a legitimate use for. I’ve found that keeping a copy of everything requires minimal effort, is reasonably cheap after considering the cost of disk space compared to the time and difficulty of re-downloading everything, and it’s just plain smart. As an added bonus, it allows you to completely rebuild or replicate your setup on the rare occasion that its needed (such as when a drive failure occurs).
Me — really OS X Disk Utility — being stupid
I had cleared a bunch of junk on my external disk, and emptied the trash. I then decided to change the filesystem on one partition of the external device from Fat32 to ext3. Up until this point, Fat32 was the easiest pc-mac interoperability solution available, and I didn’t know about the excellent and free ext3 drivers available for windows. I had recently acquired iLife 06 and wanted to back up my media, as usual, but I needed a filesystem that would support a 6GB DVD image file. Fat32 doesn’t allow this, as it has a 4GB file size ceiling.
For whatever reason — sucks to you Apple developers — while formatting the partition the trash still being emptied. Subsequent dodgy behavior ensued, the drive format failed and left the disk in an undefined state with a missing partition table, and all data on the drive appeared lost. The drive, superficially at least, was bricked. It wasn’t even mountable.
Kubuntu and Parted saved my life
Performing any sort of drive maintenance on a mac is downright painful. Disk Utility obviously doesn’t offer comprehensive support for anything, and it’s not well engineered. As we know, a sanity check wasn’t done to make sure that there weren’t any open files on the disk while it was being tampered with. Further still, there is a general lack of availability for standard tools like parted and gpart for OS X (including through back channels like fink).
Both gpart and parted have the ability to rebuild a lost or corrupt partition table by inferring the filesystem types from the drive contents. Naturally, there isn’t support for all partition types, but there definitely is support for de facto standard filesystems such as Fat16/32 and ext2/3 among others. This was perfect for my situation — I had one 200GB Fat32 slice, and one 50GB (almost, it was actually 32GB) ext3 partition. Keep this in mind the next time you think you’re slick and you install that super-fast foo-bar-baz filesystem on your cutting edge machine, as there might not be anyone to save you from yourself later on.
So I turned to linux. Kubuntu in particular, since it’s LiveCD was PPC-compatible and it came packaged with parted. I booted up, fired up an xterm, ran two commands (that’s all it took), and I was done:
sudo parted /dev/sda
rescue 0GB 200GB
// rescues partition spanning approximately 0GB - 200GB
rescue 200GB -1
// same thing, but from 200GB until end-of-disk
And that’s how my hard drive was saved and crisis was averted.
References
[1] GNU Parted
0 Comments to “Parted. It’s awesome.”
No Comments. Send your comment.
Leave a Reply