Xen Dom0: Difference between revisions

From Alpine Linux
(fully working now)
(actually hyphens, not underscores)
(28 intermediate revisions by 12 users not shown)
Line 1: Line 1:
So before anything else verify that you car '''reliably''' log into your Alpine box through ssh, because with some video chipset (intel in my case) xen will blank your screen so you will have to use ssh.
This guide will show you how to perform a Xen Dom0 install on a HDD, so you can have your Dom0. The first step is to perform a normal HDD install of Alpine Linux, which can be accomplished following the guide [[Install to disk]]. Once the install is finished, and you have rebooted into your new system, it's time to install the Xen packages:


Then upgrade you setup to Edge / testing (as of the date of writing, Xen is only avaible in Edge).
<pre>
Install Xen:
# apk add xen xen-hypervisor seabios
apk add xen
</pre>


Modify your extlinux.cfg: http://lists.alpinelinux.org/alpine-devel/1406.html
Then [https://wiki.alpinelinux.org/wiki/Enable_Community_Repository enable the community repositories] and install ovmf from community.


timeout 20
<pre>
prompt 1
# apk add ovmf
default grsec
</pre>
label grsec
kernel /boot/vmlinuz-grsec
append initrd=/boot/initramfs-grsec root=UUID=f40e340b-ea49-445b-81c0-4d7104b56662 modules=sd-mod,usb-storage,ext4
label xen
kernel mboot.c32
append /boot/xen-4.gz console=/dev/null dom0_mem=256M vga=mode-0x0311 --- /boot/vmlinuz-grsec root=UUID=f40e340b-ea49-445b-81c0-4d7104b56662 modules=sd-mod,usb-storage,ext4 vga=785 --- /boot/initramfs-grsec


Of course replace root=UUID= with '''your''' UUID in yours.
Default menu.c32 can mangle with Xen, further investigation needed, so don't use for now.


Use the script found here: http://lists.xensource.com/archives/html/xen-devel/2010-03/msg01605.html
'''seabios''' and '''ovmf''' provide BIOS and UEFI firmwares for Xen virtual machines. Please be advised that ovmf is part of the community repository. In order to download it, you will need to add the community repository to [[Alpine_Linux_package_management#Packages_and_Repositories|your configuration]].


#!/bin/sh
This will install Xen Hypervisor, xl cli command and all the required packages. The next step is to modify your extlinux.conf and add an entry to boot Xen:


test -d /proc/xen      || exit 0
Normal boot:
test -f /proc/xen/capabilities  || mount -t xenfs xen /proc/xen
test -f /proc/xen/capabilities  || exit 0
grep -q "control_d" /proc/xen/capabilities      || exit 0


for module in xen-evtchn evtchn blkbk netbk; do
<pre>
        modprobe ${module}>/dev/null 2>&1
LABEL xen
        done
  KERNEL /boot/mboot.c32
  APPEND /boot/xen.gz --- /boot/grsec root=UUID=<YOUR-DISK-UUID> modules=ext4 --- /boot/grsec.gz
</pre>


xl info won't work
Serial console boot:
<pre>
LABEL xen
  KERNEL /boot/mboot.c32
  APPEND /boot/xen.gz com1=115200,8n1 console=com1 --- /boot/grsec root=UUID=<YOUR-DISK-UUID> modules=ext4  --- /boot/grsec.gz
</pre>


Start xecommons:
{{Note|<nowiki>remember to change <YOUR-DISK-UUID> with the UUID of your boot disk (you can copy it from the normal Alpine Linux boot entry)</nowiki>}}
xencommons  use bash, so install it: apk add bash (should try sh instead)
alpine:/boot# /etc/init.d/xencommons start
Starting xenstored...FATAL: Failed to open evtchn device: No such file or directory


well this will fail but xl info will work anyway
com1=115200,8n1 console=com1 redirect xen and dom0 to a physical serial port, handy if you want to use a serial null modem cable instead of a keyboard+monitor combo or if your server has an kvm over ip.


Oh but wait, evtchn device is built in the kernel, so why is there no /dev/xen/evtch file ?
It's also a good idea to check [http://wiki.xen.org/wiki/Xen_Hypervisor_Boot_Options Xen Boot options] and set dom0_mem, dom0_vcpus_pin and dom0_max_vcpus at least.
let's start udev ! ;)


That's all folks !
The next step is to load the necessary kernel modules for Xen, we will add them to /etc/modules, so they will be loaded automatically on boot:
 
<pre>
# echo "xen-netback" >> /etc/modules
# echo "xen-blkback" >> /etc/modules
# echo "tun" >> /etc/modules
</pre>
 
The last step is to configure startup services, we will need udev and xencommons at least to be started on boot:
 
<pre>
rc-update add xenconsoled
rc-update add xendomains
rc-update add xenqemu
rc-update add xenstored
</pre>
 
Ok, now you have a fully functional Xen install, it's time to boot into it.
 
<pre>
# reboot
</pre>
 
Also remember to configure at least one network bridge following the [[Bridge]] guide.
 
== Loop Devices ==
If you plan to use more than 8 DomU's, you may need to increase the amount of loop-devices in your Dom0.
 
In Alpine Linux, you will need to add the ''max_loop'' option to the ''loop'' module, then add the loop module to your initramfs.
 
Start by populating <code>/etc/modprobe.d/loop.conf</code> with the module options:
 
<pre>
# touch /etc/modprobe.d/loop.conf
# echo "options loop max_loop=32" > /etc/modprobe.d/loop.conf
</pre>
 
Now reflect the module options in the initramfs:
 
<pre>
# mkinitfs
# reboot
</pre>
 
== See also ==
* [[Xen Dom0 on USB or SD]]
 
[[Category:Virtualization]]

Revision as of 22:03, 27 November 2019

This guide will show you how to perform a Xen Dom0 install on a HDD, so you can have your Dom0. The first step is to perform a normal HDD install of Alpine Linux, which can be accomplished following the guide Install to disk. Once the install is finished, and you have rebooted into your new system, it's time to install the Xen packages:

# apk add xen xen-hypervisor seabios

Then enable the community repositories and install ovmf from community.

# apk add ovmf


seabios and ovmf provide BIOS and UEFI firmwares for Xen virtual machines. Please be advised that ovmf is part of the community repository. In order to download it, you will need to add the community repository to your configuration.

This will install Xen Hypervisor, xl cli command and all the required packages. The next step is to modify your extlinux.conf and add an entry to boot Xen:

Normal boot:

LABEL xen
  KERNEL /boot/mboot.c32
  APPEND /boot/xen.gz --- /boot/grsec root=UUID=<YOUR-DISK-UUID> modules=ext4 --- /boot/grsec.gz

Serial console boot:

LABEL xen
  KERNEL /boot/mboot.c32
  APPEND /boot/xen.gz com1=115200,8n1 console=com1 --- /boot/grsec root=UUID=<YOUR-DISK-UUID> modules=ext4  --- /boot/grsec.gz
Note: remember to change <YOUR-DISK-UUID> with the UUID of your boot disk (you can copy it from the normal Alpine Linux boot entry)

com1=115200,8n1 console=com1 redirect xen and dom0 to a physical serial port, handy if you want to use a serial null modem cable instead of a keyboard+monitor combo or if your server has an kvm over ip.

It's also a good idea to check Xen Boot options and set dom0_mem, dom0_vcpus_pin and dom0_max_vcpus at least.

The next step is to load the necessary kernel modules for Xen, we will add them to /etc/modules, so they will be loaded automatically on boot:

# echo "xen-netback" >> /etc/modules
# echo "xen-blkback" >> /etc/modules
# echo "tun" >> /etc/modules

The last step is to configure startup services, we will need udev and xencommons at least to be started on boot:

rc-update add xenconsoled
rc-update add xendomains
rc-update add xenqemu
rc-update add xenstored

Ok, now you have a fully functional Xen install, it's time to boot into it.

# reboot

Also remember to configure at least one network bridge following the Bridge guide.

Loop Devices

If you plan to use more than 8 DomU's, you may need to increase the amount of loop-devices in your Dom0.

In Alpine Linux, you will need to add the max_loop option to the loop module, then add the loop module to your initramfs.

Start by populating /etc/modprobe.d/loop.conf with the module options:

# touch /etc/modprobe.d/loop.conf
# echo "options loop max_loop=32" > /etc/modprobe.d/loop.conf

Now reflect the module options in the initramfs:

# mkinitfs
# reboot

See also