You are on page 1of 7

Booting into rescue mode

Boot the system using installation DVD or ISO and enter into the rescue mode. Follow
the steps below for a detailed instruction on how to boot into rescue mode.

1. Attach the ISO image


You can use an actual installation DVD instead of ISO image, but I find using ISO image
easy and there is no need to go to the data center to physically insert the DVD into the
system. Different virtualization platforms have similar features to attach/mount the ISO
image to a VM guest. Make sure you change the boot order to boot from the ISO image.

2. Boot up the system


Boot up the CentOS 7 system from ISO image. At the boot screen, Select
the Troubleshooting option at the end of the screen.

3. At the next screen, select the option Rescue a CentOS Linux system.


4. On the next screen, press enter to continue. When asked if you would like Rescue to
find your installation, choose Continue.
If you run into trouble detecting your install, retry using the Skip option and manually
detect and mount your storage. You would get a message shown in the picture below if
the rescue mode has detected the correct installation.

Now we skip the chroot step here as we do not want to enter the root environment.

Installing the kernel


1. Next is to install the kernel appropriate to your installed system. It is important to have
same installation media as that of the installed system version. Install the kernel using
rpm command on the root environment /mnt/sysimage.

1 # cd /mnt/install/repo/Packages
2 # rpm -ivh --root=/mnt/sysimage kernel-3.10.0-514.el7.x86_64

If there is a newer kernel already present in the system you will be prompted that newer
version of the package is already installed.

In this case you will need to add --force key like follows:


1 # rpm -ivh --force --root=/mnt/sysimage kernel-3.10.0-514.el7.x86_64

2. Generate Grub2 configuration – Next step is to change your root directory


to /mnt/sysimage using the chroot command. This makes your system the root
environment. Here you can generate the grub2 configuration for the newly installed
kernel.

1 # chroot /mnt/sysimage
2 # grub2-mkconfig -o /boot/grub2/grub.cfg

3. Verify – Check for the file in /boot to have the new kernel. Also verify the kernel
menuentry in the file /boot/grub2/grub.cfg.

1 ls -lrt /boot/vmlinuz-*
2 -rwxr-xr-x. 1 root root 5392080 Nov 22  2016 /boot/vmlinuz-3.10.0-514.el7.x86_64
3 -rwxr-xr-x. 1 root root 5392080 Oct  1 12:44 /boot/vmlinuz-0-rescue-4bd23218ddab41e587bdd39ae2cfc09a

1 # cat /boot/grub2/grub.cfg
2 .....
3 menuentry 'CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os
4 --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.el7.x86_64-advanced-7efe94a2-10ec-40e4-8d89-a52faf13535e' {
5 load_video
6 set gfxpayload=keep
7 insmod gzio
8 insmod part_msdos
9 insmod xfs
10 set root='hd0,msdos1'
11 if [ x$feature_platform_search_hint = xy ]; then
12   search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-
13 baremetal=ahci0,msdos1 --hint='hd0,msdos1'  f88bd588-6f4d-4050-bd3f-443cf2049ee7
14 else
15   search --no-floppy --fs-uuid --set=root f88bd588-6f4d-4050-bd3f-443cf2049ee7
16 fi
linux16 /vmlinuz-3.10.0-514.el7.x86_64 root=/dev/mapper/cl-root ro crashkernel=auto rd.lvm.lv=cl/root
rd.lvm.lv=cl/swap rhgb quiet LANG=en_US.UTF-8
17
initrd16 /initramfs-3.10.0-514.el7.x86_64.img
18
}
.....

4. Filesystems relabeling
Create the file /.autorelabel to relabel the filesystems, during the next reboot, in case
you are using SELinux:

1 # touch /.autorelabel

You can now exit the chroot environment and reboot the system.

Recovering RHEL 6 or CentOS 6 guest operati ng system from RAMDISK corrupti on

