Red Hat System Administration II
Note
If you plan to take the RHCSA exam, then use the following approach to maximize the benefit of this Comprehensive Review: attempt each lab without viewing the solution buttons or referring to the course content. Use the grading scripts to gauge your progress as you complete each lab.
Create a logical volume, mount a network file system, and create a swap partition that is automatically activated at boot. You also configure directories to store temporary files.
Outcomes
Create a logical volume.
Mount a network file system.
Create a swap partition that is automatically activated at boot.
Configure a directory to store temporary files.
If you did not reset your workstation and server machines at the end of the last chapter, then save any work that you want to keep from earlier exercises on those machines, and reset them now.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start rhcsa-compreview2
Specifications
On
serverb, configure a new 1 GiBvol_homelogical volume in a new 2 GiBextra_storagevolume group. Use the unpartitioned/dev/vdbdisk to create the partition.Format the
vol_homelogical volume with theXFSfile-system type, and persistently mount it on the/user-homesdirectory.On
serverb, persistently mount the/sharenetwork file system thatserveraexports on the/local-sharedirectory. Theserveramachine exports theservera.lab.example.com:/sharepath.On
serverb, create a 512 MiB swap partition on the/dev/vdcdisk. Persistently mount the swap partition.Create the
productionuser group. Create theproduction1,production2,production3, andproduction4users with theproductiongroup as their supplementary group.On
serverb, configure the/run/volatiledirectory to store temporary files. If the files in this directory are not accessed for more than 30 seconds, then the system automatically deletes them. Set0700as the octal permissions for the directory. Use the/etc/tmpfiles.d/volatile.conffile to configure the time-based deletion of the files in the/run/volatiledirectory.
On
serverb, configure a new 1 GiBvol_homelogical volume in a new 2 GiBextra_storagevolume group. Use the unpartitioned/dev/vdbdisk to create the partition.Log in to
serverbas thestudentuser and switch to therootuser.[student@workstation ~]$
ssh student@serverb...output omitted... [student@serverb ~]$sudo -i[sudo] password for student:student[root@serverb ~]#Create a 2 GiB partition on the
/dev/vdbdisk.[root@serverb ~]#
parted /dev/vdb mklabel msdos...output omitted... [root@serverb ~]#parted /dev/vdb mkpart primary 1MiB 2GiB...output omitted... [root@serverb ~]#parted /dev/vdb set 1 lvm on...output omitted...Declare the
/dev/vdb1block device as a physical volume.[root@serverb ~]#
pvcreate /dev/vdb1...output omitted...Create the
extra_storagevolume group with the/dev/vdb1partition.[root@serverb ~]#
vgcreate extra_storage /dev/vdb1...output omitted...Create the 1 GiB
vol_homelogical volume.[root@serverb ~]#
lvcreate -L 1GiB -n vol_home extra_storage...output omitted...
Format the
vol_homelogical volume with theXFSfile-system type, and persistently mount it on the/user-homesdirectory.Create the
/user-homesdirectory.[root@serverb ~]#
mkdir /user-homesFormat the
/dev/extra_storage/vol_homepartition with theXFSfile-system type.[root@serverb ~]#
mkfs -t xfs /dev/extra_storage/vol_home...output omitted...Persistently mount the
/dev/extra_storage/vol_homepartition on the/user-homesdirectory. Use the partition's UUID for the/etc/fstabfile entry.[root@serverb ~]#
lsblk -o UUID /dev/extra_storage/vol_homeUUID 988cf149-0667-4733-abca-f80c6ec50ab6 [root@serverb ~]#echo "UUID=[root@serverb ~]#988c...0ab6/user-homes xfs defaults 0 0" \ >> /etc/fstabmount /user-homes
On
serverb, persistently mount the/sharenetwork file system thatserveraexports on the/local-sharedirectory. Theserveramachine exports theservera.lab.example.com:/sharepath.Create the
/local-sharedirectory.[root@serverb ~]#
mkdir /local-shareAppend the appropriate entry to the
/etc/fstabfile to persistently mount theservera.lab.example.com:/sharenetwork file system.[root@serverb ~]#
echo "servera.lab.example.com:/share /local-share \nfs rw,sync 0 0" >> /etc/fstabMount the network file system on the
/local-sharedirectory.[root@serverb ~]#
mount /local-share
On
serverb, create a 512 MiB swap partition on the/dev/vdcdisk. Activate and persistently mount the swap partition.Create a 512 MiB partition on the
/dev/vdcdisk.[root@serverb ~]#
parted /dev/vdc mklabel msdos...output omitted... [root@serverb ~]#parted /dev/vdc mkpart primary linux-swap 1MiB 513MiB...output omitted...Create the swap space on the
/dev/vdc1partition.[root@serverb ~]#
mkswap /dev/vdc1...output omitted...Create an entry in the
/etc/fstabfile to persistently mount the swap space. Use the partition's UUID to create the/etc/fstabfile entry. Activate the swap space.[root@serverb ~]#
lsblk -o UUID /dev/vdc1UUID cc18ccb6-bd29-48a5-8554-546bf3471b69 [root@serverb ~]#echo "UUID=[root@serverb ~]#cc18...1b69swap swap defaults 0 0" >> /etc/fstabswapon -a
Create the
productionuser group. Then, create theproduction1,production2,production3, andproduction4users with theproductiongroup as their supplementary group.[root@serverb ~]#
groupadd production[root@serverb ~]#for i in 1 2 3 4; do useradd -G production production$i; doneOn
serverb, configure the/run/volatiledirectory to store temporary files. If the files in this directory are not accessed for more than 30 seconds, then the system automatically deletes them. Set0700as the octal permissions for the directory. Use the/etc/tmpfiles.d/volatile.conffile to configure the time-based deletion of the files in the/run/volatiledirectory.Create the
/etc/tmpfiles.d/volatile.conffile with the following content:d /run/volatile 0700 root root 30s
Use the
systemd-tmpfiles --createcommand to create the/run/volatiledirectory if it does not exist.[root@serverb ~]#
systemd-tmpfiles --create /etc/tmpfiles.d/volatile.confReturn to the
workstationmachine as thestudentuser.[root@serverb ~]#
exitlogout [student@serverb ~]$exitlogout Connection to serverb closed.