3

Okay, so something really strange has happened, and it's a doozy, so please bear with me.


Problem: I need to fix my hard drive's partition map


So let me fill you in on what happened here.

I have an external 3TB hard drive that I use for storage with my Mac Pro. It recently had 4 partitions on it. This is what the map looked like.

  1. Backup [OS X, Journaled]: 1.4TB
  2. Macintosh HD clone [OS X, Journaled]: 0.3 TB
  3. Yosemite [OS X, Journaled]: 0.5 TB
  4. Windows Bridge [FAT]: 0.5 TB

I had originally downloaded and installed Yosemite on a separate partition to play around with it, and then when I decided I liked it, I copied my Mavericks Mac HD onto another partition of the drive as a backup. I then upgraded my main system to Yosemite.

Later on, I decided that I no longer needed the Mac HD clone, since Yosemite is pretty stable at this point, so I removed it; I also resized the Yosemite partition down to 300 GB since I wasn't going to write anything else to it.

The partition map then looked like this:

  1. Backup: 1.4TB
  2. Unallocated: 0.3TB
  3. Yosemite: 0.3TB
  4. Unallocated: 0.2TB
  5. Windows Bridge: 0.5TB

That was all fine. However, recently, I installed Windows through Bootcamp on my primary SSD. In Windows' disk management, I tried to remove the Windows Bridge partition and replace it with a 0.7TB NTFS partition. The partition deleted, but the reformat operation failed, so I figured I would boot into OS X, remove the partition, and add a new FAT 0.7 TB partition which could then be reformatted by Windows into NTFS.

I opened up Disk Utility and saw that the Windows Bridge partition was still there according to OS X. So I went ahead and removed it.


And then, bad stuff happened.

The windows partition removed successfully, but the Yosemite partition immediately became unrecognizable by OS X. The files are intact, but OS X sees it as disk1s3, and is unable to read, write, or repair the disk.

The strangest part of it all is that Windows can still read the drive. If I boot into Windows, I can copy anything from the partition, and it works just fine, but boot back into OS X, and the partition is unreadable.


Things I've tried

1. TestDisk and PDisk

I have tried to create my own partition map for the drive using TestDisk to find the partitions and PDisks to create the new partition. TestDisk shows some weird configurations. It appears as though there are two partitions, masquerading as MS Data, assigned to the same set of blocks, with the name Yosemite. That must be causing the problem:

enter image description here

PDisk will not let me open the disk to be rewritten.

pdisk: can't open file '/dev/rdisk1' for writing (Resource busy)

2. Copying all of the files and re-formatting.

Since Windows can read the disk, I figured, why not copy everything from the Yosemite partition onto the Windows ST partition and reformat the broken partition. The only problem with that is that Windows limits path names to 255 bytes, and in OS X, a lot of the files have filenames that are much longer than that. I need all of the files on the drive in order to keep it bootable, so skipping those files that would not copy is out of the question.


So:

Do any of you fine people have any ideas as to how I can fix this partition map and/or get all of my data off of that partition so I can reformat it?

I can definitely go pick up another 3 TB drive to use to copy all of the files off of the existing drive so that the drive can be completely reformatted if you know of a way that I can get all of the files off of the Yosemite partition.


Edit:

> diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            200.0 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:       Microsoft Basic Data BOOTCAMP                50.1 GB    disk0s4
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *3.0 TB     disk1
   1:                        EFI EFI                     314.6 MB   disk1s1
   2:                  Apple_HFS Worth Backup            1.9 TB     disk1s2
   3:       Microsoft Basic Data                         300.0 GB   disk1s3
   4:       Microsoft Basic Data WINDOWS ST              510.0 GB   disk1s4

> diskutil cs list

    No CoreStorage volume groups found

> sudo gpt -r -vvv show -l /dev/disk0

