Sometimes you may need to move a CentOS Linux to a new house, either because of the old hardware failing or because of this hardware being simply too old and needing upgrading for performance reasons.
If it is the later of the two, you will most likely have a different hardware in the new chassis, which will probably cause linux to die with kernel panic message that informs you that it could not find the specific drive that is housing your “/” partition during a process called pivotroot.
This is caused by the fact that on your old system linux kernel needed different modules to operate properly and to see the drives for example.
We can easily fix that.
First, boot from the CentOS install CD. When it prompts you to type “linux” at the beginning, type “linux rescue” instead. This will take you to the rescue environment, small linux OS with some tools to fix problems.
It will ask you if you want to search for previous installations and mount them. You should choose default there.
After this process you will be dropped to the command prompt. Run the following:
mount /proc /mnt/sysimage/proc -o bind chroot /mnt/sysimage/
Now you are in the old system and you can do few things there, like change the password, or generate a new boot image. The second one is what we need and want to do now.
Generating a new boot image is a simple command, but may require finding a few things first.
The command itself should look like this:
mkinitrd initrd-2.6.18.img 2.6.18
We need to know a more accurate kernel version number. This can be done in two ways: We can use the following to find what versions are available:
ls -l /lib/modules
Another option is to look into GRUB config file:
cat /etc/grub.conf | egrep ‘default|initrd’
The full mkinitrd command may look like that :
mkinitrd -f -v /boot/initrd-2.6.18-194.11.3.img 2.6.18-194.11.3
the “f” and “v” are for force overwriting of the image file and for verbosity.
If there are no issues with this command, you are ready to boot using new image.
If you used a currently active image name, you should only need reboot. Incase you used a non-active or non-existing name, you would need to edit GRUB parameters to boot from it.
It is possible to add another entry for your new image to the /etc/grub.conf file, or edit them at boot time in GRUB menu (hit escape to be presented with many, ethn use “e” to edit and “b” to boot after making changes.)