Cool Solution - Migrating a native UCS installation to UVMM

From Univention Wiki

Revision as of 09:46, 5 October 2016 by Hpeter (talk | contribs)
Jump to: navigation, search
Produktlogo UCS Version 3.2

Note: Cool Solutions are articles documenting additional functionality based on Univention products. Not all of the shown steps in the article are covered by Univention Support. For questions about your support coverage contact your contact person at Univention before you want to implement one of the shown steps.

Also regard the legal notes at Terms of Service.
Note: This article is not yet reviewed.

The following article describes how to migrate a standard installation of UCS. The values and device names must be adapted to each individual setup. There


Live migration

If the server has to be accessed during the migration process, special care has to be taken of application and user data. This, however, would go beyond the scope of this article. If desired, Univention offers advice for such a scenario.

Migration of a DC Master

If the DC Master does not hold any data or provides services that need to be migrated, the installation of a DC Backup and promotion to a DC Master is preferred to migrating the DC Master. The promotion is done with the following command on the DC Backup:


If this is not possible and more servers in addition to the DC Master need to be migrated, the DC Master must be saved and reinstated as first system. If desired, Univention offers advice for such a scenario.


In addition to the UCS system that will be migrated, and a working installation of UVMM, a Linux Live-CD with LVM (i.e. SystemRescueCd) support is needed.

Copying the whole harddrive

To transfer a native UCS installation into a UVMM instance, the harddrive has to be saved as an image file which is then used by UVMM.

To create the image file, the system must be booted with the Live-CD. The installed harddrives can be identified by using the following command:

fdisk -l

It is recommended to use an external harddrive or a USB flash drive to transfer the system:

dd if=/dev/sda of=/mnt/usb/ucs.raw

Depending on the size of the device sda this will take some time.

Hint: When combining the commands dd and scp, the image can be copied to the UVMM system and the need for an external storage is omitted. Beware that this can be more time consuming than using an external drive due to possible CPU and network limits.

When the copy process is finished the system can be shut down.

The image is saved as raw file and can now be used as a virtual harddrive with UVMM. For this, the raw image is copied to /var/lib/libvirt/images on the UVMM host.

If KVM is used for virtualization and advanced features should be used, then the image must be converted to a qcow2 file:

cd /var/lib/libvirt/images/
qemu-img convert -f raw -O qcow2 ucs.raw ucs.qcow2

Afterwards, a new virtual instance must be created, using the profile which describes the installation best, e.g. UCS 3.2 (64 Bit). The raw or qcow2 file must be assigned as harddrive. After starting the virtual instance, the system boots up.

Hint: If the native installation used more than one harddrive the procedure must be repeated for every harddrive!

Migration by copying the core files

To transfer a native UCS installation into a UVMM instance, its harddrive is saved to a file and then copied into an existing, already virtualized, UCS installation.

Attention: If the system, that is about to be migrated, contains databases or user data provided on network shares, ensure that the databases are shut down properly and no users are connected to the server to prevent data loss!

Using the following script, all files and ACLs are saved on the server:

export BACKUPPATH=<my-Backup-Path>
mkdir -p $BACKUPPATH
ionice -c 3 nice -n 20 tar cvfj $BACKUPPATH/files.tar.bz2 --numeric-owner --atime-preserve -X <exclude> --exclude=$BACKUPPATH /
getfacl --skip-base -RP / > $BACKUPPATH/acl

Please assure that the directory <my-Backup-Path> has enough free space to hold the backup. Furthermore, the file <exclude> must be created, containing directories that are not to be saved with the backup. The following directories must be excluded via the file:


It is recommended to exclude the following directories as well:


Attention: If the backups is saved directly to a mounted drive, the mountpoint must be excluded as well, else the files on the external drive will be saved as well into the backup!

The directory /var/log should be saved because services might deny being started when no log files are found. It is therefore recommended to exclude all gzipped files and include only the latest log files.

The script must be made executable prior executing it as root user:

chmod +x script

Before shutting down the old system write down the partitioning using gdisk for a GPT table partitioned system, or fdisk for a MBR table partitioned system.

Migration into a virtual system

First, create a new VM with the profile suiting your native installation, e.g. UCS 3.2 (64 Bit); if unsure use Other (64 Bit). The harddrive must at least match the source system's size and quantity. Furthermore, a second harddrive must be created, at least the size of the backup file and the Live-CD must be mounted in the virtual CD-ROM drive.

During the boot up of the Live-CD the old server's architecture should be loaded.

After the system is booted up, make sure the system has an IP address and the SSH daemon is started.

If the old installation used a GPT table, use gdisk, else use fdisk. Run the appropriate tool to partition the harddrives:

fdisk /dev/vda

Create an exact partioning like your old system. The command sequence in gdisk is similar to the one from fdisk:

n -> p -> 1 -> (empty) -> +2G
n -> p -> 2 -> (empty) -> +2G
t -> 2 -> 82
n -> p -> 3 -> (empty) -> (empty)
t -> 3 -> 8e

Now the Logical Volume Groups must be created on the harddrive. In an UCS standard installation, one VG exists with one volume. This can be recreated with the folling command:

pvcreate /dev/vda3
vgcreate vg_ucs /dev/vda3
lvcreate -l 100%VG -n rootfs vg_ucs

Now the /boot and LVM partition can be formatted, and the swap partion can be created:

mkfs.ext4 /dev/vda1
mkswap /dev/vda2
mkfs.ext4 /dev/mapper/vg_ucs-rootfs

Attention: Make sure to format the partitions as they are in the native installation to prevent errors!

If you copy the backup file over the network, a second harddrive must be formatted:

fdisk /dev/vdb
n -> p -> 1 -> (empty) -> (empty)
mkfs.ext4 /dev/sdb1

Now the the harddisks are ready to be mounted to the following locations:

mount /dev/mapper/vg_ucs-rootfs /mnt/custom -o acl
mount /dev/vda1 /mnt/custom/boot -o acl
mount /dev/vdb1 /mnt/backup

Copying the files to the new system

When the backup files are to be moved over the network, use the following commands:

root@hardwaresystem# scp <my-Backup-Path>/files.tar.bz2 root@<target host>:/mnt/backup/ 
root@hardwaresystem# scp <my-Backup-Path>/acl root@<target host>:/mnt/backup/ 

When the files are saved on an external drive, mount the drive and copy the files into the folder /mnt/backup.

The files can now be extracted from the archive:

cd /mnt/custom
tar xvjp --atime-preserve --numeric-owner -f /mnt/backup/files.tar.bz2 -C ./

All excluded directories must be created from the exclude-file must be created. Additionaly, the folder /tmp must be made world readable:

chmod 777 tmp

Finally the ACLs must be copied to the new environment so they can be restored later:

cp /mnt/backup/acl /mnt/custom/tmp/acl

Chroot into the system

After the folder structure is created, the system directories must be mounted into the new environment:

mount -o bind /proc /mnt/custom/proc
mount -o bind /dev /mnt/custom/dev
mount -o bind /sys /mnt/custom/sys

Now the new environment can be accessed by using chroot:

chroot /mnt/custom /bin/bash

The ACLs must now be restored:

setfacl --restore=/tmp/acl

Now the Grub bootloader must be initialized:

grub-install /dev/vda

If necessary, the /etc/fstab file must be edited to reflect the actual positions for /boot and the swap partition:

#For boot:
/dev/vda1 /boot ext4 defaults,acl 0 0
#For swap:
/dev/vda2 none swap sw 0 0

Now exit the chroot environment and reboot the system. The migrated system should now be ready to be used.

Personal tools