Chapter 17: Storage and file systems
Exercise: Storage review
Set up the spare disk of serverb from scratch: partitions, three kinds of storage with the right options, entries that survive a reboot, and a few facts for the record.
Storage review
- Partition a disk and create xfs, ext4 and swap.
- Mount permanently with UUIDs and options.
- Verify with findmnt --verify, mount -a and a reboot.
Before you start: reset the servers and complete this chapter's lessons. You work on serverb, as root (sudo -i), on the spare disk /dev/sdb; lab start and lab grade run on workstation.
On serverb:
- Create a GPT partition table on
/dev/sdbwith partitions of about 1 GiB (projects), 1 GiB (backups) and 512 MiB (swap). - Put XFS on the first, mounted on
/srv/projects, with a fileREADME.txtthat containsstorage ready. Put ext4 on the second, mounted on/srv/backupswithnoexecandnodev. Prepare the third as swap. - Make all three permanent by UUID in
/etc/fstab. Test withfindmnt --verify,mount -aandswapon -a. - On workstation, fill in
answers.txt.
Start the exercise
[student@workstation ~]$ lab start sa-storage-review
[student@workstation ~]$ ssh student@serverb
[student@serverb ~]$ sudo -i
[root@serverb ~]# lsblk /dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sdb 8:16 0 5G 0 diskPartitions and file systems
[root@serverb ~]# parted -s /dev/sdb mklabel gpt
[root@serverb ~]# parted -s /dev/sdb mkpart projects xfs 1MiB 1025MiB
[root@serverb ~]# parted -s /dev/sdb mkpart backups ext4 1025MiB 2049MiB
[root@serverb ~]# parted -s /dev/sdb mkpart swap linux-swap 2049MiB 2561MiB
[root@serverb ~]# udevadm settle
[root@serverb ~]# mkfs.xfs /dev/sdb1
[root@serverb ~]# mkfs.ext4 -L backups /dev/sdb2
[root@serverb ~]# mkswap /dev/sdb3
[root@serverb ~]# mkdir -p /srv/projects /srv/backupsfstab, mount and test
[root@serverb ~]# cp /etc/fstab /root/fstab.bak
[root@serverb ~]# cat >> /etc/fstab <<EOT
UUID=$(blkid -s UUID -o value /dev/sdb1) /srv/projects xfs defaults 0 0
UUID=$(blkid -s UUID -o value /dev/sdb2) /srv/backups ext4 defaults,noexec,nodev 0 0
UUID=$(blkid -s UUID -o value /dev/sdb3) none swap defaults 0 0
EOT
[root@serverb ~]# systemctl daemon-reload
[root@serverb ~]# findmnt --verify | tail -2
[root@serverb ~]# mount -a && swapon -a
[root@serverb ~]# echo "storage ready" > /srv/projects/README.txt
[root@serverb ~]# df -hT /srv/projects /srv/backups; swapon --showA reboot (systemctl reboot) is the final proof: after logging in again, all three must be there.
Grade
On workstation, fill in answers.txt and grade:
Check your work with lab grade sa-storage-review, then put the exercise away with lab finish sa-storage-review.