Possibly the most specific -filter in recent memory
December 14, 2009 4:14 PM   Subscribe

GUIDPartitionTableFilter: How can I non-destructively change a partition's filesystem type ID in OS X?

For some reason (which I'll add at the end so I can get to the point) a partition on my external USB drive is mistakenly flagged as 'Microsoft Basic Data' and not 'Apple_HFS', as shown by diskutil:
$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            402.5 GB   disk0s2
   3:       Microsoft Basic Data Boot Camp               97.1 GB    disk0s3
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk3
   1:                        EFI                         209.7 MB   disk3s1
   2:       Microsoft Basic Data                         999.9 GB   disk3s2
            ^^^^^^^^^^^^^^^^^^^^ Wrong!
When I plug the disk in or boot up, Snow Leopard complains about not being able to recognize the disk and asking if I want to initialize it. However, if I do mount_hfs /dev/disk3s2 /Volumes/Test the drive is mounted and I can access the filesystem just fine.

How can I change the type back to Apple_HFS? I've looked at the gpt and diskutil man pages but only found info pertaining to creating new partitions, not modifying existing ones.
posted by The Lurkers Support Me in Email to Computers & Internet (6 answers total)
 
Response by poster: As for why it happened, I suspect the following (I can't be sure): I was mucking about in Windows 7 which has Snow Leopard's (read-only) HFS driver installed, and removed the drive letter assigned to the external disk using the Disk Management tool. Perhaps when I reassigned the drive letter, Windows changed the partition table thinking the partition was NTFS?
posted by The Lurkers Support Me in Email at 4:18 PM on December 14, 2009


I fixed a similar problem with a Linux Live CD. I *think* I did it with "parted", I'll see if I can dig up the exact flags
posted by meta_eli at 4:38 PM on December 14, 2009


Best answer: I can't figure out what I did last time, but this might point you in the right direction: http://www.rodsbooks.com/gdisk/
posted by meta_eli at 4:41 PM on December 14, 2009


Best answer: You can use GPT fdisk to change the partition type.

Basically, what you want to do is:
sudo gdisk /dev/disk3
t (this sets the partition type)
3 (this sets partition 3, gdisk counts partitions starting at 1 instead of 0 like diskutil)
L (show the codes, this isn't strictly necessary, just for your own reference)
af00 (the code for Apple HFS/HFS+)
w (write to disk and exit)

That should do it.
posted by zsazsa at 4:45 PM on December 14, 2009


(You shouldn't have to boot to a Linux CD to run GPT fdisk; it runs on MacOS these days)
posted by zsazsa at 4:46 PM on December 14, 2009


Response by poster: Awesome. As soon as I wrote the changes, everything started working. Thanks to you both!
posted by The Lurkers Support Me in Email at 4:58 PM on December 14, 2009


« Older Need an electric blanket   |   All I want for Christmas is my yum smoked meat. Newer »
This thread is closed to new comments.