Migrate physical system to OpenVZ container
In this lab, we already install Openvz container kernel at host system.
Create new empty VM
mkdir /vz/root/101 /vz/private/101
cat /etc/vz/conf/ve-vps.basic.conf-sample > /etc/vz/conf/101.conf
Copy data from Physical to VM directory
rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp --exclude sys --exclude mnt -e "ssh -l root@x.x.x.x" root@x.x.x.x:/ /vz/private/101/
Create /etc/vz/conf/101.conf
VE_ROOT="/vz/root/$VEID"
VE_PRIVATE="/vz/private/$VEID"
OSTEMPLATE="centos-5"
IP_ADDRESS="192.168.1.1"
HOSTNAME="penguin"
NAMESERVER="8.8.8.8"
#Making adjustments
Edit /vz/private/101/etc/inittab
sed -i -e '/getty/d' /vz/private/101/etc/inittab
Edit /vz/private/101/etc/mtab
rm -f /vz/private/101/etc/mtab
ln -s /proc/mounts /vz/private/101/etc/mtab
Edit /vz/private/101/etc/fstab
cp /vz/private/101/etc/fstab /vz/private/101/etc/fstab.old
grep devpts /vz/private/101/etc/fstab.old > /vz/private/101/etc/fstab
mknod --mode 666 /vz/private/101/dev/ptmx c 5 2
mkdir /vz/private/101/dev/pts
cp -a /dev/ttyp* /dev/ptyp* /vz/private/101/dev/
/sbin/MAKEDEV -d /vz/private/101/dev ttyp ptyp
rm -f /vz/private/101/dev/null
mknod --mode 666 /vz/private/101/dev/null c 1 3
mknod --mode 444 /vz/private/101/dev/urandom c 1 9
ls -la /vz/private/101/ | grep proc
mkdir /vz/private/123/proc
Edit /vz/private/{CTID}/etc/sysconfig/network-scripts/ifcfg-ethx
ONBOOT=no
Edit /vz/private/{CTID}/etc/rc.sysinit
#/sbin/start_udev <-- Comment
vzctl start 123
Comments
Post a Comment