Hetzner - DokuWiki

How to migrate vServers to Cloud/en

Inhaltsverzeichnis

Migration from vServer to Cloud

You may migrate existing VQ/VX/CX vServer to the current Cloud Server.

Steps of migration:

  1. create of similar or more powerful Cloud Server
  2. start the Rescue System on the both servers and mount filesystem
  3. trigger the synchronization with rsync

Disclaimer: Individual installations may require different or more steps.

Important information

The following operation systems are not supported.

  • Debian 6 and older
  • Ubuntu 11.10 and older
  • CentOS 5.6 and older
  • openSUSE 11.4 and older

For the listed operating systems is an upgrade to a newer version is necessary.

Before migrating, all packages MUST be upgraded to the minimum supported version. Partial upgrades and/or operating systems with packages from 3rd party repositories may not work as as expected and are not supported.

Activate the Rescue System

To transfer the data, you have to boot both servers into the Rescue System. For VQ/VX/CX vServers you can activate Rescue System via your Robot panel, on tab "vServer".

Robot-Rescue.png Robot-Reset.png

For Cloud Servers you can activate Rescue System via your Cloud Console. The server will be rebooted into Rescue System.

Cloud-Rescue-And-Reset.png

Mount of the filesystem

After the start of the Rescue System, you will mount the filesystem to copy files.

On the VQ/VX/CX vServer are set up a different controller. Please check the partitions via:

old_server ~ # fdisk -l

Sample Output of fdisk.png

You may mount the filesystem via.

old_server ~ # mount /dev/XXXY /mnt

Please substitute XXX with the device declaration and Y with the partition number. If multiple partitions exist, these must be mounted in the order of the installation (e.g. / before /boot)

Mounting of swap partition:

old_server ~ # swapon /dev/XXXY

If exists a boot partition, so mount the main partition at first and in the end the boot partition.

The mountpoint for the boot partition is /mnt/boot.

You will mount the filesystem of the Cloud Server later.

Migration to Cloud Server

Partitioning (optional)

An older operating system (e.g. CentOS 6) using grub-legacy kommt, requires two separate partitios as the bootloader does not yet support ext4.

Start by creating an empty partition table (this deletes all existing entries)

new_server ~ # parted -s /dev/sda mklabel msdos

Then create a 512M partition for /boot and another one with the remaining disk space:

new_server ~ # parted -s /dev/sda mkpart primary 2048s 513MiB
new_server ~ # parted -s /dev/sda mkpart primary 514MiB 100%

Erase disk

As first step please delete file system of the Cloud Server.

new_server ~ # mkfs -O ^64bit,^metadata_csum -t ext4 /dev/sda1

This creates a new ext4 filesystem (without some newer advanced features) and hence erases all existing data on the Cloud Server.

Should you have created 2 partitions in the first step, these must be formatted with ext3 and ext4 respectively.

new_server ~ # mkfs.ext3 /dev/sda1
new_server ~ # mkfs -O ^64bit,^metadata_csum -t ext4 /dev/sda2


Mount the filesystem on the Cloud Server

new_server ~ # mount /dev/sda1 /mnt
  • in case of 2 partitions:
new_server ~ # mount /dev/sda2 /mnt
new_server ~ # mkdir /mnt/boot
new_server ~ # mount /dev/sda1 /mnt/boot

Migration

The data transfer will be performed with rsync

new_server ~ # rsync -avz --progress --numeric-ids IP-old-server:/mnt/* /mnt

fstab adjustments

Adjustment of fstab on the Cloud Server. This is procedure is necessary, otherwise the server will not boot.

Determine the UUID of the partitions.

new_server ~ # blkid -o value -s UUID /dev/sda1
  • and in case of 2 partitions also:
new_server ~ # blkid -o value -s UUID /dev/sda2

Example /mnt/etc/fstab with UUID before

UUID=<UUID-root-partition-old-server> / ext3 defaults 0 0

adjust to

