Bookmark this page

Lab: Control the Boot Process

In this lab, you reset the root password on a system, recover from a misconfiguration, and set the default boot target.

Outcomes

  • Reset a lost password for the root user.

  • Diagnose and fix boot issues.

  • Set the default systemd target.

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 boot-review

Instructions

  1. On the serverb machine, reset the password to redhat for the root user.

    Locate the icon for the serverb machine console as appropriate for your classroom environment, and then open the console.

    1. Send Ctrl+Alt+Del to your system by using the relevant button or menu entry.

    2. When the boot-loader menu appears, press any key to interrupt the countdown, except the Enter key.

    3. Use the cursor keys to highlight the rescue kernel boot-loader entry (the one with the rescue word in its name).

    4. Press e to edit the current entry.

    5. Use the cursor keys to navigate the line that starts with the linux text.

    6. Press Ctrl+e to move the cursor to the end of the line.

    7. Append the rd.break text to the end of the line.

      Note

      If it is difficult for you to see the text in the console, consider changing the resolution when editing the kernel line in the boot loader entry.

      To change the console resolution, add either video=640x480 or vga=ask on the line that starts with the linux word, after rd.break. For most consoles, a resolution of 640x480 is enough. By using vga=ask, you can choose a more suitable resolution for your environment.

    8. Press Ctrl+x to boot by using the modified configuration.

    9. Press Enter to enter the maintenance mode.

    10. At the sh-5.1 prompt, remount the /sysroot file system as writable, and then use the chroot command for the /sysroot directory.

      sh-5.1# mount -o remount,rw /sysroot
      ...output omitted...
      sh-5.1# chroot /sysroot
    11. Set redhat as the password for the root user.

      sh-5.1# passwd root
      Changing password for user root.
      New password: redhat
      BAD PASSWORD: The password is shorter than 8 characters
      Retype new password: redhat
      passwd: all authentication tokens updated successfully.
    12. Configure the system to perform a full SELinux relabeling after booting.

      sh-5.1# touch /.autorelabel
    13. Exit the chroot environment and the sh-5.1 prompt. After the file system is relabeled, the system prompts to enter maintenance mode. However, if you wait, then it completes the reboot and shows the boot-loader menu.

  2. In the boot-loader menu, select the default kernel boot-loader entry. The system fails to boot, because a start job does not complete successfully. Fix the issue from the console of the serverb machine.

    1. Boot the system into emergency mode. Reboot the serverb machine by sending Ctrl+Alt+Del to your system by using the relevant button or menu entry.

    2. When the boot-loader menu appears, press any key to interrupt the countdown, except Enter.

    3. Use the cursor keys to highlight the default boot-loader entry.

    4. Press e to edit the current entry.

    5. Use the cursor keys to navigate the line that starts with the linux text.

    6. Press Ctrl+e to move the cursor to the end of the line.

    7. Append the systemd.unit=emergency.target text to the end of the line.

    8. Press Ctrl+x to boot by using the modified configuration.

    9. Log in to emergency mode.

      Give root password for maintenance
      (or press Control-D to continue): redhat
      [root@serverb ~]#
    10. Remount the / file system as writable.

      [root@serverb ~]# mount -o remount,rw /
      ...output omitted...
    11. Mount all file systems.

      [root@serverb ~]# mount -a
      mount: /olddata: can't find UUID=4d5c85a5-8921-4a06-8aff-80567e9689bc.
    12. Edit the /etc/fstab file to remove or comment out the incorrect line that mounts the /olddata mount point.

      [root@serverb ~]# vim /etc/fstab
      ...output omitted...
      #UUID=4d5c85a5-8921-4a06-8aff-80567e9689bc  /olddata  xfs  defaults  0 0
    13. Update the systemd daemon for the system to register the changes in the /etc/fstab file configuration.

      [root@serverb ~]# systemctl daemon-reload
    14. Verify that the /etc/fstab file configuration is correct by attempting to mount all entries.

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

      [root@serverb ~]# systemctl reboot
  3. Change the default systemd target on the serverb machine for the system to automatically start a graphical interface when it boots.

    No graphical interface is installed on the serverb machine. Set only the default target, and do not install the packages.

    1. Log in to the serverb machine as the student user and switch to the root user.

      [student@workstation ~]$ ssh student@serverb
      ...output omitted...
      [student@serverb ~]$ sudo -i
      [sudo] password for student: student
      [root@serverb ~]#
    2. Set the graphical.target as the default target.

      [root@serverb ~]# systemctl set-default graphical.target
      Removed /etc/systemd/system/default.target.
      Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/graphical.target.
    3. Verify that the correct default is set.

      [root@serverb ~]# systemctl get-default
      graphical.target
    4. Return to the workstation machine as the student user.

      [root@serverb ~]# exit
      logout
      [student@serverb ~]$ exit
      logout
      Connection to serverb closed.

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 boot-review

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 boot-review

This concludes the section.

Revision: rh134-9.0-fa57cbe