Talk:Physical to container

From OpenVZ Virtuozzo Containers Wiki
Revision as of 19:35, 26 May 2010 by Kir (talk | contribs) (Reverted edits by 41.222.210.115 (Talk) to last revision by Kir)
Jump to: navigation, search

RSync Command

Please check the following command, Ive used with success:

rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp --exclude mnt --exclude sys -e "ssh -l root@a.b.c.d" root@a.b.c.d:/ /vz/private/123/

Migration Script

I composed a little Script to migrate a Debian Sarge Box to OpenVZ. (Some System specific steps have been removed)

#!/bin/sh
echo "Stopping VE 300..."
vzctl stop 300
echo "Creating base filesystem /dev /proc ..."
mknod /vz/private/300/dev/ptmx c 5 2
mkdir /vz/private/300/dev/pts
rm -f /vz/private/300/dev/null
mknod /vz/private/300/dev/null c 1 3
chmod o+rw /vz/private/300/dev/null
echo "Copy the tty's to VE and Set Permissions"
cp -r /dev/ttyp* /dev/ptyp* /vz/private/300/dev/
chmod o+wx /vz/private/300/dev/*typ*
echo "Creating /dev/random and Set Permissions"
mknod -m 644 /vz/private/300/dev/random c 1 8
mknod -m 644 /vz/private/300/dev/urandom c 1 9
chown root:root /vz/private/300/dev/random /vz/private/300/dev/urandom
echo "clearing mtab / fstab..."
echo -n > /vz/private/300/etc/fstab
rm /vz/private/300/etc/mtab
ln -s /proc/mounts /vz/private/300/etc/mtab

Use Dummy

Having been completely clueless about Openvz three days ago I first created a dummy container based on the same distribution I wanted to migrate. This helped me greatly to understand what was needed and also allowed to use the dummy as a template for /dev and the conf file. Disregarding the time to setup the host system the actual migration from the physical machine with tar ball took me two hours and the migrated container started up on second attempt after first complaining about disk size. I increased that and it runs. I am very impressed by the ease of it all.

/proc in fstab

Often it is wise to keep proc mount in fstab, if the OS doesn't make it by itself. --Grin 11:49, 9 December 2009 (UTC)

Thanks for noting this! I have modified the page accordingly, please check --Kir 11:56, 9 December 2009 (UTC)
Seems fine, thanks, Kir. --Grin 20:22, 9 December 2009 (UTC)

rsync before taking everything down

You might want to mention that it's possible to run the rsync command for copying data while the physical server is still operating normally (i.e. before you shut down its services), which will allow you to transfer most of the data before shutting down everything. If you then run rsync for a second time once everything has shut down, it will only need to transfer anything that was changed since the last rsync run, reducing the amount of downtime required. —The preceding unsigned comment was added by 87.194.177.60 (talkcontribs) 19:43, 11 March 2010.

Added to the page, thanks for noting --Kir 16:51, 11 March 2010 (UTC)