Xen Dom0: Difference between revisions

From Alpine Linux
(network tips)
m (clean up)
Line 16: Line 16:
MENU AUTOBOOT Alpine will be booted automatically in # seconds.
MENU AUTOBOOT Alpine will be booted automatically in # seconds.
TIMEOUT 50
TIMEOUT 50
LABEL 0
LABEL 0
  MENU DEFAULT
  MENU LABEL Linux 2.6.38.8-vs2.3.0.37-rc17
  KERNEL vmlinuz-2.6.38.8-vs2.3.0.37-rc17
  APPEND initrd=initramfs-2.6.38.8-vs2.3.0.37-rc17 root=UUID=f40e340b-ea49-445b-81c0-4d7104b56662 modules=sd-mod,usb-storage,ext4 quiet
LABEL 1
  MENU LABEL Linux 2.6.36.3-scst
  KERNEL vmlinuz-2.6.36.3-scst
  APPEND initrd=initramfs-2.6.36.3-scst root=UUID=f40e340b-ea49-445b-81c0-4d7104b56662 modules=sd-mod,usb-storage,ext4 quiet
LABEL 2
  MENU LABEL Linux 2.6.38.8-grsec
  KERNEL vmlinuz-2.6.38.8-grsec
  APPEND initrd=initramfs-2.6.38.8-grsec root=UUID=f40e340b-ea49-445b-81c0-4d7104b56662 modules=sd-mod,usb-storage,ext4 quiet
LABEL 3
   MENU LABEL XEN
   MENU LABEL XEN
   KERNEL mboot.c32
   KERNEL mboot.c32
   APPEND /boot/xen-4.gz loglvl=all guest_loglvl=all com1=115200,8n1 console=com1 dom0_mem=256M --- /boot/vmlinuz-grsec root=UUID=f40e340b-ea49-445b-81c0-4d7104b56662 modules=sd-mod,usb-storage,ext4 console=hvc0 earlyprintk=xen nomodeset --- /boot/initramfs-grsec
   APPEND /boot/xen-4.gz iommu=1 dom0_mem=1024M dom0_max_vcpus=2 dom0_vcpus_pin  loglvl=all guest_loglvl=all com1=115200,8n1 console=com1 --- /boot/grsec root=UUID=f40e340b-ea49-445b-81c0-4d7104b56662 modules=ext4 console=hvc0 earlyprintk=xen nomodeset --- /boot/grsec.gz
</pre>
Of course replace root=UUID= with '''your''' UUID in yours.


xl info won't work
LABEL 1
  MENU LABEL Linux
  KERNEL grsec
  APPEND initrd=grsec.gz root=UUID=f40e340b-ea49-445b-81c0-4d7104b56662 modules=ext4


Start xecommons:
<pre>
alpine:/boot# /etc/init.d/xencommons start
Starting xenstored...FATAL: Failed to open evtchn device: No such file or directory
</pre>
</pre>
well this will fail but xl info will work anyway
Of course adapt this accordingly to your setup (UUID, modules, etc).


Oh but wait, evtchn device is built in the kernel, so why is there no /dev/xen/evtch file ?
Let's start Xen services:
let's start udev ! ;)
{{Cmd|rc-service udev start}}
 
That's all folks !
 
on going debug:
vi /etc/rc.conf
rc_sys="xen0"
why ?
 
 
Commands recap:
{{Cmd|
{{Cmd|
apk add xen
apk add xen
Line 67: Line 37:
rc-service xencommons start
rc-service xencommons start
}}
}}
If you want "xm" command
xl should work. If you want "xm" command
{{Cmd|rc-service xend start}}
{{Cmd|rc-service xend start}}


Line 107: Line 77:
ifconfig xenbr0 192.168.1.10
ifconfig xenbr0 192.168.1.10
}}
}}
on going debug:
vi /etc/rc.conf
rc_sys="xen0"
why ?

Revision as of 11:50, 2 September 2011

So before anything else verify that you can 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.

Then upgrade your setup to Edge/testing (as of the date of writing, Xen is only available in Edge). Install Xen:

apk add xen

Modify your extlinux.cfg (credits: http://lists.alpinelinux.org/alpine-devel/1406.html) since video card is not working for now, we will use a serial console:

SERIAL 0 115200 
DEFAULT menu.c32
PROMPT 0
MENU TITLE Alpine/Linux Boot Menu
MENU HIDDEN
MENU AUTOBOOT Alpine will be booted automatically in # seconds.
TIMEOUT 50

LABEL 0
  MENU LABEL XEN
  KERNEL mboot.c32
  APPEND /boot/xen-4.gz iommu=1 dom0_mem=1024M dom0_max_vcpus=2 dom0_vcpus_pin  loglvl=all guest_loglvl=all com1=115200,8n1 console=com1  --- /boot/grsec root=UUID=f40e340b-ea49-445b-81c0-4d7104b56662 modules=ext4 console=hvc0 earlyprintk=xen nomodeset --- /boot/grsec.gz

LABEL 1
  MENU LABEL Linux
  KERNEL grsec
  APPEND initrd=grsec.gz root=UUID=f40e340b-ea49-445b-81c0-4d7104b56662 modules=ext4

Of course adapt this accordingly to your setup (UUID, modules, etc).

Let's start Xen services:

apk add xen apk add udev rc-service udev start ; rc-service udev-postmount start rc-service xencommons start

xl should work. If you want "xm" command

rc-service xend start

So let's install services at boot time :

rc-update add udev sysinit rc-update add udev-postmount default rc-update add xencommons rc-update add xend

since we use a serial line, let'a add a serial console prompt, modify your /etc/inittab accordinly:

  1. Put a getty on the serial port
  2. ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100

hvc0::respawn:/sbin/getty -L hvc0 115200 vt100

hvc0 is Xen console output, where we have already redirected the kernel messages. To switch to Xen console, type three time "Ctrl+a"

Now you can configure your guest, but before don't forget to load Xen kernel module:

modprobe xen-gntdev modprobe xen-gntalloc modprobe tun echo "xen-gntdev" >> /etc/modules echo "xen-gntalloc" >> /etc/modules echo "tun" >> /etc/modules

Yes, tun is not a Xen module but is needed to create tap interface in Dom0. Before creating your VM don't forget to create xenbr0 bridge, otherwise Xen will change eth0 into peth0 and eth0 will become a bridge (!):

brctl addbr xenbr0 ifconfig xenbr0 up

So now if you want to plug your "real" network card in your bridge: (192.168.1.10 is eth0 ip)

ifconfig eth0 0.0.0.0 brctl addif xenbr0 eth0 ifconfig xenbr0 192.168.1.10


on going debug: vi /etc/rc.conf rc_sys="xen0" why ?