1

For resize2fs,

If ``size parameter is not specified, it will default to the size of the partition

The size of a filesystem is by default the size of its underlying partition.

So by default, resize2fs doesn't change the size of a filesystem. Does it do nothing?

Thanks.

3 Answers 3

2

If the underlying partition is larger than the filesystem within it, resize2fs will, by default, attempt to expand the filesystem to fill the partition.

For example, if /dev/sdd3 is a 1TB partition, and we were to run:

# mke2fs /dev/sdd3 500G

We will have a 500GB partition within a 1TB partition. If we then resize2fs /dev/sdd3, it will be expanded to the full 1TB.

1

The size of a filesystem is by default the size of its underlying partition.

Usually, yes. There's little point in creating a filesystem smaller than the available space on the partition.

But if you're trying to enlarge the filesystem, you'll first have to enlarge the device it's on. For the usual fixed partitions, that's not often possible (you'd need to have available space after the partition itself), but with something like LVM it's trivial, since you can just resize the logical volume at will.

After resizing the partition/volume, the filesystem only makes use of the originally available space, and at that point resize2fs is necessary. Again, you'll usually want to resize the partition to the fill all the now available space, so the default action is what you want.

1

I also often (ab)use resize2fs in some smallish/skeletal VMs for not to have to setup LVM.

For extending a drive/partition, I can provisioning/extend a virtual physical hard disk, and then delete and create a new bigger partition. Once I do that, I can extend the partition to the new "physical" space. (for instance, in vmware, I just edit an existing virtual disk, and edit it to be 10GB instead of 5GB...)

Or even in a physical disk, you can delete a second partition, delete the 1st one and recreate it using the former space of the two partitions, and then use resizefs for having a single partition where once you had two partitions.

So, resize2fs does something even without using LVM.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .