This is a quick guide and note myself to create a simple xen vm (domU) on Debian Squeeze.
I am assuming that you have a host running debian squeeze with the base system installed on it. I am using the default ext3 filesystem and not using lvm.
Install the required xen kernel. This is a paravirtualization setup and my processor doesn’t support full virtualization (HVM).
Executing all commands logged in as root. If not please append the sudo command after installing it using sudo apt-get install sudo and then add your user to the /etc/sudoers file using visudo command.
After that proceed to install the xen base system and xen tools. we will use the xen-linux-system meta package to automatically do the basic install.
# apt-get update
# aptitude -P install xen-linux-system
# apt-get install xen-tools
Update grub to defaultly boot the xen kernel
# mv -i /etc/grub.d/10_linux /etc/grub.d/21_linux
# update-grub
Edit the xen domains file as shown below. This is because Xen will save and restore a VM rather than do a clean shutdown, too much HDD resource usage.
vi /etc/default/xendomains
#XENDOMAINS_SAVE=/var/lib/xen/save
XENDOMAINS_SAVE=""
#XENDOMAINS_RESTORE=true
XENDOMAINS_RESTORE=false
reboot the machine now to boot into the new kernel.
# reboot
edit /etc/xen-tools/xen-tools.conf to have the below configuration settings at a minimum.
dir = /home/xen
install-method = debootstrap
size = 4Gb # Disk image size.
memory = 128Mb # Memory size
swap = 256Mb # Swap size
fs = ext3 # use the EXT3 filesystem for the disk image.
#dist = `stable` # Default distribution to install.
image = sparse # Specify sparse vs. full disk images.
dhcp = 1
passwd = 1
kernel = /boot/vmlinuz-`uname -r`
initrd = /boot/initrd.img-`uname -r`
mirror = `xt-guess-suite-and-mirror --mirror`
mirror_squeeze = http://cdn.debian.net/debian
ext3_options = noatime,nodiratime,errors=remount-ro
ext2_options = noatime,nodiratime,errors=remount-ro
xfs_options = defaults
reiserfs_options = defaults
btrfs_options = defaults
Create the squeeze vm using the xen-create-image command below. I am creating it to use our default dhcp server to get an ip.
# xen-create-image --hostname xen1.local.com --vcpus 1 --pygrub --dist squeeze --dhcp
General Information
--------------------
Hostname : xen1.local.com
Distribution : squeeze
Mirror : http://ftp.de.debian.org/debian/
Partitions : swap 256Mb (swap)
/ 4Gb (ext3)
Image type : sparse
Memory size : 128Mb
Kernel path : /boot/vmlinuz-2.6.32-5-xen-amd64
Initrd path : /boot/initrd.img-2.6.32-5-xen-amd64
Networking Information
----------------------
IP Address : DHCP [MAC: xx:xx:xx:xx:xx]
Creating partition image: /home/xen/domains/xen1.local.com/swap.img
Done
Creating swap on /home/xen/domains/xen1.local.com/swap.img
Done
Creating partition image: /home/xen/domains/xen1.local.com/disk.img
Done
Creating ext3 filesystem on /home/xen/domains/xen1.local.com/disk.img
Done
Installation method: debootstrap
After sometime of processing the command will exit as successful.
On my machine I had to comment out the line in the /etc/xen/xend-config.sxp file before I could boot the domain.
vi /etc/xen/xend-config.sxp
#(vif-script vif-bridge)
(network-script network-bridge)
restart xend
sudo /init.d/xend restart
I started up the domain with the command
# xm create /etc/xen/xen1.local.com.cfg -c
To exit the console once you are done use ^] (ctrl + ]).
Thanks,
Jose