Expand old JHFS+ disk on the command line

From braindump
Revision as of 23:59, 10 January 2015 by Uroesch (talk | contribs) (Created page with "{{DISPLAYTITLE:Expand old JHFS+ disk on the command line}} For a test I partitioned an external 500GB disk with a 157.3GB JHFS+ partition and the remaining 342.8GB with an Li...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


For a test I partitioned an external 500GB disk with a 157.3GB JHFS+ partition and the remaining 342.8GB with an Linux ext2. The whole thing was meant as backup disk. After some cleanup I was able to move all the data from the ext2 partition off somewhere else. Eventually I wanted to make resize the JHFS+ partition to use all the 500GB. I thought that would be fairly simple. But I was totally wrong and had to really work hard to make it work. The description here is how I eventually got it working navigating around all the issues along the way.

Task

Repartion an disk that was created on an older version of MacOS X to use 100% of the disk space. Important the data on the volume must stay intact.

Tools

  • diskutil (MacOS X)
  • parted (Linux)

Howto

There were a few issues along the way that had to be addressed one by one. Each is described in a subsection sequentially.

Starting point

Starting out on the Mac diskutil list showed the following output.

Note: The disk is using an MBR or in Mac-speak FDisk_partition.

# diskutil list
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *500.1 GB   disk1
   1:                  Apple_HFS backup                  157.3 GB   disk1s1
   2:                  Apple_HFS disk1s2                 342.8 GB   disk1s2

Issue 1 - Wrong partition scheme

Being fairly unfamiliar with the Mac tools I found diskutil has a number of great tools such as mergePartitions or resizeVolume unfortunately running them resulted in an rather non descriptive error.

# diskutil mergePartitions JHFS+ backup disk1s1 disk1s2
Merging partitions into a new partition
     Start partition: disk1s1 backup
     Finish partition: disk1s2 disk1s2

Merging partitions encountered error 
  "MediaKit reports partition (map) too small  (-5341)".
The erase will not occur.

I was under the impression that the max partition size for MBR was 2TB but maybe it is different on the Mac so I wanted to convert it to GPT. And the almighty Internet could not clear thing up for me. In hindsight I was wrong all along and could have saved me some time but to that later.

Trying to resize the volume was not much better. The R is to use all the available space.

# diskutil resizeVolume /Volumes/backup R
Error obtaining resizing information for grow to maximum