Linux Labs

Storage / Stage 6 of 11

Logical volumes and growing a filesystem

Not running Starting usually ~20 s
Leave the lesson

Step 3 of 7 · theory · 5 min

Extents and the final size

The group hands out space in equal pieces. They decide how much of the pool a volume's growth uses.

A device given to the group is a physical volume (PV), here /dev/loop0. LVM cuts it into extents, pieces of one size, 4 MiB each in the training group. A volume gets a whole number of extents: the 128 MiB data volume is 32 extents, and growing it to 256 MiB takes 32 more.

lvextend grows a volume. The -L size comes in two forms:

Form Result for a 128 MiB volume
-L 256M: the final size 256 MiB
-L +256M: add to the current size 384 MiB

The final size is the safer form. Repeating the same command changes nothing: lvextend prints New size (64 extents) matches existing size. Repeating +256M adds the same amount again. M in LVM sizes means mebibytes.

You do not have to give one volume the whole pool: a neighbouring volume or a snapshot may need it, and snapshots are the next lesson. If the pool is too small, lvextend fails with Insufficient free space.

Check yourself 1 question

The data volume is 128 MiB, and the group has 220 MiB free. You ran sudo lvextend -L 192M /dev/lab_vg/data twice in a row. What will sudo lvs show?

  • Without a plus, -L sets the final size. On the second run lvextend prints New size (48 extents) matches existing size: the volume is already that size.

  • Adding takes -L +96M, with a plus. -L 192M brings the volume to 192 MiB and leaves it alone on a repeat.

  • Taking everything needs -l +100%FREE. -L 192M takes exactly the extents needed to reach 192 MiB: 16.

-L without a plus sets the final size: the first run added 16 extents, and the second reported the size unchanged. Check the result with sudo lvs lab_vg.

Key points

  • The group hands space to volumes in extents, 4 MiB each in the training group.
  • -L 256M sets the final size, so a repeat is safe; -L +256M adds on every run.
Ubuntu 24.04
Loading…