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
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.
Send Ctrl+Alt+Del to your system by using the relevant button or menu entry.
When the boot-loader menu appears, press any key to interrupt the countdown, except the Enter key.
Use the cursor keys to highlight the rescue kernel boot-loader entry (the one with the rescue word in its name).
Press e to edit the current entry.
Use the cursor keys to navigate the line that starts with the linux text.
Press Ctrl+e to move the cursor to the end of the line.
Append the rd.break text to the end of the line.
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.
Press Ctrl+x to boot by using the modified configuration.
Press Enter to enter the maintenance mode.
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
Set redhat as the password for the root user.
sh-5.1#passwd rootChanging password for user root. New password:redhatBAD PASSWORD: The password is shorter than 8 characters Retype new password:redhatpasswd: all authentication tokens updated successfully.
Configure the system to perform a full SELinux relabeling after booting.
sh-5.1# touch /.autorelabelExit 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.
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.
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.
When the boot-loader menu appears, press any key to interrupt the countdown, except Enter.
Use the cursor keys to highlight the default boot-loader entry.
Press e to edit the current entry.
Use the cursor keys to navigate the line that starts with the linux text.
Press Ctrl+e to move the cursor to the end of the line.
Append the systemd.unit=emergency.target text to the end of the line.
Press Ctrl+x to boot by using the modified configuration.
Log in to emergency mode.
Give root password for maintenance
(or press Control-D to continue): redhat
[root@serverb ~]#Remount the / file system as writable.
[root@serverb ~]# mount -o remount,rw /
...output omitted...Mount all file systems.
[root@serverb ~]# mount -a
mount: /olddata: can't find UUID=4d5c85a5-8921-4a06-8aff-80567e9689bc.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 0Update the systemd daemon for the system to register the changes in the /etc/fstab file configuration.
[root@serverb ~]# systemctl daemon-reloadVerify that the /etc/fstab file configuration is correct by attempting to mount all entries.
[root@serverb ~]# mount -aReboot the system and wait for the boot to complete. The system should now boot normally.
[root@serverb ~]# systemctl rebootChange 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.
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 ~]#
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.Verify that the correct default is set.
[root@serverb ~]# systemctl get-default
graphical.targetReturn to the workstation machine as the student user.
[root@serverb ~]#exitlogout [student@serverb ~]$exitlogout Connection to serverb closed.
This concludes the section.