When you abruptly power off a RHEL 6 or CentOS 6 virtual machine without shutting down the virtual
machine from operating system after you install, upgrade, or uninstall VMware Tools in a Linux environment
(RHEL or CentOS 6), the guest operating system might fail during the next reboot due to a corrupted
RAMDISK image file caused by incomplete write operation of the RAMDISK image to disk. An error similar
to the following is reported in the console when you boot the guest operating system next time:

RAMDISK: incomplete write (31522 != 32768)


write error
Kernel panic - not syncing : VFS: Unable to mount root fs on unknown-
block(0,0)

 Solution
This is not a VMware issue. For more information, consult your guest operating system vendor.

To resolve this issue, a Linux guest operating system with a corrupted RAMDISK image file is rescued to
complete boot state by creating a new initramfs image in Linux rescue mode.
To create a new initramfs image and rescue the RHEL/CentOS 6 guest operating system from the
corrupted RAMDISK image file, perform these steps:

1. Boot the virtual machine with the ISO image from which CentOS or RHEL guest is installed. The ISO
installation process is described in Installing guest operating systems from ISO images (1002). To boot an
existing VM from ISO, use steps 8 and 9 from that procedure.

Note: The preceding link was correct as of January 30, 2015. If you find the link is broken, provide a
feedback and a VMware employee will update the link.

2. Select Rescue Installed System.


3. Select a language and key board type for this rescue, and then click Local CD/DVD as the rescue
method.

4. Select No as the networking option, and then select Continue as the resume option to mount the
actual root file system in read/write mode.

5. Mount the root file system that needs rescue to the location /mnt/sysimage and start a shell.

6. To change the root file system to actual root file system, run the command:

# chroot /mnt/sysimage

7. To identify the default kernel version and initramfs image from /boot/grub/grub.conf , run


the command:

# cat /boot/grub/grub.conf For example, if the kernel version is 2.6.32-


431.23.3.el6.x86_64, the output displayed is:

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server(2.6.32-431.23.3.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-431.23.3.el6.x86_64 ro root=/dev/mapper/VolGroup-
lv_root rd_NO_LUKS
LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-
sun16 crashkernel=128M
rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-431.23.3.el6.x86_64.img
title Red Hat Enterprise Linux (2.6.32-358.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root
rd_NO_LUKS
LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-
sun16 crashkernel=128M
rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-358.el6.x86_64.img

In above example, the default value 0 identifies the first title option to be used as default, the


corresponding kernel version in title option line as 2.6.32-431.23.3.el6.x86_64 and
the initramfs image file as /boot/initramfs-2.6.32-431.23.3.el6.x86_64.img.

8. After identifying the initramfs image, backup the original initramfs image before creating the new
initramfs image by running the command:

# cp /boot/initramfs-2.6.32-431.23.3.el6.x86_64.img /boot/initramfs-2.6.32-
431.23.3.el6.x86_64.img.ori
9. To create a new initramfs image, run the dracut command:

# /sbin/dracut -f /boot/initramfs-`uname -r`.img `uname -r`

For example, to create a new initramfs image file /boot/initramfs-2.6.32-


431.23.3.el6.x86_64.img for kernel version 2.6.32-431.23.3.el6.x86_64, run
the dracut command:

# /sbin/dracut -f /boot/initramfs-2.6.32-431.23.3.el6.x86_64.img 2.6.32-


431.23.3.el6.x86_64
10. To reboot the system and verify that the guest boots successfully from RAMDISK image file, run the
command:

# reboot

Reinstalling the Boot Loader

In many cases, the GRUB 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:

o Boot the system from an installation boot medium.

o Type linux rescue at the installation boot prompt to enter the rescue environment.

o Type chroot /mnt/sysimage to mount the root partition.

o Type /sbin/grub-install /dev/hda to reinstall the GRUB boot loader,


where /dev/hda is the boot partition.

o Review the /boot/grub/grub.conf file, as additional entries may be needed for GRUB to


control additional operating systems.

o Reboot the system.

You might also like