Lay out a data disk with GPT, LVM and two file systems, then grow one

short · 45 min · Objective 2.1

Task

Add a data disk to lin-srv, partition it with GPT, put LVM on it, create two logical volumes with different file systems, mount them persistently by UUID, and then grow one volume and its file system while it stays mounted. Growing a volume without downtime is the reason LVM exists, and doing it once is the fastest way to remember the order of the steps.

Steps

  1. Identify the new disk with lsblk, create a GPT label and one partition with parted (or gdisk), and save parted <disk> print to lab/layout/parted.txt.
  2. Make the partition an LVM physical volume, create a volume group vgdata, and create two logical volumes: lvlogs of 1 GB and lvfiles of 1.5 GB.
  3. Create ext4 on lvlogs and XFS on lvfiles with mkfs.ext4 and mkfs.xfs, mount them at /srv/logs and /srv/files, and add both to /etc/fstab by UUID. Save the two fstab lines to lab/layout/fstab.txt.
  4. Reboot and save df -hT /srv/logs /srv/files to lab/layout/df-before.txt.
  5. Grow lvfiles by 1 GB with lvextend -r (or lvextend followed by xfs_growfs) while it is mounted, and save df -hT /srv/files to lab/layout/df-after.txt.
  6. Record in lab/layout/notes.txt why XFS can be grown but not shrunk, and what you would do if /srv/files had to become smaller.

Verify

These checks run in a POSIX shell: Terminal on macOS or Linux, and on Windows Git Bash (it comes with Git for Windows) or WSL. A stock Windows PowerShell or Command Prompt has no awk or grep, so there the first line fails.

grep -Eic 'gpt' lab/layout/parted.txt
grep -c 'UUID=' lab/layout/fstab.txt
grep -Ec 'ext4|xfs' lab/layout/df-before.txt
awk '$NF=="/srv/files" {print FILENAME": "$3}' lab/layout/df-before.txt lab/layout/df-after.txt
grep -Eic 'shrink|smaller|backup|restore' lab/layout/notes.txt

The partition table is GPT, both fstab lines use UUIDs, both file system types appear, and the size of /srv/files after the grow is larger than before. The notes must describe the only way to make XFS smaller: back it up, recreate it at the new size, and restore.

Notes

Mounting by UUID rather than device name matters on servers because device names such as sdb can change when disks are added or controllers are replaced, and an fstab that names the wrong device is a server that stops at boot, as the OS errors lesson shows.

This is an independent study companion for CompTIA Server+ SK0-005 and is not produced by or endorsed by CompTIA.