How to grow filesystem to use unallocated space in partition

filesystemsgpartedpartition

I duplicated a hard disk to a new larger one using the method suggested in Full DD copy from hdd to hdd.

After doing that df -h reports the original and smaller partition sizes from the original disk and gparted highlights the disparity and offers to fix them, though it seems unwise as they are mounted. If you look closely at the image you can see that Used + Unused < Size for the partitions with the yellow warning signs.

What command line tools can be used to fix the issue, and will it be safe for gparted to do it on mounted partition live? Ideally I should have done that before switching over to the target disk and rebooting from it.
Gparted Snapshot

Below is the information dialog from gparted about the discrepancy and I edited the title to describe it better.

Gparted information dialog

Best Answer

  • If gparted only has to extend the partition or filesystem into unused space (immediately following the partition), then it should be safe to let it extend the partition and/or fs.

  • If, however, it has to MOVE any partitions around to make space for resizing, you'll have to boot with a gparted Live CD

  • See the man page for resize2fs (which is the command-line tool gparted will use to grow an ext2, ext3, and ext4 filesystem) for more details about resizing those filesystems.

    For ext2/3/4, growing a filesystem is generally not a problem and can safely be done while the fs is mounted.

    Shrinking a filesystem, however, is more troublesome and should be done while the fs is unmounted. If it's the rootfs, that means booting to a rescue CD/USB/PXE etc.


BTW, both dd and cat are amongst the worst ways to copy a linux system to another hard disk. Use Clonezilla, that's what it's for.

Related Question