gpt show: /dev/disk0: mediasize=251000193024; sectorsize=512; blocks=490234752
gpt show: /dev/disk0: PMBR at sector 0
gpt show: /dev/disk0: Pri GPT at sector 1
gpt show: /dev/disk0: GPT partition: type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, start=40, size=409600
gpt show: /dev/disk0: GPT partition: type=48465300-0000-11AA-AA11-00306543ECAC, start=409640, size=390624992
gpt show: /dev/disk0: GPT partition: type=426F6F74-0000-11AA-AA11-00306543ECAC, start=391034632, size=1269536
gpt show: /dev/disk0: GPT partition: type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, start=392304640, size=97929216
gpt show: /dev/disk0: Sec GPT at sector 490234751
      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - "EFI System Partition"
     409640  390624992      2  GPT part - "Customer"
  391034632    1269536      3  GPT part - "Recovery HD"
  392304168        472         
  392304640   97929216      4  GPT part - "BOOTCAMP"
  490233856        863         
  490234719         32         Sec GPT table
  490234751          1         Sec GPT header

> sudo gpt -r -vvv show -l /dev/disk1

gpt show: /dev/disk1: mediasize=3000592977920; sectorsize=4096; blocks=732566645
gpt show: /dev/disk1: Suspicious MBR at sector 0
gpt show: /dev/disk1: MBR part: type=175, start=76806, size=461468854
gpt show: /dev/disk1: MBR part: type=7, start=534820616, size=73242187
gpt show: /dev/disk1: MBR part: type=12, start=608062976, size=124503552
gpt show: /dev/disk1: Pri GPT at sector 1
gpt show: /dev/disk1: GPT partition: type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, start=6, size=76800
gpt show: /dev/disk1: GPT partition: type=48465300-0000-11AA-AA11-00306543ECAC, start=76806, size=461468854
gpt show: /dev/disk1: GPT partition: type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, start=534820616, size=73242187
gpt show: /dev/disk1: GPT partition: type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, start=608062976, size=124503552
gpt show: /dev/disk1: Sec GPT at sector 732566644
      start       size  index  contents
          0          1         MBR
          1          1         Pri GPT header
          2          4         Pri GPT table
          6      76800      1  GPT part - "EFI System Partition"
      76806  461468854      2  GPT part - "Worth Backup"
  461545660   73274956         
  534820616   73242187      3  GPT part - "Yosemite"
  608062803        173         
  608062976  124503552      4  GPT part - "WINDOWS ST"
  732566528        112         
  732566640          4         Sec GPT table
  732566644          1         Sec GPT header

> sudo fdisk /dev/disk0

Disk: /dev/disk0    geometry: 30515/255/63 [490234752 sectors]
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: EE 1023 254  63 - 1023 254  63 [         1 -  490234751] <Unknown ID>
 2: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
 3: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
 4: 00    0   0   0 -    0   0   0 [         0 -          0] unused   

> sudo fdisk /dev/disk1

Disk: /dev/disk1    geometry: 45600/255/63 [732566645 sectors]
Sector size: 4096 bytes
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: EE 1023 254  63 - 1023 254  63 [         1 -      76805] <Unknown ID>
 2: AF 1023 254  63 - 1023 254  63 [     76806 -  461468854] HFS+        
 3: 07 1023 254  63 - 1023 254  63 [ 534820616 -   73242187] HPFS/QNX/AUX
 4: 0C 1023 254  63 - 1023 254  63 [ 608062976 -  124503552] Win95 FAT32L
  • I do understand what happened. You have not given enough information for me to tell you how to fix the problem. What I need is for you to run some commands from the terminal application. The commands will not change anything. They just give me more information. Are you willing to do this? – David Anderson Feb 8 '15 at 20:13
  • @DavidAnderson Yes absolutely. – David Feb 8 '15 at 20:14
  • I am still reading your update. But I can see the problem. Your disk1s3 is Microsoft Basic Data where it should be Apple_HFS. Let me finish reading, before starting a fix. – David Anderson Feb 8 '15 at 20:47
  • Ok. I really appreciate the help. – David Feb 8 '15 at 21:25
  • @DavidAnderson any luck? – David Feb 8 '15 at 23:38
4

UPDATE:

