Linux Labs

Storage / Stage 6 of 11

Logical volumes and growing a filesystem

Not running Starting usually ~20 s
Leave the lesson

Step 4 of 7 · on a machine · 5 min

The volume and the filesystem grow separately

Growing a volume gives space to the device. Files get it once the filesystem grows too.

lvextend changes the size of a logical volume. The ext4 on it keeps its old size until it is stretched: df shows the old numbers, and writes still fail. resize2fs grows ext4, mounted ones included, and the data stays in place. For xfs, xfs_growfs does the same.

The -r option of lvextend does both steps in one command: after the volume it grows the filesystem too.

After growing, lvs and df will not match: lvs shows the device size, while df shows the filesystem's space minus its own metadata. For a 256 MiB volume, df -h shows a Size of 224M.

Exercise · do it

Grow the volume together with ext4

Grow only the /dev/lab_vg/data volume and its ext4 to 256 MiB, keeping the data and the keep volume. Then, as your own user, write the line report to /mnt/lvm-data/report.txt.

Sign in and start The machine is available after signing in

Goals · 0 of 2

  • Grow the data volume and its ext4 to 256 MiB not done yet
  • Write report.txt as your own user not done yet

Step goals

0 of 2
  • Grow the data volume and its ext4 to 256 MiB — not done yet
  • Write report.txt as your own user — not done yet
Ubuntu 24.04

Step goals

0 of 2
  • Grow the data volume and its ext4 to 256 MiB — not done yet
  • Write report.txt as your own user — not done yet
Loading…