Hetzner - DokuWiki

How to migrate vServers to Cloud/en


Migration VQ/VX to CX

Your existing VQ/VX server can be migrated to a CX vServer. This process will convert the disk of an existing VQ/VX to a template for CX servers. To complete the migration, the exported disk is restored on a desired CX.


  1. Make the required adjustments on the existing VQ/VX
  2. Order a new CX with comparable or better specs
  3. Shut down the VQ/VX
  4. Convert the VQ/VX to a template
  5. Stop the CX vServer
  6. Restore the template on the new CX

The VQ/VX can be started again after the conversion has finished. Once you are satisfied that the system is performing as expected on the new CX, you can cancel the VQ/VX via Robot.

Required Adjustments

In order to ensure the template can be used on a CX, you need to make some changes before creating a template:

  • Apply DHCP for network settings
  • Remove udev rules for network card
  • Adjust /etc/fstab
  • Convert filesystem to ext4

Later you will be able to export VQ/VX into template and import this template to CX with at least the same size disk.

Apply DHCP for network settings


Edit /etc/network/interfaces

auto  eth0
iface eth0 inet dhcp

Remove other settings like "address", "netmask" and "gateway". Also remove IPv6 settings if exist (iface eth0 inet6 static).


rm /etc/sysconfig/network-scripts/route-eth0

Edit file /etc/sysconfig/network-scripts/ifcfg-eth0


Remove lines "IPADDR", "NETMASK" and "SCOPE".

Check if system after reboot is still available. Now you can remove line "HWADDR".

If you use a "virtio" network card type, the adaptation of network settings is finished.

Otherwise (in case of Realtek-NIC) you also have to rename "ifcfg-eth0" into "ifcfg-ens3", and change "DEVICE" to "ens3".

# /etc/sysconfig/network-scripts/ifcfg-ens3

Remove udev rules for network card

Since each vServer has a different MAC address, the udev rule must be removed before export to ensure that the new network card get name "eth0".

rm /etc/udev/rules.d/70-persistent-net.rules
rm /etc/udev/rules.d/80-net-setup-link.rules

Adjust /etc/fstab

VQ/VX servers emulate IDE or virtio-blk disk controller. This is used when importing into CX. To allow subsequent conversion to the more powerful virtio-scsi controller you have to use UUID in /etc/fstab.

Example for CentOS with virtio:

/dev/vda1 / ext3 defaults 0 0

Determine UUID

$ blkid -o value -s UUID /dev/vda1

Replace /dev/vda1 to UUID

UUID=bad16011-8988-4c53-ba5c-6727f8b90001 / ext3 defaults 0 0

Convert filesystem to ext4

Disks of CX servers are stored on SSD. To get the best performance we recommend to use ext4.

If ext4 already used, you still need to add discard into /etc/fstab.


UUID=bad16011-8988-4c53-ba5c-6727f8b90001 / ext4 defaults,discard 0 0

It can be done in Rescue system.

  • Check the filesystem:
# e2fsck -C0 -pf /dev/vda1
/dev/vda1: 31316/2621440 files (9.8% non-contiguous), 558963/10485248 blocks
  • Activate ext4 features
# tune2fs -O extents,uninit_bg,dir_index /dev/vda1
# fsck.ext4 -yfD /dev/vda1
  • Mount filesystem
# mount /dev/vda1 /mnt
  • Change file /etc/fstab

Example: fstab with UUID (UUID was set earlier)

UUID=bad16011-8988-4c53-ba5c-6727f8b90001 / ext3 defaults 0 0

change to

UUID=bad16011-8988-4c53-ba5c-6727f8b90001 / ext4 defaults,discard 0 0
  • Convert the existing files and directories to use Extents.
# find /mnt -xdev -type f -print0 | xargs -0 chattr +e
# find /mnt -xdev -type d -print0 | xargs -0 chattr +e

For more information please read https://ext4.wiki.kernel.org/index.php/UpgradeToExt4

Resize partition and filesystem

After migrating the server the partitioning and filesystem size must be adjusted to the new disk size. This is further explained in the following wiki article:


© 2020. Hetzner Online GmbH. Alle Rechte vorbehalten.