Switching to the /bin/bash directory in rescue mode on a CentOS virtual machine returns an error. What should I do?

Symptom

Switching to the /bin/bash directory in rescue mode on a CentOS virtual machine returns a No such file or directory error.

Cause

The virtual machine is missing required dependency libraries. The bash environment of the system must be restored.

Solution

  1. Locate the affected virtual machine, click Modify Configuration > Optical Drive > Image File, and load the CentOS ISO file into the virtual machine.

  2. On the virtual machine details page, click Advanced Settings > Boot Options > Boot Order to open the boot order settings and change the virtual machine boot order to optical drive first.

  3. Enter the installation page and select Troubleshooting.

    As shown in Figure 1:

    Select Troubleshooting

  4. Select Rescue a CentOS system to enter rescue mode.

    As shown in Figure 2:

    Select Rescue a CentOS system

  5. In the rescue mode interface, enter 1 to mount the system root file system to the /mnt/sysimage directory in read-write mode. To switch the /mnt/sysimage directory to the root directory, run the chroot /mnt/sysimage command.

    As shown in Figure 3:

    Mount the system root file in read-write mode

  6. Run the following commands to copy the lib and lib64 dependency libraries from the rescue mode system to the /mnt/sysimage/usr/lib and /mnt/sysimage/usr/lib64 directories respectively:

    [root@localhost ~]# cp -r /usr/lib /mnt/sysimage/usr/lib
    [root@localhost ~]# cp -r /usr/lib64 /mnt/sysimage/usr/lib64

    The version of the newly loaded CentOS image must match the version of the virtual machine's original image.

  7. Switch the /mnt/sysimage directory back to the root directory and verify that the CentOS virtual machine environment is restored.

On this page