There are three partitioning schemes used by both Windows and OS X. The first is MBR, which has been around since the 1980’s. The second is GPT, which is fairly new. The third is a hybrid scheme which combines the first two. OS X’s Disk Utility application allows you to select either MBR or GPT. If MBR is selected, then you get the traditional MBR scheme. On the other hand, if you select GPT, you will get either the GPT or the hybrid MBR/GPT scheme. Normally, the GPT scheme is used, but if one or more partitions have a MS-DOS (FAT) or ExFAT format then the MBR/GPT scheme is employed. If an external drive is hybrid, Windows will see the drive as MBR. If Windows is used to change the partitioning on such as drive, the results are unpredictable. This is why Apple recommends only using MBR to partition an external drive to be used by both OS X and Windows.

I believe your external drive was partitioned as an hybrid drive. The output you posted from the gpt command shows both GPT and MBR partitions.

To review, here is the output you posted from the command sudo fdisk /dev/disk1. It is the content of the MBR table.

Disk: /dev/disk1    geometry: 45600/255/63 [732566645 sectors]
Sector size: 4096 bytes
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: EE 1023 254  63 - 1023 254  63 [         1 -      76805] <Unknown ID>
 2: AF 1023 254  63 - 1023 254  63 [     76806 -  461468854] HFS+        
 3: 07 1023 254  63 - 1023 254  63 [ 534820616 -   73242187] HPFS/QNX/AUX
 4: 0C 1023 254  63 - 1023 254  63 [ 608062976 -  124503552] Win95 FAT32L

We want to remove partition 3 (Yosemite) from the table. When done, the output should appear as shown below.

Disk: /dev/disk1    geometry: 45600/255/63 [732566645 sectors]
Sector size: 4096 bytes
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: EE 1023 254  63 - 1023 254  63 [         1 -      76805] <Unknown ID>
 2: AF 1023 254  63 - 1023 254  63 [     76806 -  461468854] HFS+        
 3: 00    0   0   0 -    0   0   0 [         0 -          0] unused
 4: 0C 1023 254  63 - 1023 254  63 [ 608062976 -  124503552] Win95 FAT32L

Start by entering the following command in a Terminal window. The command is interactive. When completed, the Yosemite partition will be removed from the MBR tables. Windows will show the space as unallocated. Other than having a Safari window open to this page, make sure all other windows are closed.

sudo fdisk -e /dev/disk1

Below is the input to the above command. Note: Your password may be required. I did not include this in the input below.

edit 3
0
write
y
exit

I thought it might be helpful to include an example. This is what I saw as I entered the above input. Remember, what you will see can differ slightly. Certainly, the integers will be different.

Steelhead:~ davidanderson$ sudo fdisk -e /dev/disk1
fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory
Enter 'help' for information
fdisk: 1> edit 3
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 3: 07 1023 254  63 - 1023 254  63 [ 253328280 -  250708632] HPFS/QNX/AUX
Partition id ('0' to disable)  [0 - FF]: [7] (? for help) 0
Partition 3 is disabled.
fdisk:*1> write
Device could not be accessed exclusively.
A reboot will be needed for changes to take effect. OK? [n] y
Writing MBR at offset 0.
fdisk: 1> exit

The next set of commands remove the Yosemite partition from the GPT tables, then add the partition back in with the correct UUID. These commands do not alter the content of the partition. Enter the following at the Terminal window.

diskutil unmountDisk /dev/disk1
sudo gpt remove -i 3 /dev/disk1
diskutil unmountDisk /dev/disk1
sudo gpt add -i 3 -b 534820616 -s 73242187 -t hfs /dev/disk1

And you are done.

Let me know how things work out.


You will need to edit your question to post the results. Don't worry about the format, I can clean that up for you. From the Terminal application enter the following commands. Some may require your login password. This is normal.

diskutil list 
diskutil cs list 
sudo gpt -r -vvv show -l /dev/disk0
sudo gpt -r -vvv show -l /dev/disk1
sudo fdisk /dev/disk0
sudo fdisk /dev/disk1
  • I've run all of the commands and posted the results in my question – David Feb 8 '15 at 20:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .