Building a Xen Guest Root Filesystem using yum and rpm
Previous | Table of Contents | Next |
Building a Xen Virtual Guest Filesystem using Logical Volume Management (LVM) | Building a Debian or Ubuntu Xen Guest Root Filesystem using debootstrap |
In the preceding chapters of Xen Virtualization Essentials we looked at a variety of ways of creating the root filesystem for a Xen guest domain (domainU) through the cloning of the root filesystem host operating system.
Instead of cloning the host root filesystem, this chapter will focus on the creation of a Xen guest root filesystem from Linux distribution repositories using the yum and rpm tools. It is intended that the following steps works with any Linux distribution which uses yum and rpm for package management (including Fedora, CentOS and Red Hat).
An Overview of Repository Based Installation
Linux distributions are essentially a collection of many different software packages combined with a Linux kernel. These packages are stored in repositories which may be accessed online to install and update Linux distributions. The key tools for performing these tasks on systems such as Red Hat Linux, Fedora and CentOS are called yum and rpm. Other Linux distributions (such as Debian and Ubuntu use a different package management system which will be covered in where).
In terms of creating a Xen guest domain the yum and rpm tools can be used to install the base root filesystem on a blank disk image or partition by downloading the necessary packages from an online repository. This contrasts with the approach described in previous chapters whereby the the root filesystem is simply copied from the host operating system
Preparing to Create a Xen Guest Root Filesystem from Repositories
A Xen guest domain needs, at a minimum, a Xen configuration file, a root filesystem, swap space, a Linux kernel and an initial RAM Disk. In previous chapters we looked at a number of approaches to providing swap space and root filesystem including the use of disk images, disk partitions and logical volume management. The remainder of this chapter assumes that suitable storage has been configured to hold the root filesystem, that swap space has been configured and a suitable Xen configuration file exists. If you have not yet configured swap space and a suitable filesystem for the root files refer to the following chapters (omitting the sections on cloning the host root filesystem) before proceeding with this chapter:
Beginning the Installation
The first step in installing the base packages onto the root filesystem for the Xen guest domain is to mount the target filesystem so that it is accessible to the host system. The following steps assume that this filesystem has been mounted in /xen.
Initially, a number of directories and files need to be created in the filesystem in order for yum and rpm to function:
mkdir -p /xen/var/lib/rpm mkdir -p /xen/var/log touch /xen/var/log/yum.log
Next the RPM database on the guest filesystem needs to be initialized:
rpm --root /xen --initdb
Next the general release description RPM package for the Linux distribution needs to be downloaded and installed. To obtain this file go to the web site for your chosen distribution and look on the download mirrors for the file containing -release- in its name.
A recent CentOS 5 file is located at:
http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-5-1.0.el5.centos.1.i386.rpm
Alternatively, a Fedora 8 RPM can be found at:
Once the package has been downloaded install it as follows:
rpm -ihv --nodeps --root /xen centos-release-5-1.0.el5.centos.1.i386.rpm
Finally, use yum to install the full set of base packages for the operating system. The following command will download all required packages from the repository and install it:
yum --installroot=/xen -y groupinstall Base
This process involves the download and installation of over 300 packages so may take some time to complete. Upon completion copy the appropriate directories from the /lib/modules directory of the host system to /xen/lib/modules. For example:
cp -r /lib/modules/2.6.18-53.1.14.el5xen /xen/lib/modules
Configuring the Guest System using chroot
The next step is to configure the guest system so that it is ready to boot. This is achieved using chroot. For example:
chroot /xen
This essentially creates a new shell for us to work on where the root (/) directory is changed to point to /xen. From this shell prompt create a new /etc/fstab which matches the device settings in the Xen configuration file created previously. Also take this opportunity to set up the root password and add any additional users that may be needed.
Booting the Xen Guest System
Now all that remains is to boot the guest operating system. Before issuing the command to do so it is important to note that the system may not boot for a number of reasons.
If the system fails to boot be sure to read the Xen Guest Boot Problems section at the end of this chapter.
before booting the guest system it is important to first unmount the guest root filesystem:
umount /xen
With the set up and configuration complete we are now ready to start up the guest OS. This is achieved using the xm create command:
xm create XenGuest1.cfg -c
The -c flag above instructs Xen to attach a console to the guest system so that we see output as the system boots.
Xen Guest Boot Problems
A number of different problems can occur during the boot process of the Xen guest system.
Solutions to some common problems are:
- Ubuntu Xen Guest (DomU) Hangs after EXT3-fs: mounted filesystem with ordered data mode message
- Ubuntu Xen System Boot Hangs After Setting System Clock Message
- Xen domainU fails to boot with a "Xen Guest OS Fails to Boot with Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)" error message
- A Xen Guest OS fails to boot with a "switchroot: mount failed: No such file or directory error message" error message.
- Xen CentOS/Fedora/Red Hat Guest OS Hangs During Boot
- Xen domainU Boot Fails with Invalid kernel / ERROR: Not a Xen-ELF image Message
Previous | Table of Contents | Next |
Building a Xen Virtual Guest Filesystem using Logical Volume Management (LVM) | Building a Debian or Ubuntu Xen Guest Root Filesystem using debootstrap |