Difference between revisions of "MacOS/Resize HFS Plus disk"
(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...") |
|||
Line 44: | Line 44: | ||
# diskutil resizeVolume /Volumes/backup R |
# diskutil resizeVolume /Volumes/backup R |
||
<span class="highlight">Error obtaining resizing information for grow to maximum</span> |
<span class="highlight">Error obtaining resizing information for grow to maximum</span> |
||
At this point I decided to convert the whole disk to <tt>GPT</tt>. However doing so will destroy all data unless after the disk has been relabeled the exact same partition is put back in place. When it comes to partitioning making mistakes can send all the data south. As such I did it with the tool and OS im most familiar, parted on Linux had to do the repartitioning. |
|||
Note: Before starting copy the partition table of the disk to a text file so that it can recovery is possible should things turn pear shaped. |
|||
To be ultra precise the <tt>unit</tt> of the display is set to Bytes. The <tt>print</tt> then shows the partition information prior to making any changes. |
|||
# parted /dev/sd<span class="input">X</span> |
|||
(parted) unit B |
|||
(parted) print |
|||
Model: BUFFALO HD-PEU2 (scsi) |
|||
Disk /dev/sdc: 500107862016B |
|||
Sector size (logical/physical): 512B/512B |
|||
Partition Table: msdos |
|||
Number Start End Size Type File system Flags |
|||
1 32256B 157283804159B 157283771904B primary hfs+ |
|||
2 157283804160B 500105249279B 342821445120B primary hfs+ boot |
Revision as of 00:10, 11 January 2015
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
At this point I decided to convert the whole disk to GPT. However doing so will destroy all data unless after the disk has been relabeled the exact same partition is put back in place. When it comes to partitioning making mistakes can send all the data south. As such I did it with the tool and OS im most familiar, parted on Linux had to do the repartitioning.
Note: Before starting copy the partition table of the disk to a text file so that it can recovery is possible should things turn pear shaped.
To be ultra precise the unit of the display is set to Bytes. The print then shows the partition information prior to making any changes.
# parted /dev/sdX
(parted) unit B
(parted) print
Model: BUFFALO HD-PEU2 (scsi)
Disk /dev/sdc: 500107862016B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32256B 157283804159B 157283771904B primary hfs+
2 157283804160B 500105249279B 342821445120B primary hfs+ boot