If you have encountered a Kernel Panic which usually happens after a major change in the Linux System, you can follow these procedures to rebuild the Kernel files with Dracut tools.
- Boot the server in rescue mode or simply through a live CD or ISO.
- To boot the server on rescue mode login on the Vsphere Interface and look for a live CD. In the case of Kernel Panic on your own machine, you can boot your machine with a live CD.
- Once booted, create a directory in the folder /mnt
mkdir /mnt/sysimage
- Use fdisk –l to find where is the /boot. However, you can also create another directory in mnt to mount different partitions. [sysimage is just a name given]
- Mount the disk into sysimage with the aim to mount the boot file. In my case, the sda1 is the boot partition
mount /dev/sda2 /mnt/sysimage mount/dev/sda1 /mnt/sysimage/boot
- Once the disks are mounted mount the proc/dev/ and sys folders. Here are the commands:
mount - -bind /proc /mnt/sysimage/proc mount - -bind /dev /mnt/sysimage/dev mount - -bind/sys /mnt/sysimage/sys
- After the mount operations have been carried out, you need to access the directory by chrooting into it.
chroot /mnt/sysimage
- Get into the directory sysimage
- You can back up the /boot to another location and use the command Dracut to regenerate anew the file initramfs. An example is as follows:
dracut -f /boot/initramfs-2.6.32-358.el6.x86_64.img 2.6.32-358.el6.x86_64
- You can umount all partitions and /or simply reboot the machine.
Tips:
-
- On Vcenter, you may need to boot go through the BIOS interface first before being able to boot through the ISO and force the BIOS screen to appear on your screen.
-
- You may also use the Finnix ISO which is usually compatible with all UNIX systems.
-
- When firing the Dracut command make sure you only paste the kernel version with the architecture. Do not use the file .img extension, otherwise, it won’t work – Step9
-
- The last part ‘2.6.32-358.el6.x86_64’ is just the same version that needs to be regenerated. -Step9
-
- To know which kernel version your machine is actually using, you need to get into the grub folder and look for the grub.conf. The first option is usually the kernel used by default.
-
- Sometimes, you need to try with the same version of the OS, it may happen after you have boot your machine with a live CD, the ISO which you have used do not detect your disk or the data store. You may, for example, think the disk is not good or there is a problem in the SAN.
-
- However, without doing a root cause analysis, you cannot be certain if by repairing the initrd the Kernel Panic might be the unique solution. There are circumstances where a mounted NFS is not the same version with the actual machine which can result in Kernel Panic. The Dracut solution is not a definite solution.
- Always investigate the Dmesg log if possible or the crash dump if the same has been set up.