Why does Mac OS X 10.11 ignore new partition size

hfs+partitionterminal

Because running out of space on a MacBook Pro 13'' 2009 (type A1278), I cloned its 160 GB Hitachi drive to a 1 TB Seagate HDD.
The MacBook is installed with OS X El Capitan (10.11).

Summary: The cloned OS starts, login possible, new volume size not detected, disk utility crashes when trying to access the partitioning tool.

First steps done:

  1. Cloned the whole drive (low level)
  2. Activated the root user in the System Preferences
  3. Connected the cloned drive to a MacBook running OS X Lion 10.7.5
  4. Deleted the recovery partition to allow expanding the main partition.
  5. Tried to expand the main partition using first the native disk utility, and then Stellar Partition Manager. No success with both.

Expanding the partition from the Terminal:

I expanded the partition from the terminal, inspiring myself from this tutorial and its comments
http://blog.kyodium.net/2010/11/increase-disk-and-partition-size-in.html:

  1. Switched to root user with the su command
  2. Listed the drives with diskutil list
  3. Unmounted the "Macintosh HD" partition of the original drive: diskutil unmount /dev/disk1 and cloned drive diskutil unmount /dev/disk2
  4. Showed the partition scheme of the original drive: gpt show /dev/disk1
  5. Deleted the partition scheme on the cloned drive: gpt destroy /dev/disk2
  6. Created a new partition scheme on the cloned drive: gpt create -f /dev/disk2
  7. Created again the same partitions, but with increased size for the "Macintosh HD" one and the Recovery partition moved 800 MB before the end of the hard drive: gpt add -b <start> -s <size> -t <GUID_from_disk1> /dev/disk2
  8. Checked everything by repeating step 3 and using gpt show ... on both drives.
  9. Cloned the recovery partition dd if=/dev/disk1s3 of=/dev/disk2s3
  10. Repeated step 8.

Result:

  • The "Macintosh HD" partition from the cloned drive shows with the correct size around 800 GB when externally attached to the MacBook running Lion 10.7.5.
  • When the hard drive is inserted into the original MacBook, the OS starts correctly and allows to login. (I had to perform some verification and minor repair of the "Macintosh HD" volume on the MacBook running Lion for the OS to completely load.)
  • The disk utily for Mac OS X 10.11 El Capitain still sees the wrong size of 160 GB for the "Macintosh HD" Volume and when clicking on the "Partition" button, the disk utility crashes. The MacBook still displays the message that the start disk is full.

When creating the partitions at step 6, was it an error keeping the GUID of the original drive with the -t option?

Here are the hard drives and partitions as seen from the terminal:

   sh-3.2# diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *160.0 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Senza titolo            159.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *160.0 GB   disk1
   1:                        EFI                         209.7 MB   disk1s1
   2:                  Apple_HFS Macintosh HD            159.2 GB   disk1s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk1s3
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk2
   1:                        EFI                         209.7 MB   disk2s1
   2:                  Apple_HFS Macintosh HD            815.8 GB   disk2s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk2s3

sh-3.2# diskutil cs list
No CoreStorage logical volume groups found
sh-3.2# diskutil unmount /dev/disk1s2
Volume Macintosh HD on disk1s2 unmounted
sh-3.2# diskutil unmount /dev/disk2s2
Volume Macintosh HD on disk2s2 unmounted
sh-3.2# gpt show /dev/disk1
      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
     409640  310902592      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  311312232    1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  312581768          7         
  312581775         32         Sec GPT table
  312581807          1         Sec GPT header
sh-3.2# gpt show /dev/disk2
       start        size  index  contents
           0           1         PMBR
           1           1         Pri GPT header
           2          32         Pri GPT table
          34           6         
          40      409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
      409640  1593425880      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  1593835520     1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  1595105056   358420079         
  1953525135          32         Sec GPT table
  1953525167           1         Sec GPT header
sh-3.2#

Best Answer

The HFS+ volume data structures "know" how big the volume is; this means that if you take a 159.2 GB HFS+ volume and edit the partition table to make it 815.8 GB, you now have an inconsistent state: the partition table says its 815.8 GB, the volume data structures say it's 159.2 GB, and any tool that looks at both is going to be confused.

To avoid this problem, do not use gpt to change the size of partitions that contain HFS+ volumes, and don't use dd to clone between partitions or disks that aren't exactly the same size. Instead, change partition sizes with with either diskutil resizeVolume or Disk Utility (these edit both the partition table and volume data structures to keep them in sync). Also, you can clone HFS+ volumes with either something like asr --source /dev/disk1s2 --target /dev/disk2s2 --erase (note: verify /dev entry names are correct before entering this command!) or with Disk Utility's "Restore" tool (these both correctly handle expanding/contracting HFS+ volume data structures to match the target partition).

At this point, I'd erase the new drive and start over -- it's easier to use the right tools from the beginning than it is to clean up after using the wrong ones.