UNIX BLOG

Blog for NIX system based administrators

How to convert openvz template to xen centos 6

This article is about converting openvz template to xen, especially CentOS 6
First download the it from here

http://wiki.openvz.org/Download/template/precreated

 

Now, the list of commands for installing it

first create an lvm or image disk for 20GB for example
lvcreate -n /dev/Your Volume Group Nam/xen-vps-disk -L 20G

mkfs.ex4 /dev/Your Volume Group Nam/xen-vps-disk

Create a swap file

lvcreate -n /dev/Your Volume Group Nam/xen-vps-swap -L 1G

mkswap -f /dev/Your Volume Group Nam/xen-vps-swap

 

I will not put here an example for image based disk because it’s not practical to use Image Based disk, because of different reasons.

Mount it to a disk

mount /dev/Your Volume Group Name/xen-vps-disk /mnt

cd /mnt
wget http://download.openvz.org/template/precreated/centos-6-x86_64.tar.gz
tar -xf centos-6-x86_64.tar.gz

rm -r centos-6-x86_64.tar.gz

Edit /mnt/etc/fstab

proc            /proc           proc    defaults        0       0 <br />
none            /dev/pts        devpts  mode=0620       0       0 <br />
/dev/xvda1 none swap sw 0 0 <br />
/dev/xvda2 / ext4 noatime,nodiratime,errors=remount-ro 0 1

Copy kernel modules

cp -dpR /lib/modules/2.6.32-5-xen-amd64/ /mnt/lib/modules/

Edit network config

/mnt/etc/sysconfig/network-scripts/ifcfg-eth0

NETWORKING=yes
HOSTNAME=Your hostname
DEVICE="eth0"
BOOTPROTO="static"
BROADCAST="broacast"
GATEWAY="gateway"
IPADDR="your ip"
NETMASK="your netmask"
NM_CONTROLLED="yes"
ONBOOT="yes"

Edit networks file

/mnt/etc/etc/sysconfig/network

NETWORKING=yes
GATEWAY=Gateway
HOSTNAME=your hostname
NOZEROCONF=yes #do not load default route configuration read about zeroconf

Edit Xen configuration file

/etc/xen/auto/xen-vps.conf

kernel      = 'your kernel'
ramdisk     = 'your ramdisk'

vcpus       = '2''
memory      = '2000''

#
#  Disk device(s).
#
root        = '/dev/xvda2 ro'
disk        = [
'phy:/dev/Your Volume Group/vds-test-disk,xvda2,w',
'phy:/dev/Your Volume Grouip/vds-test-swap,xvda1,w',
]
#
#  Hostname
#
name        = 'your hostname'

vif         = [ 'ip=your ip' ]
#
#  Behaviour
#
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>