Today I bought a new hard disk, and tried to install xen on it.
Install Base ArchLinux
-
Start computer with USB key, choose x86_64, NBD;
-
This is not UEFI boot: an error raised when
efivar -l
; -
Install system:
rmmod tg3
modprobe broadcom
modprobe tg3
systemctl stop dhcpcd.service
dhcpcd enp2s0
sgdisk --zap-all /dev/sda
cgdisk /dev/sda
// choose GPT partitions type, /dev/sda1: 50G, /dev/sda2: 300G, 581G free
mkfs.ext4 /dev/sda1
mkfs.ext4 /dev/sda2
mount /dev/sda1 /mnt
mkdir /mnt/home
mount /dev/sda2 /mnt/home
vi /etc/pacman.d/mirrorlist
export http_proxy=http://10.32.1.154:8888
export https_proxy=http://10.32.1.154:8888 // add the ip into "allow" list tinyproxy.conf
pacstrap -i /mnt base base-devel
genfstab -U -p /mnt >> /mnt/etc/fstab
vi /etc/locale.gen
locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
export LANG=en_US.UTF-8
ln -s /usr/share/zoneinfo/Hongkong /etc/localtime
hwclock --systohc --utc
echo xenserver > /etc/hostname
vi /etc/hosts
systemctl enable dhcpcd@enp2s0.service
passwd
export http_proxy=http://10.32.1.154:8888
export https_proxy=http://10.32.1.154:8888
pacman -S openssh
systemctl enable sshd.service
pacman -S gptfdisk // use syslinux boot loader for GPT installed previously
pacman -S syslinux
syslinux-install_update -iam
vi /boot/syslinux/syslinux.cfg // modify sda3 to sda1 in "APPEND root=/dev/sda3"
exit
reboot
Customize System
After reboot, login as root and run:
# useradd -m chad
# passwd chad
# passwd -l root // disable root login, use can remove this by `sudo passwd -u root`
# export http_proxy=http://10.32.1.154:8888
# export https_proxy=http://10.32.1.154:8888
# pacman -Syu
# pacman -S xorg-server xorg-server-utils xorg-xinit i3 dmenu xf86-video-intel terminator ttf-dejavu firefox
# su - chad
$ echo exec i3 > ~/.xinitrc
$ startx
Install Xen
First make sure the host can access internet, then enable multilib repository, uncomment following lines in /etc/pacman.conf:
[multilib]
Include = /etc/pacman.d/mirrorlist
Install yaourt, see note "Yaourt Notes" for details. Then run yaourt -S xen
. If failed, install it manually:
Download xen.tar.gz, and run:
tar xf xen.tar.gz
cd xen
makepkg
sudo pacman -U xen-4.4.1-1-x86_64.pkg.tar.xz
Config network:
# cd /etc/netctl
# cp examples/bridge xenbridge-dhcp
# vi xenbridge-dhcp
# netctl start xenbridge-dhcp
# brctl show
# netctl enable xenbridge-dhcp
Config services:
sudo systemctl enable xenstored.service
sudo systemctl enable xenconsoled.service
sudo systemctl enable xendomains.service
Config boot loader. Add following stanza to /boot/syslinux/syslinux.cfg:
LABEL xen
MENU LABEL Xen
KERNEL mboot.c32
APPEND ../xen-4.4.1.gz --- ../vmlinuz-linux console=tty0 root=/dev/sda1 ro --- ../initramfs-linux.img
And make sure there is a "mboot.c32" file in folder /boot/syslinux, or you have to copy it:
cp /usr/lib/syslinux/bios/mboot.c32 /boot/syslinux/
.
Note: If there is file conflicting errors, use sudo pacman -U --force xen-4.4.1-1-x86_64.pkg.tar.xz
to install it.
Reboot, choose "Xen" at boot screen, then run sudo xl list
(list all xen domains), you can see a "Domain-0" item.
If you boot with ArchLinux, run sudo xl list
will report an error.
Install Guest OS on Xen
See Xen Configuration File Options for full syntax of xen domU config files.
CentOS 6.5 minimal
PV
Not succeed yet. Maybe we should use CentOS as dom0 system.
$ mkdir ~/docs/cloud60
$ cd ~/docs/cloud60
$ dd if=/dev/zero of=cloud60.img bs=1M count=10240
$ mkfs.ext4 cloud60.img
$ sudo mount -o loop CentOS-6.5-x86_64-minimal.iso /mnt
$ cat cloud60.conf // ???
$ sudo xl create -c cloud60.conf
HVM
$ sudo pacman -S mesa-libgl bluez-libs tigervnc
$ mkdir ~/docs/cloud60
$ cd ~/docs/cloud60
$ dd if=/dev/zero of=cloud60.img bs=1M count=10240
$ mkfs.ext4 cloud60.img
$ sudo mount -o loop CentOS-6.5-x86_64-minimal.iso /mnt
$ cat cloud60.conf
name = "hvmcentos"
builder = "hvm"
memory = 1024
disk = [ "file:/home/chad/docs/cloud60/cloud60.img,xvda,w", "file:/home/chad/warez/CentOS-6.5-x86_64-minimal.iso,xvdb:cdrom,r" ]
vif = ["bridge=xenbr0"]
vnc = 1
vnclisten = "0.0.0.0"
vncdisplay = 1
$ sudo xl create cloud60.conf
$ sudo xl vncviewer hvmcentos
Or you can use vncviewer localhost:5901
to connect to the guest OS, here the "1" in "5901" is determined by the value of "vncdisplay" in guest OS config file.
After connecting to the guest OS, install system, then reboot and connect it with vncviewer again.
You can use xl's subcommands "list", "top" and "info" to probe domU systems.
Using Xen
Based on Xen on Arch Wiki.
Use Debian as dom0: Xen Project Beginners Guide;
Use CentOS as dom0: Xen4 CentOS6 QuickStart;
Use Ubuntu as dom0: Xen in Ubuntu Community;
Other patterns see Guest Install;