Table of Contents
Xen Howto, by Luke Scharf
Create the disk image:
dd if=/dev/zero of=root.img bs=1048576 count=4096
Format the disk image:
/sbin/mkfs.ext3 root.img
similar to root for /var and /tmp if used
Mount the root disk image:
mount -o loop $PWD/root.img /mnt/tmp
install debootstrap
yum install debootstrap
Here are the instructions I worked off of, but I [Luke] didn't follow them precisely at all:
http://wiki.xensource.com/xenwiki/DebianDomU
debootstrap --arch i386 etch /mnt/tmp http://ftp.us.debian.org/debian
After that, you can chroot into the /mnt/whatever and then run apt-get to install the Xen kernel.
apt-get install xen-linux-system-2.6.18-6-xen-686 (or the current version)
Then you copy the Xen kernel and the Xen initrd out of /mnt/whatever, and put together a configuration file for Xen.
The big thing that got me was figuring out what should be in the VM directory. It should be:
1. Disk image(s) 2. Xen-aware Kernel 3. Xen-aware Initrd 4. A config-file that describes the configuration of the VM to Xen. Most of the stuff that is hard to put into context in Xen documentation goes here.
Apparently the stuff that goes in the config file varies based on the version of Xen. There are some options that are in most example files that are really set by the running guest, so I took them out. (I thought having meaningless non-information in the file was confusing.)
Here's an ls of what the Xen directory looks like:
$ ls -lh /xen/babble/ total 335M -rw-r--r--+ 1 root root 401 2008-04-05 12:18 babble.cfg -rw-r--r--+ 1 root root 4.4M 2008-04-05 12:11 initrd.img-2.6.18-6-xen-686 -rw-r--r--+ 1 root root 4.0G 2008-04-15 15:17 root.img -rw-------+ 1 root root 512M 2008-04-05 12:28 swap.img -rw-------+ 1 root root 512M 2008-04-15 15:17 tmp.img -rw-r--r--+ 1 root root 4.0G 2008-04-15 15:17 var.img -rw-r--r--+ 1 root root 1.2M 2008-04-05 12:11 vmlinuz-2.6.18-6-xen-686
The file that I sent you before is babble.cfg. These are the files referenced in babble.cfg.
Note that I decided to use a number of different volumes for this particular DomU – rather than just root. This is a production server, so I wanted to make sure that / /tmp or /var being filled up wouldn't have terribly systemic effects. Making a swap partition would be a good idea in your all's minimal test-configuration.
Xen Sample DomU/Guest configuration file
# Xen name = "babble" # Kernel and Boot kernel = "/xen/babble/vmlinuz-2.6.18-6-xen-686" ramdisk = "/xen/babble/initrd.img-2.6.18-6-xen-686" # Memory memory = 256 # Disk disk = ['file:/xen/babble/root.img,sda1,w','file:/xen/babble/var.img,sda2,w','file:/xen/babble/tmp.img,sda3,w','file:/xen/babble/swap.img,sda4,w'] root = "/dev/sda1 ro" # Network vif = ['mac=00:16:3E:ba:bb:1e','bridge=xenbr0'] [luke.scharf@workerbee babble]$
for swap partition
dd if=/dev/zero of=swap.img bs=1048576 count=512 mkswap swap.img
add to fstab
# /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 /dev/hda1 / ext3 defaults,errors=remount-ro 0 1 /dev/hda2 none swap sw 0 0
In chroot environment the the DomU because of a discrepency in the c's on Domain-0 and DomU,
apt-get install libc6-xen
For DHCP,
/etc/network/interfaces
:~# cat /etc/network/interfaces # Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or # /usr/share/doc/ifupdown/examples for more information. auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp
“xm create” is more like “xm read the config file and boot”.
xm create first -c first.cfg
If the index of the inet interfaces gets messed up because of the random mac address assignment, remove the entries from
/etc/udev/rules.d/z25_persistent-net.rules
51 ifconfig -a 52 grep -re 'eth4' . 53 cd udev/ 54 cd rules.d/ 55 ls 56 vim z25_persistent-net.rules
loopback devices
There are only 10 loopback devices by default.
http://snippets.aktagon.com/snippets/70-Fix-for-Failed-to-find-an-unused-loop-device-when-using-xen
If you use Xen and get an error “Failed to find an unused loop device” when you try to create a guest then you are probably using disk images and have run out of loop devices. Each guest uses at least two loop devices. Modify (or create) a file called /etc/modprobe.d/local-loop and add this line:
1 options loop max_loop=64
common sources
Fedora
http://fedoraproject.org/wiki/FedoraXenQuickstartFC6#head-a41b0863d68a48ee8c261adc18e7265b8355c33b
yum install virt-viewer /usr/sbin/virt-install virt-manager ??
Distro's to try
andLinux (not necessarily Xen able)
Windows executable that runs on windows to give a linux distro
http://www.linux.com/feature/131753
The coLinux project takes a stable release of the Linux kernel and ports it to run on Windows. That means that, unlike virtualization software, andLinux installs on Windows like any other application.
Windows
Works using virt-manager, except it won't find the CD on reboot, so, modify /etc/xen/<xen config file> and add the second part to specify the cdrom:
disk = [ "file:/xen/win2k3.img,hda,w", "file:/opt/nfs/Win2K3server_SP2.iso,ioemu:hdc:cdrom,r" ]
http://mediakey.dk/~cc/howto-install-windows-xp-vista-on-xen/
log on
press ctrl three times then alt-delete
Other Links
Re-booting riccioli, the xen server
riccioli aka xentest, ntinstall
power down
shut down xen machines
log on to riccioli and open virt-manager, then shut each machine down
$ ssh xentest (for steve) $ ssh 128.173.188.30 -p 32777 -l root
[root@riccioli ~]# virt-manager &
open each machine, log on and shut down. For the linux machines, use the command
webtest # poweroff xenwebf9 # poweroff win2k3sp2 -- Start, Shutdown
poweroff riccioli
[root@riccioli ~]# poweroff (or reboot)
power up
turn riccioli on
[root@riccioli ~]# virt-manager &
right click on these machines and select run.
webtest xenwebf9 win2k3sp2
[root@riccioli ~]# service firewall restart (for some odd reason the virtual machines do not allow packets to forward when started from the system)
[root@riccioli ~]# setenforce permissive