Basic System Recovery
When things go wrong, there are ways to fix problems. However, these methods require that you understand the system well. This chapter contains information on common problems you might face and it also describes installation program rescue mode, which can be used to fix these problems.
You might need to boot into installation program rescue mode for any of the following reasons:
You are unable to boot into CentOS normally.
You are having hardware or software problems, and you want to recover data from your system’s hard drive.
You forgot the root password.
This problem is often caused by the installation of another operating system after you have installed CentOS. Some other operating systems assume that you have no other operating system(s) on your computer. They overwrite the Master Boot Record (MBR) that originally contained the GRUB2 boot loader. If the boot loader is overwritten in this manner, you cannot boot CentOS unless you can boot into installation program rescue mode and reconfigure the boot loader.
Another common problem occurs when using a partitioning tool to resize a partition or create a new partition from free space after installation, and it changes the order of your partitions. If the partition number of your
/ partition changes, the boot loader might not be able to find it to mount the partition. To fix this problem, you will need to reinstall the boot loader. See Reinstalling the Boot Loader for instructions on how to do this.
This category includes a wide variety of different situations. Two examples include failing hard drives and specifying an invalid root device or kernel in the boot loader configuration file. If either of these occur, you might not be able to reboot into CentOS. However, if you boot into installation program rescue mode, you might be able to resolve the problem or at least get copies of your most important files.
See the corresponding section in the Red Hat Enterprise Linux 7 System Administrator’s Guide.
The Anaconda installation program’s rescue mode is a minimal Linux environment that can be booted from the CentOS 7.6.1810 DVD or other boot media. It contains command-line utilities for repairing a wide variety of issues. This rescue mode can be accessed from the Troubleshooting submenu of the boot menu. In this mode, you can mount file systems as read-only or even to not mount them at all, blacklist or add a driver provided on a driver disc, install or upgrade system packages, or manage partitions.
Anaconda rescue mode is different from rescue mode (an equivalent to single-user mode) and emergency mode, which are provided as parts of the systemd system and service manager. For more information about these modes, see Red Hat Enterprise Linux 7 System Administrator’s Guide.
To boot into Anaconda rescue mode, you must be able to boot the system using one CentOS boot media, such as a minimal boot disc or USB drive, or a full installation DVD.
For detailed information about booting the system using media provided by CentOS, see the appropriate chapters:
Booting the Installation on 64-bit AMD, Intel, and ARM systems for 64-bit AMD, Intel, and ARM systems
Booting the Installation on IBM Power Systems for IBM Power Systems servers
Advanced storage, such as iSCSI or zFCP devices, must be configured using
For information about
Boot the system from either minimal boot media, or a full installation DVD or USB drive, and wait for the boot menu to appear.
From the boot menu, either select the Rescue a CentOS system option from the Troubleshooting submenu, or append the
inst.rescueoption to the boot command line. To enter the boot command line, press the Tab key on BIOS-based systems or the e key on the UEFI-based systems.
If your system requires a third-party driver provided on a driver disc to boot, append the
inst.dd=driver_nameto the boot command line:
If a driver that is part of the CentOS 7.6.1810 distribution prevents the system from booting, append the
modprobe.blacklist=option to the boot command line:
For more information about blacklisting drivers, see Blacklisting a Driver (x86).
When ready, press Enter (BIOS-based systems) or Ctrl+X (UEFI-based systems) to boot the modified option. Then wait until the following message is displayed:
The rescue environment will now attempt to find your Linux installation and mount it under the
/mnt/sysimage/directory. You can then make any changes required to your system. If you want to proceed with this step choose 'Continue'. You can also choose to mount your file systems read-only instead of read-write by choosing 'Read-only'. If for some reason this process fails you can choose 'Skip' and this step will be skipped and you will go directly to a command line.
If you select Continue, it attempts to mount your file system under the directory
/mnt/sysimage/. If it fails to mount a partition, you will be notified. If you select Read-Only, it attempts to mount your file system under the directory
/mnt/sysimage/, but in read-only mode. If you select Skip, your file system is not mounted. Choose Skip if you think your file system is corrupted.
Once you have your system in rescue mode, a prompt appears on VC (virtual console) 1 and VC 2 (use the Ctrl+Alt+F1 key combination to access VC 1 and Ctrl+Alt+F2 to access VC 2):
Even if your file system is mounted, the default root partition while in Anaconda rescue mode is a temporary root partition, not the root partition of the file system used during normal user mode (
graphical.target). If you selected to mount your file system and it mounted successfully, you can change the root partition of the Anaconda rescue mode environment to the root partition of your file system by executing the following command:
This is useful if you need to run commands, such as
rpm, that require your root partition to be mounted as
/. To exit the
chroot environment, type
exit to return to the prompt.
If you selected Skip, you can still try to mount a partition or LVM2 logical volume manually inside Anaconda rescue mode by creating a directory, such as
/directory/, and typing the following command:
sh-4.2#mount -t xfs /dev/mapper/VolGroup00-LogVol02 /directory
In the above command,
/directory/ is a directory that you have created and
/dev/mapper/VolGroup00-LogVol02 is the LVM2 logical volume you want to mount. If the partition is a different type than XFS, replace the xfs string with the correct type (such as
If you do not know the names of all physical partitions, use the following command to list them:
If you do not know the names of all LVM2 physical volumes, volume groups, or logical volumes, use the
lvdisplay commands, respectively.
From the prompt, you can run many useful commands, such as:
pingif the network is started
For details, see the Red Hat Enterprise Linux 7 System Administrator’s Guide.
restorefor users with tape drives
fdiskfor managing partitions
For details, see the Red Hat Enterprise Linux 7 Storage Administration Guide.
rpmfor installing or upgrading software
For details, see the Red Hat Enterprise Linux 7 Administrator’s Guide
In some cases, the GRUB2 boot loader can mistakenly be deleted, corrupted, or replaced by other operating systems. The following steps detail the process on how GRUB is reinstalled on the master boot record:
Follow instructions in Booting into Anaconda Rescue Mode to boot into Anaconda rescue mode. Ensure that you mount the installed system’s
/(root) partition in read-write mode.
Change the root partition:
Use the following command to reinstall the GRUB2 boot loader, where install_device is the boot device (typically, /dev/sda):
Reboot the system.
Missing or malfunctioning drivers can cause problems when booting the system. Anaconda rescue mode provides an environment in which you can add, remove, or replace a driver even when the system fails to boot. Wherever possible, we recommend that you use the RPM package manager to remove malfunctioning drivers or to add updated or missing drivers.
When you install a driver from a driver disc, the driver disc updates all initramfs images on the system to use this driver. If a problem with a driver prevents a system from booting, you cannot rely on booting the system from another initramfs image.
Boot the system into Anaconda rescue mode. Follow the instructions in Booting into Anaconda Rescue Mode. Ensure that you mount the installed system in read-write mode.
Change the root directory to
rpm -ecommand to remove the driver package. For example, to remove the xorg-x11-drv-wacom driver package, run:
sh-4.2#rpm -e xorg-x11-drv-wacom
Exit the chroot environment:
If you cannot remove a malfunctioning driver for some reason, you can instead blacklist the driver so that it does not load at boot time. See Blacklisting a Driver (x86) and Boot Options for more information about blacklisting drivers.
Installing a driver is a similar process but the RPM package must be available on the system:
Boot the system into Anaconda rescue mode. Follow the instructions in Booting into Anaconda Rescue Mode. Do not choose to mount the installed system as read only.
Make the RPM package that contains the driver available. For example, mount a CD or USB flash drive and copy the RPM package to a location of your choice under
/mnt/sysimage/, for example:
Change the root directory to
rpm -ivhcommand to install the driver package. For example, to install the xorg-x11-drv-wacom driver package from
sh-4.2#rpm -ivh /root/drivers/xorg-x11-drv-wacom-0.23.0-6.el7.x86_64.rpm
/root/drivers/directory in this chroot environment is the
/mnt/sysimage/root/drivers/directory in the original rescue environment.
Exit the chroot environment:
When you have finished removing and installing drivers, reboot the system.