Tips April 5, 2006 at 6:15 pm

Resizing Partitions at Last!

As of 10.4.6, if you’ve got a GPT partitioned disk, you can use diskutil from the command line to resize volumes…

[email protected]: ~ &#36; diskutil resizeVolume
Disk Utility Tool
Usage:  diskutil resizeVolume &#91;Mount Point|Disk Identifier|Device Node&#93; size
        &lt;part1Format part1Name part1Size&gt; &lt;part2Format part2Name part2Size&gt; ...
Non-destructively resize a disk. You may increase or decrease its size.
When decreasing size, you may optionally supply a list of new partitions to create.
Ownership of the affected disk is required.
Valid partition sizes are in the format of &lt;number&gt;&lt;size&gt;.
Valid sizes are B(ytes), K(ilobytes), M(egabytes), G(igabytes), T(erabytes)
Example: 10G (10 gigabytes), 4.23T (4.23 terabytes), 5M (5 megabytes)
resizeVolume is only supported on GPT media with a Journaled HFS+ filesystem.
A size of "limits" will print the range of valid values for the current filesystem.
Example: diskutil resizeVolume disk1s3  10G
         JHFS+ HDX1 5G MS-DOS HDX2 5G
Valid filesystems: "Case-sensitive HFS+" "Journaled HFS+" "Case-sensitive Journaled HFS+" 
"HFS+" "HFS" "MS-DOS FAT32"  "MS-DOS FAT16" "MS-DOS" "MS-DOS FAT12" "UFS" "Linux" "Swap" 

No Comments

  • Is there a way to delete partitions? Doesn’t seem obvious from the help text.
    I had reparitioned my drive to install XP the third party way, but BootCamp
    has shown up before I had a chance. However, BootCamp won’t run unless I
    have one big partition. Looks like I can’t go back to one partition without
    wiping the disk.

    • In that case, you’re probably better off looking at something like Parallels which lets you run any
      number of OSes simultaneously, while booted in OS X. It is still in beta,
      though, so a few things don’t work quite right (or at all). It is a step in the
      right direction, though, and certainly worth taking a look at. It’s just not
      production-ready quite yet 🙂


  • Other news:

    1.) 10.4.6’s disk utility allows to format disks with GPT
    2.) a PPC mac can boot off a GPT disk with 10.4.6

    i just did both of those things on my PPC mac (quad G5). sweet.

  • i couldn’t get resizing to work at this time… :-/

    [Quadzilla:/Volumes] boli% diskutil resizeVolume /Volumes/
    Started resizing on disk disk3s2 bonsai
    Resizing Volume

    Resizing encountered error No space left on device (28) on disk

    i did check the minimum and maximum size beforehand:

    [Quadzilla:/Volumes] boli% diskutil resizeVolume /Volumes/
    For device disk3s2 bonsai:
    Current size: 79716450304 bytes
    Minimum size: 3515957248 bytes
    Maximum size: 79716450304 bytes

    There’s only 2.27 GiB of data on that disk, and according to iDefrag
    no data beyond block 756709 (that’s byte 3099480064 with 4 KiB

    • hmm, this article states:

      The following is highly suspected to be functional only on Intel Macs.

      well, it didn’t work on my PPC mac (post above), so it looks like his suspicion is confirmed. did anyone else try?

      • I played with diskutil on 10.4.6 on a Powerbook using an external drive.

        I used the following Command to lay down a new GPTPartition table:
        diskutil partitionDisk disk2 1 JHFS+ Part1 20G

        It produced the following output:

        Started partitioning on disk disk2
        Creating Partition Map
        5% ..Formatting Disk 100% ..
        Finished partitioning on disk disk2
        #: type name size identifier
        0: GUID_partition_scheme *44.7 GB disk2
        1: EFI 200.0 MB disk2s1
        2: Apple_HFS Part1 44.4 GB disk2s2

        At this point diskutil info and the Disk Utility GUI both reflect the
        GUID partition table and the correct filesystem type.

        The Disk Utility App, cannot be used to break the drive into multiple
        partitions. When it does so, it writes an Apple style partition table.

        Using, diskutil resizeVolume disk2s2 15GB (or the same command with
        args specifying additional FSType/Name/Size triplets) fail.

        The failure does not indicate lack of space. I get the following output:
        Started resizing on disk disk2s2 Part1
        Resizing Volume

        Resizing encountered error Invalid argument (22) on disk disk2s2 Part1

        Given the possible coincidence of disk2s2 and the argument ’22’ I created
        a GUIDPartition with 2 partitions and tried to resize the second partition on
        disk2s3. I still failed with Invalid argument (22).

        Only then did I ‘Doh!’ and remember that 22 is the standard EINVAL error
        return code in /usr/include/sys/errno.h. So it is calling some library function to
        perform the resize, and returning a failure. I have not investigated further.

        I think that further attempts to run on PowerPC are likely to fail unless
        the test is run on a system which has been hacked together (via radmind,
        etc.) as a Universal build.

        • One final bit.

          I suggested that it was failing during a call to some library function which
          attempted to perform the resize. This is incorrect.

          disukutil makes a call to an Objective C method in the DiskManagement
          framework. This in turn will call a standalone executable Resources/

          On my system, the failure occurs before resizeVolume would even be
          So some function called before this, is failing.

          • no, it’s not calling the resizevolume tool in the diskmanagment framework. The
            issue is resizevolume only works on Intel macs. It specifically will not work on
            ppc, and nor APM maps.

        • The Disk Utility App, cannot be used to break the drive into multiple
          partitions. When it does so, it writes an Apple style partition table.

          that’s not true for me. i used (10.4.6’s) DiskUtility to create a single or
          multiple partitions that use GPT (using the
          “Options…” button to select GPT, see picture).

          disk[Quadzilla:~] oli% diskutil list
          #: type name size identifier
          0: GUID_partition_scheme *74.6 GB disk3
          1: EFI 200.0 MB disk3s1
          2: Apple_HFS Untitled 1 37.2 GB disk3s2
          3: Apple_HFS Untitled 2 37.0 GB disk3s3

    • There are two cases where this will fail:

      -Your volume fails a verify. Before resizing, resizevolume does a fsck of the
      volume in question. If that fails, the resize will fail, and you’ll need to use
      diskutility to repair it.

      -There are files can cannot be moved in order to accommodate your resizing
      request. The filesystem resizing routines have some limitations on what files it
      can move. There are a few metadata files that can’t be moved, so if they
      happen to be in the space you’re trying to free up, the resize will fail. Note
      that in some cases the filesystem doesn’t know if there are files it can’t move
      before it starts. Thus, there will be cases where it actually moves some
      number of files before exiting. In these cases, the disk should still be ok.

  • I have a problem with this resizing thing!

    I used bootcamp to resize my single-volume HD into a 70gb and a smaller
    5gb partition. Instead of installing windows, I used disk util to format the
    volume as HFS+.

    I then decided to merge back to partition into a single Volumen (the 5gb was
    empty) but bootcamp refused to recognise the partition so it wouldn’t merge

    diskutil resizeVolume did not work because of this second 5gb partition
    (disk0s3) being present.

    I used gpt to delete the 5gb partition and I now have about 5gb of free
    unpartioned space on my hard drive. However, diskutil resizeVolume still
    refuses to adjust the size of my main macintosh volume (disk0s2)

    I really don’t know what to do. I installed tiger like 3 days ago and i don’t
    really want to go thorugh all the installation process again :S

Leave a reply

You must be logged in to post a comment.