Bookmark this page

Lab: Resolving a Console Login Issue

Reset a root password and repair a boot issue.

Outcomes

You should be able to successfully reset a root password and repair a boot issue.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

This command modifies the root password and boot parameters.

[student@workstation ~]$ lab start compreview-review2

Important

This lab is intended to practice the technique to use on a physical system that might not be network-accessible. You are asked to assume that you do not have ssh access to serverb, and that the student account on serverb does not have full sudo access. Access a direct virtual console to serverb by using the appropriate method for your classroom environment.

Specifications

  • Users report that the serverb system displays an error and hangs during the boot process. While troubleshooting, your colleague accidentally modified the root password of the serverb system to an unknown value.

    • Reset the root password to redhat.

    • Repair the boot parameters so that the system boots without manual intervention.

  1. Reset the root password. Ignore the malfunctioning default boot entry for now.

    1. If the grub2 boot menu is not visible, then reboot the system.

    2. Highlight the Red Hat Enterprise Linux 8.4 (Ootpa) boot entry, and press e to edit it.

    3. Scroll down to the line that starts with linux, press Ctrl+e to jump to the end of the line, remove all console= settings (if any), and append rd.break.

    4. Press Ctrl+x to boot with these modified settings.

    5. Remount the file system on /sysroot with read-write capabilities.

      switch_root:/# mount -o remount,rw /sysroot
    6. Change the root directory to /sysroot.

      switch_root:/# chroot /sysroot
    7. Set the root password to redhat.

      sh-4.2# echo "root:redhat" | chpasswd
    8. Force SELinux to relabel all files during the next boot.

      sh-4.2# touch /.autorelabel
    9. Reboot your system by typing exit twice. On rebooting, select the Red Hat Enterprise Linux 8.4 (Ootpa) boot entry.

      sh-4.2# exit
      exit
      switch_root:/# exit
      exit
    10. Log in to the console as the root user with the password redhat.

      serverb login: root
      Password: redhat
      [root@serverb ~]#
  2. Repair the boot issue.

    1. Query the current boot entries.

      [root@serverb ~]# grubby --info=ALL
      index=0
      kernel="/boot/vmlinuz-4.18.0-305.el8.x86_64"
      args="ro no_timer_check net.ifnames=0 crashkernel=auto $tuned_params"
      root="/dev/vda3"
      initrd="/boot/initramfs-4.18.0-305.el8.x86_64.img $tuned_initrd"
      title="Red Hat Enterprise Linux (4.18.0-305.el8.x86_64) 8.4 (Ootpa)"
      id="ffffffffffffffffffffffffffffffff-4.18.0-305.el8.x86_64"
      index=1
      kernel="/boot/vmlinuz-newboot"
      args="ro no_timer_check net.ifnames=0 crashkernel=auto"
      root="/dev/vda3"
      initrd="/boot/initramfs-newboot.img"
      title="NewBootHopeThisWorks"
      id="b39b2a9094e24603888d9d5b9ddc2740-newboot"
    2. Determine the default grub2 boot entry.

      [root@serverb ~]# grubby --default-kernel
      /boot/vmlinuz-newboot
    3. Change the default grub2 menu entry to use the kernel that does not have the newboot label. The version of the kernel will vary.

      [root@serverb ~]# grubby --set-default=/boot/vmlinuz-4.18.0-305.el8.x86_64
      The default is /boot/loader/entries/ffffffffffffffffffffffffffffffff-4.18.0-305.el8.x86_64.conf with index 0 and kernel /boot/vmlinuz-4.18.0-305.el8.x86_64
    4. Verify that the default kernel is set correctly.

      [root@serverb ~]# grubby --default-kernel
      /boot/vmlinuz-4.18.0-305.el8.x86_64
    5. Reboot the system and verify that the default grub2 menu entry boots correctly and displays the login prompt.

      [root@serverb ~]# reboot
      ...output omitted...
      serverb login:
    6. Return to workstation as the student user, with the appropriate technique for your classroom environment.

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 compreview-review2

Finish

As the student user on the workstation machine, use the lab command to complete this exercise. This is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish compreview-review2

Revision: rh342-8.4-6dd89bd