Posted on June 26th, 2009 in Linux | 2 Comments »
After the sad death of K T Ligesh I decided, like many people, to move away from HyperVM.
I searched and tried many control panels.
I’ve now decided to create the VM’s by hand. I then hope to make a PHP control panel of my own. Here are my steps for creating Xen VPS’s using the command line and Centos 5.
I’m going to create a vm called testvm
First I needed to find out what Volume groups exist on my system and what the VG Name was
VG Name VolGroup00
Create the disks for the VM and format
lvcreate -L8.5G -n testvm_rootimg VolGroup00
lvcreate -L 384M -n testvm_vmswap VolGroup00
tune2fs -j /dev/VolGroup00/testvm_rootimg
Now mount your disk image. I’ve created a custom hardened Centos distro, but you could use Jailtime Images
mount -o loop centos.5-3.64-smudge.img /mnt/img
mount /dev/VolGroup00/looop_rootimg /mnt/vm
Copy the image onto your new partition
cp -a /mnt/img/* /mnt/vm/
Now all you need to do is configure the hostname, ip etc on the VM.
Change the hostname
If your using Jailtime images people have advised to change this line to the following:
Add the line:
/dev/sda2 swap swap defaults 0 0
umount /mnt/img /mnt/vm
You will need a ram disk to boot from. This can be created by running:
mkinitrd /boot/xen-guest-initrd `uname -r` –with xenblk –with xennet –preload xenblk –preload xennet –omit-scsi-modules
Now all you need to do is create the config file and give it an IP/ Mac address.Please check which kernel you are using first and change – kernel = “/boot/vmlinuz-2.6.18-128.1.14.el5xen”…
kernel = “/boot/vmlinuz-2.6.18-128.1.14.el5xen”
ramdisk = ‘/boot/xen-guest-initrd’
maxmem = 192
memory = 192
vcpus = 1
name = “testvm”
vif = [ 'ip=87.xxx.xxx.xxx,bridge=xenbr0, rate = 1000KB/s, mac=aa:00:23:b0:de:34' ]
serial = ‘pty’
disk = ['phy:/dev/VolGroup00/testvm_rootimg,sda1,w', 'phy:/dev/VolGroup00/testvm_vmswap,sda2,w']
root = ‘/dev/sda1 ro’
on_poweroff = ‘destroy’
on_reboot = ‘restart’
on_crash = ‘restart’
All is ready to go.
xm create testvm
And you VPS should be now running:
xm console testvm
Hope this helps.