Lay out a data disk with GPT, LVM and two file systems, then grow one
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
- Identify the new disk with
lsblk, create a GPT label and one partition withparted(orgdisk), and saveparted <disk> printtolab/layout/parted.txt. - Make the partition an LVM physical volume, create a volume group
vgdata, and create two logical volumes:lvlogsof 1 GB andlvfilesof 1.5 GB. - Create ext4 on
lvlogsand XFS onlvfileswithmkfs.ext4andmkfs.xfs, mount them at/srv/logsand/srv/files, and add both to/etc/fstabby UUID. Save the two fstab lines tolab/layout/fstab.txt. - Reboot and save
df -hT /srv/logs /srv/filestolab/layout/df-before.txt. - Grow
lvfilesby 1 GB withlvextend -r(orlvextendfollowed byxfs_growfs) while it is mounted, and savedf -hT /srv/filestolab/layout/df-after.txt. - Record in
lab/layout/notes.txtwhy XFS can be grown but not shrunk, and what you would do if/srv/fileshad 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.