Xen
From FlimzyWiki
Contents |
[edit]
My Xen on Debian 4.0 Cookbook
[edit]
Installing the Dom0 (on an amd64 target)
- Boot from Debian 4.0 (etch) amd64 install CD -- Don't use the rc1 CD, as it's broken. Use a later rc, or a nightly build
- Select your appropriate language/region/timezone settings
- Enter an appropriate hostname. I suggest not ending the hostname in a letter to make my LVM naming convention less ugly. But do what you like. I used 'xena', 'xenb', .. 'xenN' for my test setup.
- When prompted to partition, select manual partitioning:
- Create a 100mb ext3 primary partition and mount it as /boot
- Partition the entire rest of the disk as type LVM physical volume.
- Create an LVM Volume Group named the same as the hostname, followed by the number 0. (i.e. xena0, xenb0, etc) Don't name your volume group the same as your hostname to avoid possible VG name collisions should you ever add another VG or move a VG to this machine
- Create a 1gb logical volume called 'swap' and mark it to be used as swap
- Create a 5gb logical volume called 'root' and format it as ext3 and mark to be used as /
- Leave the rest of the LVM space unused for the moment
- Confirm changes and write to disk
- Install the rest of the base system and install grub when prompted
- Reboot
- De-select all package options--the only service you really want running on the Dom0 is xend
- Log in as root and install a few essential packages:
apt-get install less ssh joe screen bridge-utils
- Edit /etc/network/interfaces:
auto lo
iface lo inet loopback
auto br-priv
iface br-priv inet manual
bridge_ports eth0
bridge_maxwait 0
auto br-pub
iface br-pub inet static
address 192.168.0.x
netmask 255.255.255.0
network 192.168.0.255
broadcast 192.168.0.255
dns-search pub.domain.com
bridge_ports eth1
bridge_maxwait 0
The rest of the config can be done remotely if desired.
- Install the essential packages for using Xen:
apt-get install debootstrap linux-image-2.6-xen-amd64 \ xen-hypervisor-3.0.3-1-amd64 xen-docs-3.0 bzip2 libc6-xen lsof
- Reboot to begin using the new Xen-enabled kernel
[edit]
Creating a DomU
- Create a file in /etc/xen named after the DomU you wish to create. "xena0" for instance:
name = "domu00" kernel = "/boot/vmlinuz-2.6.18-3-xen-amd64" root = "/dev/sda1" memory = 768 disk = ['phy:/dev/xena0/domu00-root,sda1,w','phy:/dev/xena0/domu00-swap,sda2,w'] ramdisk = "/boot/initrd.img-2.6.18-3-xen-amd64" vif = ['mac=aa:00:00:00:00:01,bridge=br-pub']
- Prepare the partitions:
lvcreate -L5G -n domu00-root xena0 lvcreate -L1G -n domu00-swap xena0 mkswap /dev/xena0/domu00-swap mkfs -t ext3 /dev/xena0/domu00-root
- Populate the root filesystem:
mount /dev/xena0/domu00-root /mnt debootstrap etch /mnt
If you wish to populate the root filesystem using an existing filesystem, for instance to migrate a physical server to a virtual machine, try these instructions: Migrating to Xen
[edit]
Configure the DomU
- Create /mnt/etc/fstab:
# <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 /dev/sda1 / ext3 defaults,errors=remount-ro 0 1 /dev/sda2 none swap sw 0 0
- Create /mnt/etc/network/interfaces:
auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp
- Edit /mnt/etc/hostname
- Edit /mnt/etc/hosts
- Copy essential Xen files to the domU:
cp /boot/*xen* /mnt/boot cp -a /lib/modules/2.6.18-3-xen-686 /mnt/lib/modules
- Disable TLS (i386 only??)
mv /mnt/lib/tls /mnt/lib/tls.disabled
- Chroot to the new directory to make final configuration changes:
chroot /mnt
- Set the root password:
passwd
- Create a user account:
adduser <username>
- Install locales (to stop all the annoying errors during package installations):
apt-get install locales dpkg-reconfigure locales
- Install and configure any additional packages you wish, then exit.
apt-get install joe screen ssh less
- Unmount any filesystems that were mounted during the install (probably /proc and /sys--run 'mount' to check). Then exit the chroot.
umount /proc umount /sys exit
- Unmount the domU's filesystem:
umount /mnt
[edit]
Start the DomU
xm create -c domu00

