Repair GUID after changing HFS+ partition drive letter in Windows

boot-campguidhfs+macpartitioning

I have a non-boot HFS+ partition. After changing the drive letter in Windows diskmgmt.msc, I can no longer see the drive in OS X. I can see the drive and its contents in Windows. Apparently this is due to windows overwriting the GUID for the disk and changing the partition's designation from HFS+ to FAT.

I even found a thread that links to a solution, but the target is dead. I checked the internet archive. I searched for "apple discussions archive". I tried searching for the link. I tried using the new link format.

Here is the thread:

https://discussions.apple.com/thread/2471125

Here is the dead link from that thread:

http://discussions.apple.com/thread.jspa?messageID=11227763&#11227763

As of last night there are no SMART errors on any disk in the system. I will attempt to copy off the data in Windows, but I would much prefer to get access from OS X since there are sometimes errors copying files from HFS+ to NTFS, due to symlinks and certain characters. Usually I make a tarball in the OS X side and untar in Windows.

So, how do I fix the GUID to make this partition show up? Assuming this is actually the fix, of course.

The drives and partitions in the computer are like so:

Bay 1: Win Boot - 1TB NTFS SSD (bootable)
Bay 2: Win Data - 1TB NTFS SSD
Bay 3: Mac Data 1 - 3TB HFS+ HDD RAID 1 (1TB unused)
Bay 4: 6TB HDD
  Mac Boot Backup - 1TB HFS+ (bootable)
  Mac Data Backup - 3TB HFS+ 
  Win Boot Backup - 1TB NTFS (not bootable as of yet)
  Win Data Backup - 1TB NTFS  
Bay 5: Mac Data 2 - 3TB HFS+ HDD RAID 1 (1TB unused) 
Bay 6: Mac Boot - 1TB HFS+ SSD (bootable)

The problem is with the Mac Data Backup partition in Bay 4. This disk is only bootable by OS X from the Mac Boot Backup partition at the moment. Normally I boot Windows from the Win Boot disk and OS X from the Mac Boot disk.

Mac Pro 1,1 (2006), Windows 7 Bootcamp, OS X 10.6. It cannot boot UEFI, only EFI.

$ diskutil repairvolume /dev/disk3s3
Started filesystem repair on disk3s3
** /dev/disk3s3
Invalid BS_jmpBoot in boot block: 000000
Volume repair complete
Updating boot support partitions for the volume as required
Error: -9957: Filesystem verify or repair failed
Underlying error: 8: POSIX reports: Exec format error
$ sudo fsck -fy /dev/rdisk3s3
** /dev/rdisk3s3
BAD SUPER BLOCK: MAGIC NUMBER WRONG

LOOK FOR ALTERNATE SUPERBLOCKS? yes

SEARCH FOR ALTERNATE SUPER-BLOCK FAILED. YOU MUST USE THE
-b OPTION TO FSCK TO SPECIFY THE LOCATION OF AN ALTERNATE
SUPER-BLOCK TO SUPPLY NEEDED INFORMATION; SEE fsck(8).
$ sudo fsck_hfs -fy /dev/rdisk3s3
** /dev/rdisk3s3
   Executing fsck_hfs (version diskdev_cmds-491.6~3).
** Checking Journaled 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 Mac Data Backup appears to be OK.
$ diskutil list disk3
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *6.0 TB     disk3
   1:                        EFI                         209.7 MB   disk3s1
   2:                  Apple_HFS Mac Boot Backup         1000.0 GB  disk3s2
   3:       Microsoft Basic Data                         3.0 TB     disk3s3
   4:       Microsoft Basic Data Win Boot Backup         1.0 TB     disk3s4
   5:       Microsoft Basic Data Win Data Backup         1.0 TB     disk3s5
$ sudo gdisk -l /dev/rdisk3
GPT fdisk (gdisk) version 0.8.10

Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/rdisk3: 11721045168 sectors, 5.5 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): B006753D-13AC-4C49-88E1-F6C7E50FE896
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 11721045134
Partitions will be aligned on 8-sector boundaries
Total free space is 525717 sectors (256.7 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          409639   200.0 MiB   EF00  EFI System Partition
   2          409640      1953534639   931.3 GiB   AF00  Mac Boot Backup
   3      1953796784      7807788799   2.7 TiB     0700  Win Data Backup
   4      7808051200      9764546559   932.9 GiB   0700  Untitled
   5      9764546560     11721043967   932.9 GiB   0700  Untitled

gdisk is wrongly calling partition 3 Win Data Backup. The correct name of partition 3 is Mac Data Backup. Win Data Backup is the name of partition 5. Win Data Backup is shown correctly in diskutil above.

Best Answer

I just needed to use gdisk change the GUID type code for the partition from 0700 to AF00. The latest version that worked without segfaulting was 1.0.4. It looks like gdisk also works to fix drive name problems, for example correcting Win Data Backup to Mac Data Backup.

# gdisk /dev/disk2
GPT fdisk (gdisk) version 1.0.4

Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Command (? for help): p
Disk /dev/disk2: 11721045168 sectors, 5.5 TiB
Sector size (logical): 512 bytes
Disk identifier (GUID): B006753D-13AC-4C49-88E1-F6C7E50FE896
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 11721045134
Partitions will be aligned on 8-sector boundaries
Total free space is 525717 sectors (256.7 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          409639   200.0 MiB   EF00  EFI System Partition
   2          409640      1953534639   931.3 GiB   AF00  Mac Boot Backup
   3      1953796784      7807788799   2.7 TiB     0700  Win Data Backup
   4      7808051200      9764546559   932.9 GiB   0700  Untitled
   5      9764546560     11721043967   932.9 GiB   0700  Untitled
Command (? for help): t
Partition number (1-5): 3
Current type is 'Microsoft basic data'
Hex code or GUID (L to show codes, Enter = AF00):
Changed type of partition to 'Apple HFS/HFS+'
Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/disk2.
Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Warning: The kernel may continue to use old or deleted partitions.
You should reboot or remove the drive.
The operation has completed successfully.