Wednesday, November 16, 2011

Recover from a missing kernel : The Solution

This is part two of two parts. You can read about the problem here.
The Solution
The solution was simple. I needed to install a new kernel.
I found that the sysadmin had an iso of the CentOS installation DVD on the VMWare server's datastore. The beauty of most modern distros is that their installation CDs or DVD come with a Repair Mode boot option. I modified the VM's setting to mount the iso as a cdrom for the VM. You may also have to change the VM's BIOS boot options to boot the CD-ROM drive before the hard disk. The VM's settings under Boot has an option to boot straight into the VM's BIOS setting. By default, the wait is too short for you to press the F2 key to enter the BIOS.
So I booted in to installation DVD's repair mode. It was all automatic. That is one of the nice things about using a VM environment: no hardware issues. Your distro supports them on bootup or not (commonly the network interface driver). CentOS found the network interface and configured it, found and mounted volumes and offered advice as to how to chroot to the mounted disks. Which I took. This makes the system think the root directory is the one mounted and not the DVD. Basically it boots into your system from the DVD and then makes the system think that it booted from the hard disk. Other then the running kernel, everything else is going to be loaded from the hard disk. /lib, /usr and /etc were where they should be. If there is no major incompatibility with the kernel, the existing utilities should run fine. I found yum was running ok. Why not? All the rpm databases and config files were right where it expected them to be. I installed latest kernel with yum. No problems because the network card was detected and was up. Once installed, I shut down the VM, removed the ISO from the CD-ROM settings and restarted a-okay.

The same could be achieved with a rescue distro like System Rescue CD. You could boot into it, configure and mount the network and disks and finally chroot into the mounted disks. But if possible, try with the distro installation media first. This eliminates esoteric incompatibilities between kernels and utilities.

No comments:

Post a Comment

Recently Popular