Virtual openSUSE

Un article de Bulles.

This article summarizes the major steps to install openSUSE 10.3 as DomU using a Debian Etch / Xen 3.1.0 Dom0 as described in this Xen article.

Sommaire

Foreword

Everything is easy once you know how to do it!

Installing an openSUSE virtual machine on top of a Xen 3.1.0 hypervisor with a Debian Etch Dom0 is part of these things!

Here are the few steps that need to be done to get an openSUSE as DomU up and running.

About the installer

The openSUSE installer comes in different flavours. We will use the Network installer.

There are roughly 2 major steps in the install process:

  1. The kernel boots with its initial ramdisk. It will asks for the basic information: language, keyboard, source for packages and network configuration.
  2. The graphical installer is then started to perform the actual installation (partitioning, packages selection, ...).

The installer can be started in three modes:

  • text mode;
  • graphical mode using the Xen virtual frame buffer (vfb). Note that this feature is not compiled by default in Xen (see re-compile Xen article should you need to recompile);
  • graphical mode using the VNC feature of the installer (recommended)

Package repository

There is no need to host local mirror of the packages, as the openSUSE network installer is able to fetch the packages direcly from the Mirrors Released Version. Just select a repository near you!

Kernel

To boot our virtual machine, we need a xenified installation kernel. This kernel is available on any openSUSE mirror.

Code: shell

mkdir /boot/opensuse
Mirror=http://ftp.skynet.be/pub/ftp.opensuse.org/opensuse/distribution/10.3/repo/oss
wget ${Mirror}/boot/i386/vmlinuz-xenpae -O /boot/opensuse/vmlinuz-xenpae-install
wget ${Mirror}/boot/i386/initrd-xenpae  -O /boot/opensuse/initrd-xenpae-install

Note that there is also a non-pae kernel available in the repository.

Disk allocation

We use a logical volume to allocate disk space for the virtual machine:

Code: shell
lvcreate  -L 10240 -n openSUSE vgDomU 

It will be used as Disk Image (xvd) by the virtual machine. This gives more flexibility to the guest than individual partitions (hd), and makes the boot process easier (see below).

Xen DomU Configuration file

This is the minimal configuration file that we will use for this installation:

Fichier: /etc/xen/openSUSE.cfg

#  -*- mode: python; -*-
#============================================================================
# Python configuration setup for 'xm create'.
# This script sets the parameters used when a domain is created using 'xm create'.
# You use a separate script for each domain you want to create, or
# you can set the parameters for the domain on the xm command line.
#============================================================================

#----------------------------------------------------------------------------
# Kernel image file.
bootloader="/usr/bin/pygrub"

# Initial memory allocation (in megabytes) for the new domain.
memory = 512

# A name for your domain. All domains must have different names.
name = "openSUSE"

#----------------------------------------------------------------------------
# Define network interfaces.
vif = [ 'ip=xxx.xxx.xxx.xxx,mac=yy:yy:yy:yy:yy:yy,bridge=xenbr0' ]

#----------------------------------------------------------------------------
# Define the disk devices you want the domain to have access to, and
# what you want them accessible as.
# Each disk entry is of the form phy:UNAME,DEV,MODE
# where UNAME is the device, DEV is the device name the domain will see,
# and MODE is r for read-only, w for read-write.
disk = [ 'phy:/dev/vgDomU/openSUSE,xvda,w' ]

#----------------------------------------------------------------------------
# Define frame buffer device.
# vfb = ["type=vnc,vncunused=1"]
keymap = 'fr-be'

#----------------------------------------------------------------------------
# Configure the behaviour when a domain exits.  There are three 'reasons'
# for a domain to stop: poweroff, reboot, and crash.
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

#============================================================================

The interresting aspect of using pygrub as bootloader instead of specifying a kernel and a ramdisk is that the linux kernel will be taken from the DomU virtual machine and not from the Dom0 host. Obviously we will have to override that during the installation.

Installation

Booting

Before starting YaST, the installer will run Linuxrc to gather all the parameters needed for the install. To make our life easier, we will pass all these parameters from the command line:

