Debian Sarge on Xen

From ConShell
Jump to: navigation, search

Quick instructions for installing a Debian Sarge VM on Xen

REFERENCE

http://wiki.xensource.com/xenwiki/DebianSarge

PROCEDURE

Prepare your storage. You can use partitions, LVM volumes or simple file-based images. I choose file-based for the flexibility - for a real server you would NOT want to use a file-based because the IO sucks, use real partitions or LVM volumes.

Choosing a suitably large partition (/usr) I linked it into /opt/xen

 mkdir /usr/xen
 ln -s /usr/xen /opt/xen

Bootstrap Debian into a file-based image (note: this is a meager setup of 1GB root / and 128MB swap, you'll likely want much more for a real-world VM)

 mkdir -p /opt/xen/domains/vm01
 dd if=/dev/zero of=/opt/xen/domains/vm01/diskimage bs=1024k count=1024
 dd if=/dev/zero of=/opt/xen/domains/vm01/swapimage bs=1024k count=128
 mkfs.ext3 /opt/xen/domains/vm01/diskimage
 mkswap /opt/xen/domains/vm01/swapimage
 mkdir /mnt/disk
 mount -o loop /opt/xen/domains/vm01/diskimage /mnt/disk
 apt-get install debootstrap #If necessary
 debootstrap --arch i386 sarge /mnt/disk http://ftp.us.debian.org/debian
 chroot /mnt/disk /bin/bash
 cd /etc; vi hostname hosts resolv.conf

Add minimal entries as desired.

Create an /etc/fstab file

 /dev/sda1     /     ext3     errors=remount-ro     0     1
 /dev/sda2     none  swap     sw                    0     0
 proc          /proc proc     defaults              0     0

Logout and unmount /mnt/disk

Now you can setup the first VM (aka vm01)

 cat > /etc/xen/vm01.cfg
 kernel = "/boot/vmlinuz-2.6.10-xenU"
 memory = 96
 name = "vm01"
 dhcp = "dhcp"
 disk = [ 'file:/opt/xen/domains/vm01/diskimage,sda1,w','file:/opt/xen/domains/vm01/swapimage,sda2,w' ]
 root = "/dev/sda1 ro"

Start it

 xm create vm01.cfg -c
 > Using config file "/etc/xen/vm01.cfg".
 > Started domain vm01, console on port 9601

Show it

 xm list

Attach to it (already done if used -c above)

 xm console vm01

Login as root (no password yet set), set the root password and update.

 passwd root
 /usr/sbin/base-config
 aptitude update
 aptitude upgrade


Here are the additional steps I needed in customizing the initial debian image:

Disable tls libraries in domU

 mv /lib/tls /lib/tls.disabled

Setup tty1->tty6 (required for inittab)

 cd /dev
 ./MAKEDEV tty1 tty2 tty3 tty4 tty5 tty6


Setup /etc/network/interfaces

 cat > /etc/network/interfaces << EOF
 # 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
 iface eth0 inet dhcp
 EOF