Reset the Root Password from the Boot Loader¶
This article provide the screenshot for each step: https://ankitkumarakt746.medium.com/reset-forgotten-red-hat-enterprise-linux-rhel-8-root-password-aeaa8fe17364
The instructions provided cover the steps to manually repair file-system issues during the boot process on a system running Red Hat Enterprise Linux 9. Here is a summarized and streamlined version of the process:
Repair File-system Issues at Boot¶
-
Identify the Issue:
- During boot, if the system encounters file-system issues, it may drop into an emergency shell.
- Common issues include corrupted file systems, nonexistent devices, or incorrect UUIDs in
/etc/fstab
.
-
Accessing the Emergency Shell:
- If prompted, enter the root password to access the emergency shell.
- Example error message during boot:
[* ] A start job is running for /dev/vda2 (27s / 1min 30s) [ TIME ] Timed out waiting for device /dev/vda2. [DEPEND] Dependency failed for /mnt/mountfolder [DEPEND] Dependency failed for Local File Systems. [DEPEND] Dependency failed for Mark need to relabel after reboot. [ OK ] Started Emergency Shell. [ OK ] Reached target Emergency Mode. Give root password for maintenance (or press Control-D to continue):
-
Repair Steps:
-
Check Mounted File Systems:
- Identify if the root file system is mounted as read-only (
ro
).
- Identify if the root file system is mounted as read-only (
-
Remount Root File System as Read/Write:
-
Edit
/etc/fstab
if Necessary:- Correct any errors in the
/etc/fstab
file (e.g., incorrect device names, UUIDs, or mount points).
- Correct any errors in the
-
Create Missing Mount Points:
-
Reload systemd Configuration:
-
Attempt to Mount All File Systems:
- This command will skip already mounted file systems and display any errors for others.
-
-
Reboot the System:
- Verify that the system boots normally and all file systems are mounted correctly.
Additional Tips:¶
- For quick testing, you can use the
nofail
option in/etc/fstab
entries to allow the system to boot even if a file system fails to mount. This should not be used for critical file systems required for applications:
What is
/etc/fstab
?¶The
/etc/fstab
file in Linux is a system configuration file that contains information about various file systems and how they should be automatically mounted during the boot process. The name stands for "file system table."Structure of
/etc/fstab
¶Each line in the
/etc/fstab
file corresponds to a file system and contains the following fields:
- File System (Device)
The device or partition to be mounted, specified by its device file (e.g.,
/dev/sda1
), UUID, or label.Mount Point
The directory where the file system should be mounted (e.g.,
/
,/home
,/mnt/data
).File System Type
The type of file system (e.g.,
ext4
,xfs
,nfs
).Mount Options
Options for mounting the file system (e.g.,
defaults
,ro
,rw
,nofail
,noatime
).Dump Frequency
A number indicating whether the file system should be backed up by the
dump
command (0 = no, 1 = yes).FSCK Order
- A number indicating the order in which file systems should be checked at boot time by the
fsck
command (0 = do not check, 1 = check first, 2 = check later).Example of
/etc/fstab
Entries¶Here is an example of what the
/etc/fstab
file might look like:# <file system> <mount point> <type> <options> <dump> <fsck order> UUID=123e4567-e89b-12d3-a456-426614174000 / ext4 defaults 1 1 UUID=123e4567-e89b-12d3-a456-426614174001 /home ext4 defaults 1 2 UUID=123e4567-e89b-12d3-a456-426614174002 swap swap defaults 0 0 UUID=123e4567-e89b-12d3-a456-426614174003 /mnt/data xfs defaults,nofail 0 0
Field Descriptions¶
- UUID=123e4567-e89b-12d3-a456-426614174000 / ext4 defaults 1 1
Mounts the file system with UUID
123e4567-e89b-12d3-a456-426614174000
at the root directory/
using theext4
file system type with default options, backs it up (1
), and checks it first during boot (1
).UUID=123e4567-e89b-12d3-a456-426614174001 /home ext4 defaults 1 2
Mounts the file system with UUID
123e4567-e89b-12d3-a456-426614174001
at/home
using theext4
file system type with default options, backs it up (1
), and checks it second during boot (2
).UUID=123e4567-e89b-12d3-a456-426614174002 swap swap defaults 0 0
Uses the file system with UUID
123e4567-e89b-12d3-a456-426614174002
as swap space with default options, does not back it up (0
), and does not check it during boot (0
).UUID=123e4567-e89b-12d3-a456-426614174003 /mnt/data xfs defaults,nofail 0 0
- Mounts the file system with UUID
123e4567-e89b-12d3-a456-426614174003
at/mnt/data
using thexfs
file system type with default options and thenofail
option, does not back it up (0
), and does not check it during boot (0
).Common Mount Options¶
- defaults: Uses the default mount options (
rw
,suid
,dev
,exec
,auto
,nouser
, andasync
).- ro: Mounts the file system as read-only.
- rw: Mounts the file system as read/write.
- nofail: Allows the system to continue booting even if the file system cannot be mounted.
- noatime: Prevents updating the access time on files (useful for performance).
Usage¶
The
/etc/fstab
file is crucial for system booting and for ensuring that all necessary file systems are available for use. It allows for automated and consistent mounting of file systems, which helps maintain system stability and reliability.