How can I resize partitions from the command line? I've heard of GParted, but I don't want to use a GUI program.


1 Answer 1


Use parted instead, possibly coupled with your filesystem's resizing command.

parted is the engine underneath the GParted GUI. You can use it in either interactive command mode or directly from the command line.

Before parted 3.0, the following command does what you are probably expecting, having learned about GParted:

$ sudo parted /dev/sdb resize 1 1 200M

That will resize the first partition on the second hard disk to 200 MiB, and make sure it starts 1 MiB into the disk so as to avoid alignment problems with Advanced Format drives.

This functionality was removed in v3.0, the regression being justified by comparison to removing a gangrenous toe. Partial functionality was restored in v3.1, covering only FAT and HFS+.

v3.2 is where things really got interesting, from a Unix/Linux file system perspective. It replaces the resize command with resizepart. The new name is due to the fact that it can only change the partition size; it doesn't even attempt to rearrange its contents first.

In the case of growing an existing filesystem, this is a low-risk operation as long as you're using a filesystem that can be grown on the fly, like ext4 or XFS. For example, if we start with a 200 MiB ext4 partition on /dev/sdb1, we can double its size:

$ sudo parted /dev/sdb resizepart 1 400M
$ sudo resize2fs /dev/sdb1 400M

The same command pair also works for shrinking ext[234] filesystems, except that you give them in reverse: shrink the actual filesystem, then chop the empty space off the end of the partition.

Some filesystems (e.g. XFS) can be grown only; they can't be shrunk. This is why XFS's equivalent to resize2fs is called xfs_growfs.

RAID and LVM systems complicate all of this. They have their own restrictions and capabilities.

A common situation is to have an XFS filesystem on top of a multi-drive LVM-managed disk array, to which you add some drives, then expand the LVM, and finally expand the XFS filesystem into the new space.

  • Great answer. What would happen if you left out calling resize2fs?
    – Jeppe
    Oct 11, 2020 at 20:01
  • Is there a resize2fs equivalent for FAT32/vfat? I found fatresize but it appears to be a wrapper for parted, which doesn't appear to do this any more...
    – jacobq
    Oct 27, 2020 at 22:08
  • 1
    @jacobq: This is a really old question. It's best if you just ask a new question to focus on this specific element, given current software realities. Oct 27, 2020 at 22:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.