UUID=<UUID-sda1-new-server> / ext4 discard,errors=remount-ro 0 1

or in case of 2 partitions:

UUID=<UUID-sda2-new_server> / ext4 discard,errors=remount-ro 0 1
UUID=<UUID-sda1-new_server> /boot ext3 defaults 0 2

Necessary adjustments to the new server

Change to DHCP

Debian/Ubuntu

edit of /mnt/etc/network/interfaces

Remove lines like auto ens3, iface ens3 inet static .

auto eth0
iface eth0 inet dhcp
iface eth0 inet6 static
    address
    netmask 64
    gateway fe80::1

Remove further lines likes address, netmask and gateway in the IPv4 part (iface eth0 inet dhcp).

CentOS and openSUSE

new_server ~ # rm /mnt/etc/sysconfig/network-scripts/route-eth0

edit of /mnt/etc/sysconfig/network-scripts/ifcfg-eth0

BOOTPROTO=dhcp

Remove lines like IPADDR, NETMASK, SCOPE and BROADCAST.

Arch Linux

If the installation of Arch Linux performed with our ISO or installimage, so will used systemd-network.

Edit of /mnt/etc/systemd/network/network/10-ens3.network (In some cases 10-eth0.network too!)

[Match]
Name=eth0
[Network]
DHCP=ipv4

Remove lines like address and Gateway.

Removing the udev-rule of the network interface card

Every virtual server has a unique MAC, please remove the current udev-rule in preparation of the migration.

new_server ~ # rm /mnt/etc/udev/rules.d/70-persistent-net.rules
new_server ~ # rm /mnt/etc/udev/rules.d/80-net-setup-link.rules

Arch Linux

Create a link with /dev/null. For that reason the NIC is called eth0 again.

new_server ~ # ln -s /dev/null /etc/systemd/network/99-default.link

GRUB

The bootloader has still the old configuration. Now update the configuration via the following commands.

Debian/Ubuntu

new_server ~ # chroot-prepare /mnt ; chroot /mnt
new_server ~ # grub-mkdevicemap
new_server ~ # grub-install /dev/sda
new_server ~ # update-initramfs -u
new_server ~ # update-grub
new_server ~ # exit

On Debian 9 before running the following commands the file /etc/default/grub has to be edited:

GRUB_CMDLINE_LINUX="net.ifnames=0"

This will cause the network card to be available in the system as eth0 instead of ens3. Now run the next commands:

new_server ~ # update-grub
new_server ~ # exit

CentOS 6

new_server ~ # chroot-prepare /mnt ; chroot /mnt
new_server ~ # grub-install /dev/sda

Please adjust the UUID in /boot/grub/grub.cfg on your own, because the bootloader will be not updated via grub-install.

After the adjustment of /boot/grub/grub.cfg, perform the following commands.

new_server ~ # dracut -f
new_server ~ # exit

CentOS 7

new_server ~ # chroot-prepare /mnt ; chroot /mnt
new_server ~ # grub2-install /dev/sda 
new_server ~ # grub2-mkconfig -o /boot/grub2/grub.cfg
new_server ~ # dracut -f
new_server ~ # exit

Arch Linux

new_server ~ # chroot-prepare /mnt ; chroot /mnt
new_server ~ # grub-install /dev/sda
new_server ~ # grub-mkconfig -o /boot/grub/grub.cfg
new_server ~ # mkinitcpio -p linux
new_server ~ # exit

openSUSE

new_server ~ # chroot-prepare /mnt ; chroot /mnt
new_server ~ # grub2-install /dev/sda
new_server ~ # grub2-mkconfig -o /boot/grub2/grub.cfg
new_server ~ # mkinitrd
new_server ~ # exit

Last steps at the Cloud Server

To use the Cloud Server again, please unmount the filesystem

unmount the filesystem

new_server ~ # umount -R /mnt

restart the server

new_server ~ # reboot


© 2019. Hetzner Online GmbH. Alle Rechte vorbehalten.