Sunday, August 24, 2008

linux p2v: Migrating from one hardware to other

No matter how good the hardware is, eventually it dies. All my servers are dying one by one. Initially they have kernel panic sometimes then the frequency of kernel panics increase.
The challenge that I have always faced is how do I take all the applications running on server to another one? Reinstalling everything on a new machine is obviously not an option as I don't know what all is running and who is the current owner of which application.
So now I have started making VM of a server when it shows signs of old age. The usual p2v stuff did not help me much. Eventually I am able to do create the VM. Here is how to do it, for an experienced admin.
1) Install bare minimum OS on the new server. Preferably same version (major/minor etc). If you can not get the same version then get next up version from the same distribution (debian,fedora etc).
2) Boot the machine with a live cd (knoppix is my favorite) and delete everything except /boot and /lib/modules/ directory from the hard disk of the new machine.
3) Now tar these two directories and put st some secure place.
4) Boot the original machine also using a live cd and copy all the files using tar command itself. Execute the command like this:
tar -C -czvf - ./ | ssh root@new_mcahine tar -C -xzvf -
5) Now restore the the previously stores /boot and /lib/modules form secure place to new machine (using the live cd booted environment itself)
6) Edit the /etc/fstab to have correct entries.
7) Boot with a grub floppy and use setup command to setup grub.
8) Now reboot and if needed do the repair.

These instructions are useful to someone who knows what they are doing so may not be useful to linux novices. let me know if you have questions thru the comments here and my be I can help.

if you have lvm on the original machine, it becomes very difficult and you may have to edit the initrd image to make sure that lvm and hdd drivers are part of the initrd image.

No comments: