Before installing the dedicated server, please follow this layout as we'll use the left free space for LVM (once the machine is installed) :
Mountpoint | Size | FS type | Partition type |
---|---|---|---|
/boot | 256M | ext4 | Primary |
/ | 2048M | ext4 | Primary |
swap | 1024 | swap | Primary |
n/a | all free space | n/a | Extended |
/usr | 4096 | swap | Logical |
/var | 4096 | swap | Logical |
Xen install
- Retrieve Xen version and install package
apt-cache search xen-hypervisor apt-get install xen-hypervisor-4.x-amd64
- Check if Xen has been integrated to grub
grep Xen /boot/grub/grub.cfg
- Specify dedicated CPUs and memory for dom0 in /etc/default/grub :
I prefer not to restrict memory for dom0, let's allocate only one CPU :
GRUB_CMDLINE_LINUX="apparmor=0" GRUB_CMDLINE_XEN="dom0_max_vcpus=1 dom0_vcpus_pin"
- Launch update-grub
- Reboot
- Check if Xen kernel has been loaded on boot
xm list
Xen configuration
- Comment and uncomment those lines in /etc/xen/xend-config.sxp
#(vif-script vif-bridge) #(vif-script vif-route) (network-script network-nat) (vif-script vif-nat)
- Launch /etc/init.d/xen restart
VMs setup
- Create a 32 bits virtual machine
xen-create-image --lvm=datavg --size=4G --memory=256M --swap=256M --dist=wheezy --mirror=http://ftp.fr.debian.org/debian --force --ip=192.168.1.1 --netmask=255.255.255.0 --gateway=192.168.1.254 --hostname=wheezy32bits --kernel=/boot/vmlinuz-3.2.0-4-686-pae --initrd=/boot/initrd.img-3.2.0-4-686-pae --arch=i386 --fs=ext4
kernel and initrd files can be retrieved here :
- kernel : vmlinuz-3.2.0-4-686-pae
- initrd : initrd.img-3.2.0-4-686-pae
VM configuration file
/etc/xen/wheezy32bits.cfg
# # Configuration file for the Xen instance wheezy32bits, created # by xen-tools 4.3.1 on Sun Feb 9 16:25:13 2014. # # # Kernel + memory size # kernel = '/boot/vmlinuz-3.2.0-4-686-pae' ramdisk = '/boot/initrd.img-3.2.0-4-686-pae' vcpus = '1' cpus = '1,2,3' memory = '256M' # # Disk device(s). # root = '/dev/xvda2 ro' disk = [ 'phy:/dev/datavg/wheezy32bits-disk,xvda2,w', 'phy:/dev/datavg/wheezy32bits-swap,xvda1,w', ] # # Physical volumes # # # Hostname # name = 'wheezy32bits' # # Networking # vif = [ 'ip=192.168.1.1 ,vifname=vif1.1' ] # # Behaviour # on_poweroff = 'destroy' on_reboot = 'restart' on_crash = 'restart'
Starting the VM
- with console :
xm create wheezy32bits.cfg -c
- without console :
xm create wheezy32bits.cfg
Firewall
- dom0 firewall rules : firewall
- VMs firewall rules : firewall.VM