RousselTMLEARNING

TP · Linux administration: from discovery to expertise

Lab: LVM, fstab and online extension

What you will learn in this TP
  • Create PVs, VGs and LVs
  • Mount by UUID in fstab
  • Extend online and take a snapshot

Introduction #

What you will learn in this section
  • Create PVs, VGs and LVs
  • Mount by UUID in fstab
  • Extend online and take a snapshot

Context. An application's data volume is filling up. You set up LVM storage that can grow without downtime. Disks are simulated with files (loop devices): nothing touches the real disks.

Prerequisites: a disposable Ubuntu 24.04 virtual machine (Multipass, Vagrant or cloud) with a sudo account  ·  Estimated time: 50 min

A /data volume grown from 600 MB to 1.4 GB without unmounting.

Hands-on #

Guided steps, with their solution.

  1. 1. Create two virtual disks

    Why? Loop devices let you practise without risk to the system disk.

    Create two 1 GB files and attach them as loop devices. Keep their names in variables D1 and D2.
  2. 2. Create the logical volume

    Why? The VG is a pool; allocate only what the LV needs to keep headroom.

    Initialise $D1 as a PV, create VG vg_tp and a 600 MB LV lv_data formatted as ext4, mounted on /data.
  3. 3. Make the mount persistent

    Why? An fstab mistake can block boot: always check with findmnt and mount -a.

    Add /data to /etc/fstab with its UUID and the nofail option, check the file, unmount and remount with mount -a.
  4. 4. Fill the volume

    Why? Simulate data growth to see the need for extension.

    Write a 450 MB file to /data and check usage. Leave an application writing to the volume.
  5. 5. Extend online

    Why? With LVM, you add space without unmounting or stopping the application.

    Add $D2 to the VG, extend lv_data by 800 MB growing the file system in the same command, and check writing continues.
  6. 6. Take a snapshot

    Why? A snapshot freezes the volume for a consistent backup or a rollback.

    Create a 200 MB snapshot, mount it read-only, compare app.log with the original, then delete the snapshot.
  7. 7. Clean up

    Why? Undo cleanly in reverse order: mount, LV, VG, PV, loop.

    Stop the writer, unmount, remove the fstab line and delete LVM and the loop devices.

Difficulty level : ●●●○○ (3/5)

My progress

  • ⏱ Estimated time : ≈ 50 min

Sign in to track your progress and take notes. Sign in

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Recommended Articles

Storage on Linux: disks, partitions, file systems and LVM

Administer Linux storage: lsblk and blkid, GPT partitioning, ext4 and XFS, mounting and /etc/fsta...

Backup, monitoring and troubleshooting of a Linux server

Operate a Linux server day to day: 3-2-1 backup strategy with rsync, tar, LVM snapshots and resti...

Linux administration best practices

Checklist for administering Linux servers: accounts and sudo, SSH, updates, systemd services, sto...

The Bash shell and files: navigation, redirections, pipes and text processing

Master the Linux command line: paths, file handling, wildcards, redirections, pipes, searching wi...

Users, groups, sudo and permissions on Linux

Manage Linux accounts (useradd, usermod, passwd, chage), groups, sudo and visudo, rwx and octal p...

Packages, systemd services, logs and scheduled tasks

Install and update software with apt and dnf, manage services with systemctl, write a systemd uni...

Networking on Linux: configuration, diagnosis, firewall and SSH

Configure and troubleshoot Linux networking: ip, ss, netplan and NetworkManager, DNS, layered dia...

Linux server security and hardening

Harden a Linux server: least privilege, updates, secure SSH, firewall, fail2ban, SELinux and AppA...

Bash scripts for administrators: writing robust scripts

Automate Linux administration with Bash: variables and quoting, conditions, loops, functions, exi...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!