Physical to container
A rough description of how to migrate existing physical server into a VE.
What you need to do in order to migrate is:
- Prepare an “empty” VE. For OpenVZ this would mean the following (assume you choose VE ID of 123):
mkdir /vz/root/123 /vz/private/123 cat /etc/vz/conf/ve-vps.basic.conf-sample > /etc/vz/conf/123.conf
- Stop most services on a machine to be migrated. “Most” means services such as web server, databases and the like — so you will not loose your data. Just leave the bare minimum (including ssh).
- Copy all your data from the machine to an OpenVZ box. Say you'll be using VE with ID of 123, then all the data should be placed to
/vz/private/123/
directory (so there will be directories such as/vz/private/123/bin
,etc
,var
and so on).
- Set some VE parameters. You have to add
OSTEMPLATE=xxx
line to/etc/vz/conf/123.conf
file, wherexxx
would be distribution name (likedebian-3.0
) for vzctl to be able to make changes specific for this distribution.
- Also, you have to supply an IP for a new VE:
vzctl set 123 --ipadd x.x.x.x --save
- You have to edit some files inside a VE. For example, virtual server does not have real ttys, so you have to disable getty in
/etc/inittab
(i. e./vz/private/123/etc/inittab
). Also, link/etc/mtab
to/proc/mounts
.
sed -i -e '/getty/d' /vz/private/123/etc/inittab rm -f /vz/private/123/etc/mtab ln -s /proc/mounts /vz/private/123/etc/mtab
- There might be other adjustments needed.
- Try to start your new VE:
vzctl start 123
- If anything goes wrong, try to find out why and fix. If you have enough Linux experience, it can be handled.