User Tools

Site Tools


xen-tools

Xen-tools

= Setting up Trainee Admin Xen VMs Automatically =

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 dom0 xen-create-image –hostname dom0-vm## –ip 192.168.0.15



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 Bridge Networking

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

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 = 192.168.0.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:

  • xen-tools will handle creating and deleting lvm partitions for vms.
  • xen-tools will mount and copy across network setting and whatever files you wish onto the domU.
  • xen-tools will mount and debootstrap the os you specified onto the domU.

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 192.168.0.15

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

  • xen-tools greatly speeds up creating the VMs. Note: it does take xen-tools between 10-15 minutes to create and debootstrap a VM, so be patient.
  • As long as VMs are running when dom0 goes down, xen-tools will bring back up all domU's on restart.
  • Use “xm list” and “xm top” to see an exact list of whats running.
  • With a later version of xen-tools (later than what is with etch), it is possible to setup incremental IPs, so the IP does not have to be specified when going xen-create-image.
  • cp /root/.ssh/authorized_keys2 /etc/xen-tools/skel/root/.ssh/ allows you to ssh into the new VM without a password.
  • If you dont have “passwd = 1” then all existing users and passwords from existing dom0 will be copied across to domU.
  • Minor problems occurred from xen-tools. On creating a new VM, it added an entry into /etc/hosts on dom0. As I was testing with a few setups, old ips remained within /etc/hosts. The dns names are now added into dns, so they dont need to be in the hosts file.
  • When the domU is up and running, you might want to run:

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

xen-tools.txt · Last modified: 2022/07/19 20:13 by 127.0.0.1