Code: shell

LinuxRC="hostip=<DomU ip>/<net> gateway=<gw ip> nameserver=<ns ip> install=${Mirror}"

We need now to choose between the character mode, the vfb and the VNC install.
I recommend to go either for the the character mode or the VNC approach, as the vfb method has some issues with the mouse tracking.

In all scenarios, we override the bootloader directive and specify the installation kernel.
We also need to ask for a destroy at reboot time, otherwise the virtual machine would re-enter the installation procedure when done!

Code: shell

XmCreate="bootloader= \
            kernel=/boot/opensuse/vmlinuz-xenpae-install \
            ramdisk=/boot/opensuse/initrd-xenpae-install \
            on_reboot=destroy"


Text Mode

To start the installation, we create the virtual machine:

Code: shell

xm create -c /etc/xen/openSUSE.cfg \
          ${XmCreate} \
          extra="xencons=tty ${LinuxRC}"

Xen Virtual Frame Buffer

We start the installation with the following incantation:

Code: shell

xm create /etc/xen/openSUSE.cfg \
          ${XmCreate} \
          vfb='type=vnc,vncunused=1' \
          extra="${LinuxRC}"

We start xvncviewer to access the install console -- e.g.:

Code: shell

xvncviewer -via <Dom0> :1

Installer's VNC

The openSUSE installer is smart enough to run a VNC server for network installations.
We create the virtual machine:

Code: shell

xm create /etc/xen/openSUSE.cfg \
          ${XmCreate} \
          extra="vnc=1 vncpassword=<mypass> ${LinuxRC}"
Attention: The password is mandatory and must be at least 8 characters long!

Note that this time, we have to connect directly to the virtual machine and no more to the Dom0:

Code: shell

xvncviewer <DomU>:1

Installing

We are now in the (graphical) installer.
We will be asked for the language, timezone...

When it comes to the Overview, switch to Expert mode and ensure grub is selected as boot loader. This is not the case by default!

Agrandir
Agrandir
Agrandir


Attention: We need to get this right, otherwise we will be in trouble when the system reboots. We need to ensure that we have
  • /boot/vmlinuz-xenpae for the kernel image
  • /boot/initrd-xenpae for the ramdisk


Agrandir

The machine will find the packages and proceed with the installation just like on a bare metal system.


Note that by default the installer will setup a Xen kernel.


Time to look at the openSUSE slide show or grab a coffee!


Reboot

At the end of the installation, the system reboots and you are back at the command prompt of your Dom0 host.

Since we specified the on_reboot=destroy parameter, we need to restart the virtual machine, using this time only the parameters from the configuration file:

Code: shell
xm create /etc/xen/openSUSE.cfg 

After the pygrub boot screen the system will start, ask a couple of post-install questions and we are done!

Welcome to openSUSE 10.3 (i586) - Kernel 2.6.22.5-31-xenpae (tty1).

openSUSE login:

Post Install

We can now connect to your system via the console or using ssh.

Graphical session is available through the Xen Virtual Frame Buffer or directly via VNC if we have enabled VNC remote console in YaST.

Agrandir
Agrandir

Troubleshooting

Installer does not start

If we do not specify the right parameters for Linuxrc, YaST will not be able to start. In case we are performing a VNC install, we are in the dark as no message is available.
When this happens, we can

  • switch to the Xen Virtual Frame Buffer method which will provide an interactive session with Linuxrc;
  • pass xencons=tty as extra parameter to get Linuxrc on the Xen console.

Installed system does not (re)boot

We forgot to install grub or have the wrong configuration...

There are basically two possibilities to boot the system. Once it runs, we just have to go back in YaST and install/configure grub properly

Edit GrUB configuration

If grub is installed but not configured properly, we can easily fix that on the Xen console, just like we would do on a bare metal environment.
The trick is that obviously we need to know how the exact name of the kernel, etc...

Use the installer

The other approach is even more easy: Linuxrc can be used to boot an installed system. We just need to launch the installer without parameters and start the system (in console or vfb mode)!

Agrandir
Agrandir