Wednesday 15 January 2014

Standing on the shoulders of giants

This is a guide to setting up the Xen hypervisor on Arch Linux.

I've been having a whale of a time over the past 4-5 weeks learning as much as I can about virtualisation with the objective of configuring a unified server to run;

  • unRAID
  • mediaportal server (windows VM) with DVB-S2 tuner cards passed through
  • at least one mediaportal client (windows VM) with GPU & USB passed through

I've bought and built a new machine for this and I've been playing variously with Linux distros such as OpenSuSe, Manjarobox and now vanilla ArchLinux. With all of the above I've tried both Xen and KVM as virtualisation hosts.

I've been enjoying the discussion on unRAID forums around virtualisation and the possibility of running unRAID in a full distro but am hedging my bets and want to become very familiar with setting up a system like this where unRAID can run either on the host system or in a VM.


Rather than try to do everything at once, I've decided it's best to take baby steps. My objective right now now is to build an ArchLinux system with Xen. Once established, I'll play with that, get familiar with making VMs etc. and then later move on to configuring passthrough.

From my tests so far, I've settled on Xen as gpu passthrough seems to be a bit more straightforward than on KVM (or I just haven't found a good KVM guide yet)

Anyway, the work of IronicBadger and GrumpyButFun on the unRAID forums has been inspirational and I've been following their threads, posts, guides and blogs with deep interest.

However, while all the steps for building such a system are there in their output, what I've found is that the required info is fragmented. Some guides are incomplete, others assume a certain level of knowledge or take shortcuts or refer to other (unlinked) documents.

What I've done here is write a consolidated meta-guide that lists all the steps in an efficient order and includes any clarifications or gotchas I've found, investigated and resolved in following the instructions from the guys. Essentially, the response of a user with basic linux skills drawing together all the bits and pieces,(and a reference for myself for when I want to re-do this at some point in the future).

So, below I reproduce yagxup v0.2 (yet another guide for xen and unraid with passthrough).



pre-install notes

Things change. This guide can only be up to date at the time of writing. Caveat emptor.


prerequisites

before attempting this you should;

  1. be familiar with issuing linux commands in CLI
  2. be familiar with editing files in nano



STEP 1 - Install ArchLinux

Follow IronicBadger's ArchLinux install guide which utilises ArchBoot with a visual installer (as opposed to cli espoused on ArchWiki beginners guide).

This gets you to the stage of booting ArchLinux and allowing root login.

Gotchas
The ISO image link in the guide is broken. This appears to be the current ISO link;
url=http://mirror.cinosure.com/archlinux/iso/archboot/latest/archlinux-2013.10-1-archboot-network.iso




STEP 2 - Post Install Setup

2.1 Grub Update Bug Fix

issue this command;

nano /etc/default/grub

In nano, add this to the file
GRUB_DISABLE_SUBMENU=y

(From http://blog.ktz.me/?p=308. Newer versions of the ArchLinux netbook ISO (Jan 2014 and later) don't need this fix but were not available at the time of writing).





2.2 Configure pacman & update

Edit /etc/pacman.conf in nano.

Uncomment [multilib] block and add the following underneath;
[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/$arch
save and then update pacman with the following

pacman -Syyu




2.3 Install SSH

Set up SSH and get it to start on boot;

pacman -S openssh
systemctl enable sshd.service
systemctl start sshd.service



2.4 Create a user

useradd -m -g users -s /bin/bash <username>
usermod -a -G wheel <username>
passwd <username>




2.5 Configure nano as default

in /etc/bash.bashrc add;
export EDITOR=nano




2.6 Configure sudo

pacman -S sudo
EDITOR=nano visudo

uncomment this line;
%wheel ALL=(ALL) NOPASSWD: ALL




2.7 Install utilities

pacman -S unzip
pacman -S wget




STEP 3 - Install Xen


3.1 Download precompiled Xen

navigate to a suitable directory and download IronicBadgers Xen package;

wget http://blog.ktz.me/wp-content/uploads/2013/09/xen-4.3.1-2-x86_64.pkg_.tar.xz_.zip

OR download the same file as linked by GrumpyButFun;

https://drive.google.com/file/d/0B396mkxPBhWrZU9ySThQZzZFYnc/edit?usp=sharing






3.2 Install Xen

unzip *.zip
su
pacman -U xen-4.3.1-2-x86_64.pkg_.tar.xz




3.3 Update grub

grub-mkconfig -o /boot/grub/grub.cfg

This adds the Xen kernel to the grub boot menu.



3.4 Set Up services

systemctl enable xenstored.service
systemctl enable xenconsoled.service
systemctl enable xendomains.service




3.5 Reboot

reboot

You should select the Xen option from the grub menu during restart



STEP 4 - Post-Xen install

4.1 Set up network bridge

Follow grumpybutfun's guide at the start of this post;

http://lime-technology.com/forum/index.php?topic=30980.msg279094#msg279094



4.2 Set up libvirt

Follow grumpybutfun's guides to enabling libvirt and configuring ssh/tcp;

http://lime-technology.com/forum/index.php?topic=30980.msg279083#msg279083
http://lime-technology.com/forum/index.php?topic=30980.msg279084#msg279084



You should now have a working installation of Xen on Arch Linux.


REFERENCES & SOURCES

ArchLinux Installation guide;
https://wiki.archlinux.org/index.php/Installation_Guide

ArchLinux Beginners guide;
https://wiki.archlinux.org/index.php/Beginners%27_Guide

ArchLinux Network Bridge setup guide;
https://wiki.archlinux.org/index.php/xen#Creation_of_a_network_bridge

IronicBadger's ''How to install ArchLinux'
http://blog.ktz.me/?p=131

IronicBadger's 'perfect media server setup with Arch Linux, Xen and XBMC'
http://blog.ktz.me/?p=120

GrumpyButFun's '[GUIDE] Virtualizing unRaid in Xen / KVM on Arch Linux'
http://lime-technology.com/forum/index.php?topic=30980.0

No comments: