Table of Contents
Xen
A short Xen 3.0.3 installation report on debian etch. Im setting up a test system (Athlon XP 3200+) with software-raid 1 and LVM.
Install a minimal debian (etch) system
As soon as your minimal etch is up an running, we remove some packages and install additional software:
apt-get install xen-hypervisor-3.0.3 xen-utils-3.0.3 linux-image-2.6.18-3-xen-k7
Configure serial console access
Edit your /boot/grub/menu.lst
Add the following below the default entry
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 terminal --timeout=30 serial console
Edit the lines below to tell xen about your serial console:
## Xen hypervisor options to use with the default Xen boot option # xenhopt=dom0_mem=262144 com1=115200,8n1 console=com1 ## Xen Linux kernel options to use with the default Xen boot option # xenkopt=console=tty0,com1
Run update-grub
to finalize your settings.
Edit /etc/inittab: uncomment the line starting with T0
# Example how to put a getty on a serial line (for a terminal) # T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100 #T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
After editing /etc/inittab instruct init to reread its config:
init q
That's it. Reboot and you should be able to access your serial console with minicom.
Administration
Howto handle your installed guests …
List all running guests:
xm list
Switch Console to guest with id 2:
xm console 2
Return with console to Dom0:
Putty: press <ctrl> + 5 or <ctrl> + <altgr> + 9
Configuration
A sample configuration file (/etc/xen/wiggum):
kernel = "/boot/vmlinuz-2.6.18-3-xen-k7" ramdisk = "/boot/initrd.img-2.6.18-3-xen-k7" memory = 256 vif = [ '' ] root = "/dev/sda1 ro" disk = [ "file:/srv/xen/wiggum/wiggum.disk.img,sda1,w", "file:/srv/xen/wiggum/wiggum.swp,sda2,w" ]
HINT: no virtual machine would startup until I added the ramdisk
line to my config.
Create DomU
How to create a guest installation of debian etch. The guests hostname will be “wiggum”. The xen config file for wiggum is here
First I create a disk image of 3 GB size:
dd if=/dev/zero of=wiggum.disk.img bs=1M count=1 seek=3072
next I format the image file with ext3 filesystem:
mke2fs -F -j wiggum.disk.img
create 256 MB swap file
dd if=/dev/zero of=wiggum.swp bs=1024 count=262144 mkswap wiggum.swp
mount the disk image file to /mnt
mount -o loop wiggum.disk.img /mnt/
debootstrap
debootstrap --arch i386 etch /mnt http://your.mirror/debian
copy the kernel modules to /mnt/lib/modules
cp -ax /lib/modules/2.6.18-3-xen-k7/ /mnt/lib/modules/
create a valid fstab, something like this:
# /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> /dev/sda1 / ext3 defaults 1 1 /dev/sda2 none swap sw 0 0 proc /proc proc defaults 0 0 sysfs /sys sysfs noauto 0 0 usbfs /proc/bus/usb usbfs noauto 0 0 devpts /dev/pts devpts mode=0620,gid=5 0 0
copy /etc/passwd and /etc/shadow to /mnt/etc
edit hostname and hosts to meet your needs
echo wiggum > /mnt/etc/hostname echo "127.0.0.1 localhost" > /mnt/etc/hosts echo "127.0.1.1 wiggum.domain.lan wiggum" >> /mnt/etc/hosts
deaktivate TLS and umount
mv /mnt/lib/tls /mnt/lib/tls.disabled umount /mnt
puh, now it's time to bootup your guest:
xm create /etc/xen/wiggum -c
wiggum
should boot up … Login to your brand new guest and countinue with the configuration:
the network is still down and needs some tune up:
/etc/network/interfaces
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 allow-hotplug eth0 iface eth0 inet dhcp
HINT: if dhcp is unavailable or doesn't work use a static ip configuration.
apt-get install locales console-data dpkg-reconfigure locales console-data # with libc6-xen you won't have any problem with TLS in the future :-) apt-get install libc6-xen
xen-tools
Install them:
apt-get install xen-tools
Creating a DomU with xen-tools reduces your effort to a single command:
xen-create-image \ --hostname testman \ --lvm vgdrbd0 \ --dhcp \ --dist etch \ --swap 256Mb \ --memory 128Mb \ --passwd \ --kernel /boot/vmlinuz-2.6.18-4-xen-amd64 \ --initrd /boot/initrd.img-2.6.18-4-xen-amd64 \ --debootstrap
man xen-create-image
will give you detailed information about the options used above.
Links
Useful resources: