Difference between revisions of "Physical to container"
m (added info on dev-ptmx and not able to enter VE) |
|||
Line 41: | Line 41: | ||
<code>vzctl exec 123 mount</code> | <code>vzctl exec 123 mount</code> | ||
− | If not, mount it <code>vzctl exec 123 mount -t devpts none /dev/pts</code> | + | If it is not mounted, mount it <code>vzctl exec 123 mount -t devpts none /dev/pts</code> |
− | If it does | + | If it does not exist, please check above to create it correctly. |
: If anything goes wrong, try to find out why and fix. If you have enough Linux experience, it can be handled. | : If anything goes wrong, try to find out why and fix. If you have enough Linux experience, it can be handled. | ||
+ | : Also check out IRC and please report back on this page. | ||
== Success Stories == | == Success Stories == |
Revision as of 13:44, 8 February 2007
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). This could be done by scp or rsync.
- 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
Also check that:
- fstab is empty ; fstab has to be empty. - /dev/ptymx exists if it does not exist, create with:vzctl exec 123 mknod /dev/ptmx c 5 2
- check if /dev/pts exists it's a dir, if it does not exist, create withvzctl exec 123 mkdir /dev/pts
- There might be other adjustments needed. Please add if you have more info.
- Try to start your new VE:
vzctl start 123
- If your node starts but you can not enter it, you should be able to execute commands in it.
check if devpts is mounted.
vzctl exec 123 mount
If it is not mounted, mount it vzctl exec 123 mount -t devpts none /dev/pts
If it does not exist, please check above to create it correctly.
- If anything goes wrong, try to find out why and fix. If you have enough Linux experience, it can be handled.
- Also check out IRC and please report back on this page.
Success Stories
- Debian 3.1 Sarge with MySQL, apache2, PowerDNS --stoffell 08:41, 8 February 2007 (EST)