Migrating Linux server in 7 steps

Mplaying Linux server in 7 stepsso you don’t need to do a fresh installation if you move the server to a new provider.

You can actually make more money every month if you go to a cheaper, better quality supplier. You can do it in 7 easy steps.

We recently migrated an entire Linux Fedora Core 11 server and it took us longer than originally expected, so we wrote this post because we couldn’t find any help online. If that doesn’t help you, feel free to write in the comments.

Step 1 – Preparatory Phase Before Migration

  1. If you are using 64 – bit software, you will not be able to migrate to a 32 – bit server.
  2. Check how much network bandwidth is being used. Check if the new provider has enough traffic packet for the current monthly bandwidth.
  3. Don’t be fooled by “You can put your server in VMware VM and pay for management services every month. You just have to execute the script on the server ”. It looks very easy and it really is, but you will pay more each month for something that you will not use.

Step 2 – Selecting a new supplier

Let’s start by contacting several suppliers and choosing the best option.

This is very important because you need to buy a new server from the vendor that has a control panel for you to reboot the server, ideally has a KVM console so you can change BIOS settings and control everything, and at least has 2 disk.

If you opt for a KVM solution, you can install a server migration via a LIVE CD Linux that your ISP will install for you.

If you don’t want this kind of problem, just ask for a fresh install of whatever distribution (Ubuntu or Debian based) you install on a secondary disk, and then you will make it primary.

Step 3 – Prepare the target server to receive data

You must have a new server ready to receive data from your primary server.

If you are using a regular Linux distribution (Finnix, Fedora, Ubuntu, …) you can create all partitions with cfdisk and then follow below command:

/*
 * Imagine:
 * /dev/sda1 - boot (ext2)
 * /dev/sda2 - swap
 * /dev/sda3 - root filesystem where your OS is installed
 */
# mkdir /mnt/root
# mount /dev/sda3 /mnt/root
# mount /dev/sda1 /mnt/root/boot
# mount --bind /dev /mnt/root/dev
# mount --bind /sys /mnt/root/sys
# mount --bind /proc /mnt/root/proc
# chroot /mnt/root

Note: You need the GNU version of netcat on the target server. If your distribution does not have it, then try installing it.

Then on the destination server:

cd /mnt/root
netcat -vv -l -p 31337|tar vxfzp -

Check security

Moving a server is a great opportunity to get hacked by a very experienced hacker. You should consider the security of the network connection between the two servers, otherwise you should use an alternative to Netcat for file transfers such as scp.

Step 5 – Backing Up Everything from the Source Server

Check the available server drives:

$ fdisk -l

Check the partitions so that you can copy it to the destination server (change the / dev / sda drive you want to see):

$ cfdisk /dev/sda

Use tar and untar for disk over the network. If the disk on your source server is larger than the disk on your target server and you still have enough space on the target server, you can compress the data:

/*
 * Я использовал nc здесь, но вы можете использовать netcat, если у вас он установлен
 */
# tar -cvpzf - --exclude=/mnt/ --one-file-system / | nc -vv your_destination_server_ip 31337

Step 6 – New Configurations

There are a few things that will be different on the new server.

1) UUID drives

– Either you go to /boot/grub/menu.lst and / etc / fstab and change the UUID for the new drives. – you can also change the UUID on new drives to the same old ones on your drives:

На старом сервере: 
# blkid /dev/sdaX (change X for 1, 2 or 3...)
На новом сервере:
# tune2fs -U UUID-you-got-from-the-blkid-in-the-old-server /dev/sdaX (change X for 1, 2 or 3...)
Своп файл
# mkswap -U UUID-you-got-from-blkid-in-the-old-server /dev/sdaX (change X for 1, 2 or 3...)

2) drivers must be loaded

If you have a standard kernel, all drivers will probably be available as a module. If you need to fix it later, make sure you keep the list:

lsmod

Also keep in mind that different kernel versions may have different module names …

Note: We had a problem porting the Fedora 11 kernel because there was no driver in the kernel running on the new hard drive. So I had to go to kernel.org and compile the new kernel manually.

3) Network configuration

It really depends on your distribution, but you can probably set up your network fairly easily. Fedora:

# system-config-network

4) IP – configuration address in / etc.

Try to remember and find any hardcoded IP configurations:

grep -r "your-old-IP-address" /etc

Step 7 – Summary

Option 1

If you used the KVM console option, you can simply change the BIOS on the new server to boot the new system.

Option 2

If you have 2 disks and the system is installed on a second disk, ask the vendor to make it the second primary disk, or simply change /boot/grub/menu.lst to boot to that disk.

Sidebar