Hetzner - DokuWiki

How to migrate vServers to Cloud/en
(Debian/Ubuntu)
(Required Adjustments)
Zeile 17: Zeile 17:
 
Once you are satisfied that the system is performing as expected on the new CX, you can cancel the VQ/VX via Robot.
 
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 =
+
= Required Adjustments - Linux =
  
 
In order to ensure the template can be used on a CX, you need to make some changes before creating a template:
 
In order to ensure the template can be used on a CX, you need to make some changes before creating a template:
Zeile 128: Zeile 128:
  
 
[[Resize_Ext_Partition/en|Resize Ext Partition]]
 
[[Resize_Ext_Partition/en|Resize Ext Partition]]
 +
 +
= Required Adjustments - FreeBSD =
 +
 +
== Apply DHCP for network settings ==
 +
 +
The networkconfiguration is located in /etc/rc.conf. There we need to change the following line:
 +
 +
ifconfig_re0="DHCP"
 +
 +
This line need to be removed completely:
 +
defaultrouter="..."
 +
 +
== Bootloader Logo ==
 +
 +
To get FreeBSD boot on current virtualization platforms we need to add the following line to /boot/loader.conf:
 +
 +
beastie_disable="YES"
 +
 +
== 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 FreeBSD documentation article:
 +
[https://www.freebsd.org/doc/handbook/disks-growing.html Resize Partition]

Version vom 30. November 2016, 08:40 Uhr

Inhaltsverzeichnis

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.

Steps:

  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 - Linux

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

Debian/Ubuntu

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).

If you are using NIC type r8139, please replace "eth0" with "ens3".

CentOS

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

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

BOOTPROTO=dhcp

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
DEVICE=ens3
BOOTPROTO=dhcp
ONBOOT=yes

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
bad16011-8988-4c53-ba5c-6727f8b90001

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.

Example:

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:

Resize Ext Partition

Required Adjustments - FreeBSD

Apply DHCP for network settings

The networkconfiguration is located in /etc/rc.conf. There we need to change the following line:

ifconfig_re0="DHCP"

This line need to be removed completely:

defaultrouter="..."

To get FreeBSD boot on current virtualization platforms we need to add the following line to /boot/loader.conf:

beastie_disable="YES"

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 FreeBSD documentation article: Resize Partition



© 2020. Hetzner Online GmbH. Alle Rechte vorbehalten.