linux filesystems rhel lvm – Difference Between resize2fs and lvresize

filesystemslinuxlvmrhel

what is the difference between resize2fs and lvresize?
I know that resize2fs is used for resizing partition and lvresize is used for resizing lvm, but what is the difference between these?

resize2fs /dev/groupname/NAME1 5G

and

lvresize -L 5G /dev/groupname/NAME1

and why should resize2fs be done first?

Best Answer

There are two separate things:

  • the filesystem, a data structure that provides a way to store distinct named files, and

  • the block device (disk, partition, LVM volume) on inside of which the filesystem lies

resize2fs resizes the filesystem, i.e. it modifies the data structures there to make use of new space, or to fit them in a smaller space. It doesn't affect the size of the underlying device.

lvresize resizes an LVM volume, but it doesn't care at all what lies within it.

So, to reduce a volume, you have to first reduce the filesystem to a new size (resize2fs), and after that you can resize the volume to the new size (lvresize). Doing it the other way would trash the filesystem when the device was resized.

But to increase the size of a volume, you first resize the volume, and then the filesystem. Doing it the other way, you couldn't make the filesystem larger since there was no new space for it to use (yet).

Related Question