For resizing LVM2 partition, one needs to perform the following 2 commands:
# lvextend -L+1G /dev/myvg/homevol
# resize2fs /dev/myvg/homevol
However, when I perform lvextend
, I see that the changes are already applied to the partition (as shown in Gnome Disks). So why do I still need to do resize2fs
?
Best Answer
The
lvextend
command (without the--resizefs
option) only makes the LVM-side arrangements to enlarge the block device that is the logical volume. No matter what the filesystem type (or even whether or not there is a filesystem at all) on the LV, these operations are always similar.If the LV contains an ext2/3/4 filesystem, the next step is to update the filesystem metadata to make the filesystem aware that it has the more space available, and to create/extend the necessary metadata structures to manage the added space. In the case of ext2/3/4 filesystems, this involves at least:
This part is specific to the filesystem type, although the ext2/3/4 filesystem types are similar enough that they can all be resized with a single
resize2fs
tool. For XFS, filesystems, you would use axfs_growfs
tool instead. Other filesystems may have their own extension tools. And if the logical volume did not contain a filesystem but instead something like a "raw" database or an Oracle ASM volume, a yet another procedure would need to be applied.Each filesystem has different internal workings and so the conditions for extending a filesystem will be different for each. It took a while until a common API was designed for filesystem extension; that made it possible to implement the
fsadm resize
command, which provides an unified syntax for extending several filesystem types. The--resizefs
option oflvextend
just uses thefsadm resize
command.In a nutshell: After
lvextend
, LVM-level tools such aslvs
,vgs
,lvdisplay
andvgdisplay
will see the updated size, but the filesystem and any tools operating on it, likedf
, won't see it yet.