CompTIA Linux+ (XK0-006)System ManagementMedium

The logical volume /dev/vg_data/lv_home is formatted with ext4 and has run out of space. The volume group vg_data has 5GB of free extents. Which sequence of commands correctly extends the logical volume by 5GB and grows the filesystem to use the new space?

  1. Avgextend -L +5G /dev/vg_data/lv_home && mkfs.ext4 /dev/vg_data/lv_home
  2. Blvextend -L +5G /dev/vg_data/lv_home && resize2fs /dev/vg_data/lv_home
  3. Clvresize -L 5G /dev/vg_data/lv_home && fsck /dev/vg_data/lv_home
  4. Dpvresize +5G /dev/vg_data/lv_home && resize2fs /dev/vg_data/lv_home
Show answer & explanation

Correct answer: B. lvextend -L +5G /dev/vg_data/lv_home && resize2fs /dev/vg_data/lv_home

lvextend -L +5G grows the logical volume by adding 5GB from the volume group's free space, and resize2fs then expands the ext4 filesystem to fill the newly available space on that logical volume.

Why the other options are wrong

  • A. vgextend adds physical volumes to a VG, it does not take a -L size flag for an LV, and mkfs.ext4 would destroy existing data.
  • C. lvresize -L 5G sets absolute size (risking shrink if miscalculated) and fsck checks but does not resize the filesystem.
  • D. pvresize resizes a physical volume's metadata, it does not accept a logical volume path or +5G syntax.

LVM Logical Volume Extension

To grow a filesystem on LVM, first extend the logical volume with lvextend, then resize the filesystem itself with a tool like resize2fs (ext) or xfs_growfs (XFS).

  • lvextend -L +<size> adds space to an LV
  • resize2fs grows ext2/3/4 filesystems online
  • xfs_growfs is used instead for XFS filesystems

Memory trick: 'Extend the pipe (lvextend), then stretch the balloon inside it (resize2fs).'

More System Management questions