RHCSA Practice ExamLesson 3 of 4
Part B: System, software and storage (100 points)
Nine tasks on repositories, services, tuning, the boot loader, root recovery, LVM, swap and file systems.
dnfflatpaksystemctltuned-admrenicegrubbypartedvgcreatelvextendmkswap
After this lesson you can
- Complete the software, boot, recovery and storage tasks of the exam within about 55 minutes.
How to run Part B
Continue on node1 unless the task says otherwise. Do B5 early: start the reboot of node2 and keep working on node1 while it relabels. Do the storage tasks in order: B6, B7, B8, B9 reuse the same two disks, and later ones depend on the layout of earlier ones.
| Task | Topic | Points | Minutes | Skills it draws on |
|---|---|---|---|---|
| B1 | Repos, packages, Flatpak | 14 | 8 | Software Management |
| B2 | Target, services, journal | 12 | 6 | Services, Targets and Boot; Processes, Tuning and Logs |
| B3 | tuned, nice | 10 | 5 | Processes, Tuning and Logs |
| B4 | Process, GRUB | 10 | 6 | Processes; Services, Targets and Boot |
| B5 | Root recovery | 14 | 8 | Services, Targets and Boot |
| B6 | LVM, XFS | 16 | 8 | Storage and LVM |
| B7 | Extend LV | 8 | 4 | Storage and LVM |
| B8 | Swap | 8 | 4 | Storage and LVM |
| B9 | ext4 / VFAT labels | 8 | 5 | File Systems, NFS and Autofs |
B1 __/14 B2 __/12 B3 __/10 B4 __/10 B5 __/14 B6 __/16 B7 __/8 B8 __/8 B9 __/8 Part B = ___/100
Marking Part B
| Common reason for a lost point | Where it came from |
|---|---|
Repository file has the right sections but a wrong baseurl (two slashes instead of three) | B1 |
Packages installed but httpd not enabled | B1/B2 |
| Flatpak remote added as user, not system; or the app installed for the user only | B1 |
| Journal directory created but no size limit, or the reverse | B2 |
tuned profile set but the service not enabled | B3 |
renice on the wrong PID, or the nice value set by the wrong command (nice of a running process does nothing) | B3 |
GRUB timeout edited but grub2-mkconfig not run | B4 |
Forgot touch /.autorelabel, so the password works but login is denied | B5 |
Extent size left at the default 4 MiB, or -L 20 instead of -l 20 | B6 |
| fstab line by device path instead of UUID/label | B6, B8, B9 |
mklabel repeated on /dev/vdc, which destroyed the swap partition | B9 |
Total available in Part B: 100 points. Write your score before starting Part C.
Practice
0 of 9 done
Do these on your own system. They get harder. Check each result, then tick it off.
- Practice
B1 · Repositories, packages and Flatpak (14 points, 8 min)
On node1:
- Make sure the installation media at
/dev/sr0is mounted at/mnt/dvdat every boot, read-only. - Configure two repositories in the file
/etc/yum.repos.d/exam.repo:exam-baseosforfile:///mnt/dvd/BaseOSandexam-appstreamforfile:///mnt/dvd/AppStream. Both enabled; signature checking is off because the key is not available. - Install the packages
tree,lsofandhttpd. - Add a system-wide Flatpak remote named
labusing the URL given by your lab (practice:https://dl.flathub.org/repo/flathub.flatpakrepo), and install the applicationorg.gnome.Calculatorfrom it for all users.
Check your result
findmnt /mnt/dvdshowsiso9660;grep /mnt/dvd /etc/fstabshows aniso9660line;sudo mount -aprints nothing.dnf repolistlistsexam-baseosandexam-appstream;grep gpgcheck /etc/yum.repos.d/exam.reposhowsgpgcheck=0twice.rpm -q tree lsof httpdprints three versions.flatpak remotesshowslabwithsystem;flatpak listshowsorg.gnome.Calculator.
Hint
fstab:
/dev/sr0 /mnt/dvd iso9660 ro 0 0. Two[section]blocks in one.repofile.flatpak remote-add --if-not-exists lab URLandflatpak install -y lab APPIDas root.Solution
sudo mkdir -p /mnt/dvd grep -q /mnt/dvd /etc/fstab || echo '/dev/sr0 /mnt/dvd iso9660 ro 0 0' | sudo tee -a /etc/fstab sudo systemctl daemon-reload && sudo mount -a sudo tee /etc/yum.repos.d/exam.repo <<'EOT' [exam-baseos] name=Exam BaseOS baseurl=file:///mnt/dvd/BaseOS enabled=1 gpgcheck=0 [exam-appstream] name=Exam AppStream baseurl=file:///mnt/dvd/AppStream enabled=1 gpgcheck=0 EOT sudo dnf clean all && dnf repolist sudo dnf install -y tree lsof httpd sudo flatpak remote-add --if-not-exists lab https://dl.flathub.org/repo/flathub.flatpakrepo sudo flatpak install -y lab org.gnome.Calculator flatpak list - Make sure the installation media at
- Practice
B2 · Default target, services and the journal (12 points, 6 min)
On node1:
- The system must boot into the text multi-user target by default.
httpdmust be running now and start at every boot. The same for theatdservice (install theatpackage if needed).- The system journal must be kept across reboots, and the journal must never use more than 200 MB on disk.
Check your result
systemctl get-defaultprintsmulti-user.target.systemctl is-active httpd atdprintsactivetwice;systemctl is-enabled httpd atdprintsenabledtwice.ls -d /var/log/journalexists;journalctl --list-bootsshows more than one boot after the final reboot.grep -r SystemMaxUse /etc/systemd/journald.conf /etc/systemd/journald.conf.d/showsSystemMaxUse=200M;journalctl --disk-usageruns without error.
Hint
systemctl set-default,systemctl enable --now,mkdir /var/log/journal, and a drop-in file in/etc/systemd/journald.conf.d/with[Journal],Storage=persistent,SystemMaxUse=200M, then restartsystemd-journald.Solution
sudo systemctl set-default multi-user.target sudo dnf install -y at sudo systemctl enable --now httpd atd sudo mkdir -p /var/log/journal /etc/systemd/journald.conf.d printf '[Journal]\nStorage=persistent\nSystemMaxUse=200M\n' | sudo tee /etc/systemd/journald.conf.d/persist.conf sudo systemctl restart systemd-journald sudo journalctl --flush systemctl get-default; systemctl is-active httpd atd; systemctl is-enabled httpd atd - Warm-up
B3 · tuned profile and process priority (10 points, 5 min)
On node1:
- Install and enable
tuned, and apply the profile thattuned-admrecommends for this system. It must stay active after a reboot. - Start
sleep 7200in the background as userharrywith a nice value of15. Then, while it is running, change its nice value to5. Leave it running.
Check your result
systemctl is-enabled tunedisenabled;tuned-adm activeprints the same profile astuned-adm recommend.ps -u harry -o pid,ni,comm | grep sleepshows nice value5.
Hint
tuned-adm profile $(tuned-adm recommend).sudo -u harry nice -n 15 sleep 7200 &thensudo renice -n 5 -p PID(PID frompgrep -u harry sleep).Solution
sudo dnf install -y tuned sudo systemctl enable --now tuned sudo tuned-adm profile $(tuned-adm recommend) tuned-adm active sudo -u harry nice -n 15 sleep 7200 & sleep 1 sudo renice -n 5 -p $(pgrep -u harry sleep) ps -u harry -o pid,ni,comm - Install and enable
- Practice
B4 · Runaway process and boot loader (10 points, 6 min)
Setup for practice:
sudo bash -c 'dd if=/dev/zero of=/dev/null & echo started'.On node1:
- One process is using nearly 100 % of a CPU. Identify it, write its PID to the file
/root/hog.pid, and terminate it. - Add the kernel argument
audit=1to every installed kernel permanently, and set the GRUB menu timeout to8seconds. Regenerate the configuration as needed.
Check your result
cat /root/hog.pidshows the PID of the formerddprocess;ps -p $(cat /root/hog.pid)shows nothing running.sudo grubby --info=ALL | grep argsshowsaudit=1for every entry.grep ^GRUB_TIMEOUT /etc/default/grubshowsGRUB_TIMEOUT=8;grep -m1 'set timeout' /boot/grub2/grub.cfgshowstimeout=8(or the$timeoutvariable set to 8).
Hint
ps -eo pid,%cpu,comm --sort=-%cpu | head -3. Send the default signal first.grubby --update-kernel=ALL --args="audit=1", editGRUB_TIMEOUT,grub2-mkconfig -o /boot/grub2/grub.cfg.Solution
ps -eo pid,%cpu,comm --sort=-%cpu | head -3 pid=$(ps -eo pid,%cpu,comm --sort=-%cpu | awk 'NR==2 {print $1}') echo "$pid" | sudo tee /root/hog.pid sudo kill "$pid" sudo grubby --update-kernel=ALL --args="audit=1" sudo sed -i 's/^GRUB_TIMEOUT=.*/GRUB_TIMEOUT=8/' /etc/default/grub sudo grub2-mkconfig -o /boot/grub2/grub.cfg sudo grubby --info=ALL | grep args - One process is using nearly 100 % of a CPU. Identify it, write its PID to the file
- Challenge
B5 · Reset the root password on node2 (14 points, 8 min)
The root password of node2 is unknown. Using the console of the virtual machine, set it to
Ex200!Lab. After the reboot, root must be able to log in at the console, and SELinux must still be enforcing.Check your result
- Log in on node2's console as
rootwithEx200!Lab. getenforceon node2 printsEnforcing.ls /.autorelabelon node2 reports that the file does not exist (the relabel has finished).ping -c1 node2.lab.examplefrom node1 answers once node2 is up.
Hint
Reboot, press
eat GRUB, appendrd.breakto thelinuxline,Ctrl+x. Thenmount -o remount,rw /sysroot,chroot /sysroot,passwd,touch /.autorelabel,exit,exit.Solution
1. Reboot node2. At the GRUB menu press e on the first entry. 2. On the line beginning with "linux" press End and add: rd.break 3. Ctrl+x to boot. 4. switch_root:/# mount -o remount,rw /sysroot 5. switch_root:/# chroot /sysroot 6. sh-5.2# echo 'root:Ex200!Lab' | chpasswd (or: passwd root) 7. sh-5.2# touch /.autorelabel 8. sh-5.2# exit 9. switch_root:/# exit -> the machine relabels and reboots by itself - Log in on node2's console as
- Practice
B6 · LVM and XFS (16 points, 8 min)
On node1, using
/dev/vdb:- Create a GPT partition table and one partition of 1 GiB (use the whole disk) with type Linux LVM.
- Create a physical volume on it and a volume group
vgappwith a physical extent size of 16 MiB. - Create a logical volume
lvappof 20 extents. - Create an XFS file system with the label
appon it. - Mount it permanently on
/srv/app, using its UUID in/etc/fstab.
Check your result
sudo parted /dev/vdb printshowsPartition Table: gptand one partition.sudo vgs -o vg_name,vg_extent_sizeshowsvgapp 16.00m;sudo lvs -o lv_name,lv_sizeshowslvapp 320.00m.blkid /dev/vgapp/lvappshowsTYPE="xfs"andLABEL="app".grep /srv/app /etc/fstabbegins withUUID=matchingblkid -s UUID -o value /dev/vgapp/lvapp;findmnt /srv/applists it;sudo mount -ais silent.
Hint
parted -s /dev/vdb mklabel gpt mkpart lvm 1MiB 100%andset 1 lvm on,pvcreate,vgcreate -s 16M,lvcreate -n lvapp -l 20 vgapp,mkfs.xfs -L app.Solution
sudo parted -s /dev/vdb mklabel gpt mkpart lvm 1MiB 100% set 1 lvm on sudo partprobe /dev/vdb sudo pvcreate /dev/vdb1 sudo vgcreate -s 16M vgapp /dev/vdb1 sudo lvcreate -n lvapp -l 20 vgapp sudo mkfs.xfs -L app /dev/vgapp/lvapp sudo mkdir -p /srv/app uuid=$(sudo blkid -s UUID -o value /dev/vgapp/lvapp) echo "UUID=$uuid /srv/app xfs defaults 0 0" | sudo tee -a /etc/fstab sudo systemctl daemon-reload && sudo mount -a echo data | sudo tee /srv/app/test.txt findmnt /srv/app - Practice
B7 · Extend the volume (8 points, 4 min)
On node1 resize
lvappso that it is approximately 700 MiB, and make the file system use the new space. The file system must stay mounted and/srv/app/test.txtmust remain readable.Check your result
sudo lvs -o lv_name,lv_size vgappshowslvappbetween about690mand720m.df -h /srv/appshows a size of about 700 MiB (a little less).cat /srv/app/test.txtprintsdata;findmnt /srv/appstill lists the mount.
Hint
lvextend -r -L 700M /dev/vgapp/lvappgives a final size. With 16 MiB extents the result is 704 MiB (44 extents).Solution
sudo lvextend -r -L 700M /dev/vgapp/lvapp sudo lvs -o lv_name,lv_size vgapp df -h /srv/app cat /srv/app/test.txt - Practice
B8 · Add swap (8 points, 4 min)
On node1, on the second disk
/dev/vdc: create a GPT label and a partition of 512 MiB with type Linux swap. Make it available as swap now and at every boot, referencing it by UUID. The existing swap must stay.Check your result
swapon --showlists the new partition (/dev/vdc1,512M) and the previous swap.grep swap /etc/fstabhas aUUID=line for it with typeswap.free -m | grep Swaptotal grew by about 512.
Hint
parted -s /dev/vdc mklabel gpt mkpart swap linux-swap 1MiB 513MiB,mkswap /dev/vdc1,swapon,blkidfor the UUID.Solution
sudo parted -s /dev/vdc mklabel gpt mkpart swap linux-swap 1MiB 513MiB sudo partprobe /dev/vdc sudo mkswap /dev/vdc1 sudo swapon /dev/vdc1 uuid=$(sudo blkid -s UUID -o value /dev/vdc1) echo "UUID=$uuid none swap defaults 0 0" | sudo tee -a /etc/fstab sudo systemctl daemon-reload swapon --show - Practice
B9 · Labelled ext4 and VFAT file systems (8 points, 5 min)
On node1, in the free space of
/dev/vdcwithout changing the swap partition:- Add a 256 MiB partition with an ext4 file system labelled
data, mounted permanently on/srv/databy label. - Add a 200 MiB partition with a VFAT file system labelled
EXCH, mounted permanently on/mnt/exchange, where every user can read and write.
Check your result
lsblk -f /dev/vdcshowsswap,ext4 dataandvfat EXCH; the swap partition is unchanged and still active.grep -E 'LABEL=(data|EXCH)' /etc/fstabshows both lines;sudo mount -ais silent;findmnt /srv/data /mnt/exchangelists both.sudo -u sarah touch /mnt/exchange/xsucceeds.
Hint
Use
parted print freeto find where the free space starts, thenmkpartafter the swap partition (nomklabel!).mkfs.ext4 -L data,mkfs.vfat -n EXCH, optionsdefaults,umask=000for VFAT.Solution
sudo parted /dev/vdc unit MiB print free sudo parted -s /dev/vdc mkpart data ext4 513MiB 769MiB sudo parted -s /dev/vdc mkpart exch fat32 769MiB 969MiB sudo partprobe /dev/vdc sudo dnf install -y dosfstools sudo mkfs.ext4 -L data /dev/vdc2 sudo mkfs.vfat -n EXCH /dev/vdc3 sudo mkdir -p /srv/data /mnt/exchange printf 'LABEL=data /srv/data ext4 defaults 0 0\nLABEL=EXCH /mnt/exchange vfat defaults,umask=000 0 0\n' | sudo tee -a /etc/fstab sudo systemctl daemon-reload && sudo mount -a findmnt /srv/data /mnt/exchange lsblk -f /dev/vdc - Add a 256 MiB partition with an ext4 file system labelled