Alpine Linux Xen tips

 

 

I also run OpenNebula and stuff, so some ruby stuff sneaks in there.

 

This is what I install on any system:

"bacula-client", "procps", "bash", "python", "screen",
"ncurses", "gawk", "grep", "lsof", "ethtool", "iptables", "ip6tables",
"coreutils", "python", "vim", "zsh", "rsync"

I usually install the following dependency packages for Xen hosts:

"ruby", "ruby-gems", "iproute2", "libvirt", "pciutils", "dmidecode",
"ebtables", "dnsmasq", "lvm", "openvswitch", "libvirt-daemon",
"sg3_utils", "mdadm", "lsscsi"

 

I also added the following as a KVM fallback while Libvirt has issues with Xen. (Just like half a year, who cares about accessibility when you're hip)

"qemu", "libvirt-qemu", "qemu-img", "qemu-x86_64"

I might also install targetcli to run iSCSI into a VM from the host.

I'm still looking for the packages containing some utilities.

For example:

  • kpartx

 

 

I don't have notes about installing the Xen packages.

Do it as you found it in the docs.

Don't forget to

rc-update add xenstored
rc-update add xendomains

 

 

 

Some host specific stuff needs to be added to /etc/modules after installing Xen

echo "xen_netback
xen_blkback
tun
raid1
ipv6" >> /etc/modules
For bonded network interfaces (as configured below, we also need to initialize the bonding driver.
This is not done via /etc/modules to allow different options for each bond.

 

# cat /etc/modprobe.d/bonding.conf 
alias bond0 bonding
options bonding mode=1 miimon=100 downdelay=200

 

After most stuff seems ready, it is time to test things a little.
Later I'll also add some info to my /etc/update-extlinux.conf

 

# default                                                                                                                                           
# default kernel to boot                                                                                                                            
default=xen-grsec                                                                                                                                   
                                                                                                                                                    
# xen_opts                                            
xen_opts="dom0_mem=512M tmem tmem_compress tmem_dedup iommu=1 dom0_vcpus_pin dom0_max_vcpus=2 numa acpi=ht"

I give more RAM than the example since I found the memory calculation is broken and you'll have a few 100 meg less than you define. Everything with tmem is experimental stuff. Don't use it if you don't need it. Iommu=1 is said to be a default. Since the docs are useless / outdated I can't tell if it's true and thus set it. acpi=ht is my last straw since I would dearly love to reboot/poweroff my server which does not work!

 

These changes take effect by running update-extlinux


After a reboot, you should see the Xen bootup prior to your host boot, and be able to run "xl info" or "xl dmesg"


What you're still missing is a bridged networking config.

This example gives a full bridging + v6 config 

auto lo 
iface lo inet loopback 


auto br0 
iface br0 inet static 
pre-up brctl addbr br0 
pre-up echo 0 > /proc/sys/net/bridge/bridge-nf-call-arptables 
pre-up echo 0 > /proc/sys/net/bridge/bridge-nf-call-iptables 
pre-up echo 0 > /proc/sys/net/bridge/bridge-nf-call-ip6tables 
pre-up ip link set dev bond0 up 
address my_ip_addr
netmask 255.255.255.0 
broadcast my_subnet_broadcast
gateway my_gw
hostname my_hostname
post-down brctl delbr br0 

auto bond0 
iface bond0 inet manual 
up brctl addif br0 $IFACE 
#pre-up ip link set dev eth0 up 
bond-slaves eth0 
down brctl delif br0 $IFACE || true 
down ip link set $IFACE down 

# 1 gbit uplink, no LACP on this box 
auto eth0 
iface eth0 inet manual 
up ip link set $IFACE up 
down ip link set $IFACE down 


auto sixxs 
iface sixxs inet6 v4tunnel 
address 2001:6f8:xx:xx:xx:my:addr:
netmask 64 
endpoint ip4_tunnel_gw
ttl 64 
up ip link set mtu 1280 dev sixxs 
up ip route add default via 2001:6f8:xx:xx:xx dev sixxs 

As should become pretty obvious, if you add a few more NICs, a few dozen VLANs or more tunnels, the Debian-Style "networking" config file way of doing networking is a bad match for networking.

Suggestion would be to only bring up your management interface via the /etc/network/interfaces and do the rest elsewhere with something that wasn't designed by a dev for his laptop.

 

An example VM config.

# use these 3 lines and disable the pygrub line after them to install from iso. 
# Iso must be referenced in disk [] section and have the same driver slot (xvda, xvdb, xvdC) as given there.
#kernel  = "/home/grsec"
#ramdisk = "/home/grsec.gz"
#extra   = "alpine_dev=xvdc:iso9660 modules=loop,squashfs,sd-mod,usb-storage modloop=/boot/grsec.modloop.squashfs console=hvc0"
 
 
# Use this line for prod use
# bootloader = "pygrub"
 

# Path to HDD and iso file
disk = [
    # Watch out, this vm really has stuff in /home :>
    'file:/home/disk.img,xvda,w',
    'phy:/dev/vgxen/lvalpinedata,xvdb,w',
    'file:/home/alpine-2.5.0-x86_64.iso,xvdc:cdrom,r',
        ]
# Network configuration, autogenerates MAC on each boot unless you add it there using mac=de:ad:be:ef
vif = ['bridge=br0,ip=domU_ip']
# DomU settings
memory = 1024
maxmem = 4906
name   = "my_vm_hostname"
vcpus  = 2
on_crash = "restart"
on_shutdown = "destroy"
on_reboot = "restart"