0

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?

New contributor
Cracker is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    resize2fs is for ext filesystems, not partitions. "why should resize2fs be done first?" Where did you see that? – muru Aug 14 at 4:21
  • resize2fs should be used first only when you want to shrink the fs: shrink fs first, shrink the partition/LV second. when enlarging a fs, do the reverse - enlarge partition/LV, enlarge fs. see the man pages for resize2fs and lvresize for details. – cas Aug 14 at 5:28
  • lvresize resizes a logical volume (a virtual disk); resize2fs resizes an ext filesystem. Clearly to increase a filessystem, you need to extend space first; if you want to shrink, the other way around. – vonbrand Aug 14 at 13:37
3

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).

Your Answer

Cracker is a new contributor. Be nice, and check out our Code of Conduct.

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.