Bookmark this page

Lab: Fix Boot Issues and Maintain Servers

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.

Troubleshoot and repair boot problems and update the system default target. You also schedule tasks to run on a repeating schedule as a normal user.

Outcomes

  • Diagnose issues and recover the system from emergency mode.

  • Change the default target from graphical.target to multi-user.target.

  • Schedule recurring jobs to run as a normal user.

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-compreview1

Specifications

  • On workstation, run the /tmp/rhcsa-break1 script. This script causes an issue with the boot process on serverb and then reboots the machine. Troubleshoot the cause and repair the boot issue. When prompted, use redhat as the password of the root user.

  • On workstation, run the /tmp/rhcsa-break2 script. This script causes the default target to switch from the multi-user target to the graphical target on the serverb machine and then reboots the machine. On serverb, reset the default target to use the multi-user target. The default target settings must persist after reboot without manual intervention. As the student user, use the sudo command for performing privileged commands. Use student as the password, when required.

  • On serverb, schedule a recurring job as the student user that executes the /home/student/backup-home.sh script hourly between 7 PM and 9 PM every day except on Saturday and Sunday. Download the backup script from http://materials.example.com/labs/backup-home.sh. The backup-home.sh script backs up the /home/student directory from serverb to servera in the /home/student/serverb-backup directory. Use the backup-home.sh script to schedule the recurring job as the student user. Run the command as an executable.

  • Reboot the serverb machine and wait for the boot to complete before grading.

  1. On workstation, run the /tmp/rhcsa-break1 script.

    [student@workstation ~]$ sh /tmp/rhcsa-break1
  2. After the serverb machine boots, access the console and notice that the boot process stopped early. Consider a possible cause for this behavior.

    1. Locate the icon for the serverb console, as appropriate for your classroom environment. Open the console and inspect the error. It might take a few seconds for the error to appear.

    2. Press Ctrl+Alt+Del to reboot the serverb machine. When the boot-loader menu appears, press any key except Enter to interrupt the countdown.

    3. Edit the default boot-loader entry, in memory, to log in to the emergency mode. Press e to edit the current entry.

    4. Use the cursor keys to navigate to the line that starts with linux. Append systemd.unit=emergency.target.

    5. Press Ctrl+x to boot with the modified configuration.

    6. Log in to emergency mode. Use redhat as the root user's password.

      Give root password for maintenance
      (or press Control-D to continue): redhat
      [root@serverb ~]#
  3. Remount the / file system with read and write capabilities. Use the mount -a command to try to mount all the other file systems.

    1. Remount the / file system with read and write capabilities to edit the file system.

      [root@serverb ~]# mount -o remount,rw /
    2. Try to mount all the other file systems. Notice that one of the file systems does not mount.

      [root@serverb ~]# mount -a
      ...output omitted...
      mount: /FakeMount: can't find UUID=fake.
    3. Edit the /etc/fstab file to fix the issue. Remove or comment out the incorrect line.

      [root@serverb ~]# vi /etc/fstab
      ...output omitted...
      #UUID=fake     /FakeMount  xfs   defaults    0 0
    4. Update the systemd daemon for the system to register the new /etc/fstab file configuration.

      [root@serverb ~]# systemctl daemon-reload
      [ 206.828912] systemd[1]: Reloading.
    5. Verify that /etc/fstab file is now correct by attempting to mount all entries.

      [root@serverb ~]# mount -a
    6. Reboot serverb and wait for the boot to complete. The system should now boot without errors.

      [root@serverb ~]# systemctl reboot
  4. On workstation, run the /tmp/rhcsa-break2 script. Wait for the serverb machine to reboot before proceeding.

    [student@workstation ~]$ sh /tmp/rhcsa-break2
  5. On serverb, set the multi-user target as the current and default target.

    1. Log in to serverb as the student user.

      [student@workstation ~]$ ssh student@serverb
      ...output omitted...
      [student@serverb ~]$
    2. Determine the default target.

      [student@serverb ~]$ systemctl get-default
      graphical.target
    3. Switch to the multi-user target.

      [student@serverb ~]$ sudo systemctl isolate multi-user.target
      [sudo] password for student: student
    4. Set the multi-user target as the default target.

      [student@serverb ~]$ sudo systemctl set-default multi-user.target
      Removed /etc/systemd/system/default.target.
      Created symlink /etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target.
    5. Reboot serverb and verify that the multi-user target is set as the default target.

      [student@serverb ~]$ sudo systemctl reboot
      Connection to serverb closed by remote host.
      Connection to serverb closed.
      [student@workstation ~]$
    6. After the system reboots, open an SSH session to serverb as the student user. Verify that the multi-user target is set as the default target.

      [student@workstation ~]$ ssh student@serverb
      ...output omitted...
      [student@serverb ~]$ systemctl get-default
      multi-user.target
  6. On serverb, schedule a recurring job as the student user that executes the /home/student/backup-home.sh script hourly between 7 PM and 9 PM on all days except Saturday and Sunday. Use the backup-home.sh script to schedule the recurring job. Download the backup script from http://materials.example.com/labs/backup-home.sh. Run the command as an executable.

    1. On serverb, download the backup script from http://materials.example.com/labs/backup-home.sh. Use chmod to make the backup script executable.

      [student@serverb ~]$ wget http://materials.example.com/labs/backup-home.sh
      ...output omitted...
      [student@serverb ~]$ chmod +x backup-home.sh
    2. Open the crontab file with the default text editor.

      [student@serverb ~]$ crontab -e
    3. Edit the file to add the following line:

      0 19-21 * * Mon-Fri /home/student/backup-home.sh

      Save the changes and exit the editor.

    4. Use the crontab -l command to list the scheduled recurring jobs.

      [student@serverb ~]$ crontab -l
      0 19-21 * * Mon-Fri /home/student/backup-home.sh
  7. Reboot serverb and wait for the boot to complete before grading.

    [student@serverb ~]$ sudo systemctl reboot
    [sudo] password for student: student
    Connection to serverb closed by remote host.
    Connection to serverb closed.
    [student@workstation ~]$

Evaluation

As the student user on the workstation machine, use the lab command to grade your work. Correct any reported failures and rerun the command until successful.

[student@workstation ~]$ lab grade rhcsa-compreview1

Finish

On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish rhcsa-compreview1

Revision: rh134-9.3-5fd2368