Admin/traineevms

Setting up the Trainee Admin Xen VMs

This how-to guide covers streamlining the setting up of Xen VMs using xen-tools. The setting up of Xen and VMs is also discussed here: Admin/SetupGuides/SettingUpXenVMs

In brief, to Create a VM

ssh hex
xen-create-image --hostname hex-vm## --ip 172.20.20.0/24 --role udev
vi /etc/xen/hex-vm##
#add the following line underneath the ramdisk line:
extra = 'xencons=tty clocksource=jiffies'


Documented Procedure on getting to the above stage:

1. Install Xen

apt-get install linux-image-2.6-xen-686 xen-hypervisor-3.0.3-1-i386-pae xen-tools bridge-utils libc6-xen sysfsutils

2. Setup Xen to use Routed Mode

vi /etc/xen/xend-config.sxp
(vif-script vif-route)
(network-script network-route)

vi /etc/xen/scripts/network-route
#add in the following two lines:
echo 1 > /proc/sys/net/ipv4/conf/all/proxy_arp
iptables -t nat -A POSTROUTING -s 172.20.20.0 -j MASQUERADE

2.5 Add Private IP to Xen dom0

vi /etc/network/interfaces
#add the following:
auto eth0:1
iface eth0:1 inet static
        address 172.20.20.1
        netmask 255.255.255.0
        broadcast 172.20.20.255

2.7 Add Kernel Option for Xen

This should be done also on bender, flexo and hex (all dom0's).

vi /boot/grub/menu.lst
#look for the following line:
# xenhopt=
change it to:
# xenhopt=dom0_mem=128000
(Leave the # there.)

update-grub

What this does: 1. # xenhopt=XX means that whenever a kernel is updated (apt-get upgrade), or when grub is updated (update-grub), it will automatically add the following kernel parameter to the Xen kernel: dom0_mem=128000. Usually it had to be manually edited by hand in menu.lst like:

title           Xen 3.0.3-1-i386-pae / Debian GNU/Linux, kernel 2.6.18-6-xen-686
root            (hd0,0)
kernel          /xen-3.0.3-1-i386-pae.gz dom0_mem=128000
module          /vmlinuz-2.6.18-6-xen-686 root=/dev/mapper/flexovg-root ro acpi=off console=tty0
module          /initrd.img-2.6.18-6-xen-686
savedefault

2. dom0_mem=128000 is needed to dedicate memory to dom0. Otherwise the following errors will be seen in /var/log/kern.log:

Nov 25 17:21:39 flexo kernel: printk: 4 messages suppressed.
Nov 25 17:21:39 flexo kernel: xen_net: Memory squeeze in netback driver.
Nov 25 17:21:44 flexo kernel: printk: 4 messages suppressed.
Nov 25 17:21:44 flexo kernel: xen_net: Memory squeeze in netback driver.

3. Reboot dom0 and Check Xen

xm list
#shows machines running

ifconfig
#you should see entries for: peth0 and xenbr0

4. Configure Xen-tools

This step shows all the settings which were required:

vi /etc/xen-tools/xen-tools.conf
#uncommented lines are as follows:
lvm = hexvg
debootstrap = 1
size   = 4Gb      # Disk image size.
memory = 64Mb    # Memory size
swap   = 128Mb    # Swap size
# noswap = 1      # Don't use swap at all for the new system.
fs     = ext3     # use the EXT3 filesystem for the disk image.
dist   = etch    # Default distribution to install.
image  = sparse   # Specify sparse vs. full disk images.
gateway   = 172.20.20.1
netmask   = 255.255.255.0
passwd = 1
kernel = /boot/vmlinuz-2.6.18-4-xen-686
initrd = /boot/initrd.img-2.6.18-4-xen-686
mirror = http://ftp.ie.debian.org/debian/

Configure /etc/profile to use a proxy on dom0:

vi /etc/profile
export http_proxy="http://proxy:3128"
#case sensitive for debootstrap!!

Copy files for domU skeleton as follows:

mkdir -p /etc/xen-tools/skel/root/.ssh/
mkdir -p /etc/xen-tools/skel/etc/

cp /root/.ssh/authorized_keys2 /etc/xen-tools/skel/root/.ssh/
cp /etc/profile /etc/xen-tools/skel/etc/

5. Manage xen-tools

Xen-tools is a front end, doing a lot of things:

Note, the settings which are not specified on the command line are kept in: /etc/xen-tools/xen-tools.conf

xen-create-image --hostname hex-vm04 --ip 172.20.20.13 --role udev
vi /etc/xen/hex-vm##
#add the following line underneath the ramdisk line:
extra = 'xencons=tty clocksource=jiffies'
xen-delete-image hex-vm04
#cleanly delets the vm, including removing the lvm partition!
xen-list-images

Xen Specific Tools:

xm create /etc/xen/hex-vm04.cfg
#VMs still need to be started manually.

xm console hex-vm04
#serial console in. Hit CTRL + } to escape

xm shutdown hex-vm04
#brings down the VM

Conclusion

apt-get remove locales
apt-get install locales
dpkg-reconfigure locales
tzconfig

--steviewdr, 25-Jul-07


Changed Bridged Networking to Routed Networking with Xen. This removes a lot of problems with the two firewalls previously. Hex is now the default gateway for the 172.20.20.0 range. -- steviewdr, 08-Oct-08

last edited 2009-02-25 23:58:08 by 213