Using Linux Terminal 2.2: Partitions and filesystems
A GPT partition with an ext4 filesystem mounted at boot by UUID, getting a deleted partition back, and a read-only filesystem check.
Before you start
Work as root (sudo -i), and write answers to the files in
/root/lab-answers/. The lab adds a blank 2 GiB spare disk,
/dev/loop40, which stays attached across reboots; its first partition is
/dev/loop40p1 (the guide's /dev/vdb and /dev/vdb1). It saves
/etc/fstab and puts it back on reset, which also removes the disk.
Tasks
- Give
/dev/loop40a GPT partition table with one 1 GiB partition, make an ext4 filesystem labeleddataon it, and mount it at/mnt/dataat every boot, by UUID.findmnt --verifyreports no errors or warnings. - Save a file
/mnt/data/keep.txtcontainingkeep me. Unmount the filesystem, write its partition's start sector to/root/lab-answers/2, delete the partition with fdisk, then recreate it so thatkeep.txtcomes back unchanged. Mount it again. - Check the filesystem fully while it's unmounted, without letting fsck
change anything, and save fsck's output in
/root/lab-answers/3.
Hints
fdisk /dev/loop40(g,n,+1G,w) orparted;mkfs.ext4 -L;blkidfor the UUID;systemctl daemon-reloadafter editing fstab, thenmount -a.fdisk -l /dev/loop40shows the start; recreate with the same start and answer N to "remove the signature". fdisk asks that only at a terminal: fed from a pipe, it keeps the signature without asking.blkidshows the same UUID.fsck -fn /dev/loop40p1 >/root/lab-answers/3 2>&1.