Thursday, July 25, 2019

macos - Adding NTFS partition to disk in Windows makes HFS+ partition on same disk invisible in Mac OS X



I've got a USB hard drive that I've been using with my Mac for backups, formatted as one large HFS+ partition. I added a second NTFS partition for similar use with Windows, as follows:




  1. Resize HFS+ partition using Mac OS X Disk Utility


  2. Reboot into Windows 7 using Bootcamp


  3. Add NTFS volume in the free space using Windows 7 Disk Manager





Now that I've done this, I can see both volumes in Bootcamp Windows, and they seem to be fine.



When I boot into Mac OS X, though, only the NTFS volume appears.



Looking at the disk in Disk Utility, the reason is clear: Mac OS X can't actually see any HFS+ partition there. Its space is shown as "disk4s2", and when I click on it in Disk Utility it's supposedly in "MS-DOS (FAT)" format. diskutil on the command line has this to say:



~% diskutil list /dev/disk4
/dev/disk4

#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.0 TB disk4
1: EFI 209.7 MB disk4s1
2: Microsoft Basic Data 700.0 GB disk4s2
3: Microsoft Basic Data BACKUPS 300.0 GB disk4s3


Nevertheless, when I reboot into Windows 7, the HFS+ partition pops up again, correct volume label and everything. So clearly the data is still there, and in some kind of usable format.



It's not the end of the world if I have to reformat, but I'd rather keep my full Time Machine history if possible. So is there something I can do to fix this non-destructively, and should I have done something differently when I was adding the second partition?



Answer



I tried various other search terms and found that this question is actually a duplicate of this one: OS X 10.6 Snow Leopard no longer mounting an external USB drive.



Here's what I did to fix:




  1. Download and install GPT fdisk

  2. Run gdisk and select problem drive:



    ~% sudo gdisk

    GPT fdisk (gdisk) version 0.8.1

    Type device filename, or press to exit: /dev/disk3
    Partition table scan:
    MBR: protective
    BSD: not present
    APM: not present
    GPT: present

    Found valid GPT with protective MBR; using GPT.


  3. Look at the partitions using the p command:



    Command (? for help): p
    Disk /dev/disk3: 1953525168 sectors, 931.5 GiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): ABFA9105-73F4-4627-9890-9DECC55E86AC
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 1953525134
    Partitions will be aligned on 8-sector boundaries

    Total free space is 3389 sectors (1.7 MiB)

    Number Start (sector) End (sector) Size Code Name
    1 40 409639 200.0 MiB EF00 EFI System Partition
    2 409640 1367597143 651.9 GiB 0700 Time Machine Backups
    3 1367599104 1953523711 279.4 GiB 0700 Basic data partition


    In this case, it's partition 2 that's causing the problem. And the problem is that its type code is 0700, which means something other than HFS.


  4. Use the t command to set the partition type to af00 - Apple HFS/HFS+.




    Command (? for help): t
    Partition number (1-3): 2
    Current type is 'Microsoft basic data'
    Hex code or GUID (L to show codes, Enter = af00):
    Changed type of partition to 'Apple HFS/HFS+'

  5. Use the w command to write the stuff back to disk and quit.



    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).
    Warning: The kernel may continue to use old or deleted partitions.
    You should reboot or remove the drive.
    The operation has completed successfully.




The HFS+ partition, and all of its contents, then became visible again to OS X.


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...