Changes

Jump to: navigation, search
no edit summary
In earlier chapters of this book we looked at populating the root filesystem of a Xen domU guest system by copying the root filesystem from the host operating system. While this is a workable approach it has the draw back drawback that it provides little or no control over which packages get installed in the guest system. It is also possible that the operating system required to run in the guest domain is a different Linux distribution to that running on the host.
A cleaner way to install the operating system files on a guest root filesystem on Debian or Ubuntu is to use the ''debrootstrap'' tool to install the packages from the distribution repositories. In this chapter we will work step by step through the process of creating a bootable Ubuntu Xen guest system using debootstrab to populate the root filesystem.
== Creating the Xen Guest Root Filesystem ==
For the purposes of this chapter the root filesystem for the guest domain will reside in a disk image file (as opposed to a physical partition of or logical volume). The first step therefore is to create the image file:
<pre>
</pre>
The above command creates a 3Gb image file to which will contain the root filesystem. Having generated the image the next step is to create a filesystem on it. This is achieved by running the ''mkfs'' command. For example:
<pre>
</pre>
Below is the typical output from an ''mkfs'' execution. Note that because we are building a filesystem on an image file mkfes , ''mkfs'' prompts us to verify that this is what we intended. When so prompted, simply enter '''y''' to proceed:
<pre>
== Creating Swap for the Xen Guest Domain ==
The next key requirement for a Xen guest domain is swap space. Once again for the purposes of this chapter we will use a disk image file for this purpose. The following command creates a 1Gb disk image file for swap:
<pre>
</pre>
Having created the an image file to act as the swap device the next task is to format the image as swap space using the ''mkswap'' command as follows:
<pre>
</pre>
Now that the root filesytem filesystem disk image is mounted the base Ubuntu operating system can be be installed using ''debootstrap''. The tool takes two command-line arguments, the release of Ubuntu or Debian to be installed (for example ''gutsy'' or ''edgy'') following followed by the location of the filesystem into which the packages are to be installed. For example:
<pre>
</pre>
The following shows an excerpt of the output from a succession debootstrab successful ''debootstrap'' session:
<pre>
The debootstrap tool will now download and install the base packages necessary for the Xen Guest system to boot. Note that this may take some time to complete.
Once the installation is complete the appropriate modules need to be copied from the host operating system to the guest root fileystemfilesystem:
<pre>
It is important to keep in mind that at this point in the process we have copied all of the system files from our host operating system onto the disk image for our guest operating system. It is vital at this point, therefore, that we change any system configuration files to meet the requirements of our guest domain. Typical settings that will need to be changed are:
* ''/etc/fstab'' - This file contains the mappings between physical and network devices and filesystems. This will need to be changed to reflect the disk configuiration configuration used by the guest system.
* ''/etc/passwd'' - Contains password information for all user and application accounts on the host system. It is important to remove the entries for any accounts which will not be required on the guest system.
* ''/etc/group'' - This file contains information about user and application groups and, as with the passd passwd file, should be modified to remove any groups not required in the guest system.
* ''/etc/hosts'' - Contains information about the local host and other hosts on the network. Be sure to change the name of the local host to match the name to be used by the guest operating system.
== Modifying /etc/fstab for the Guest System ==
In the preceding section we talked about the system configuration files which may need to be modified in the root filesystem of the guest operating system. One file which needs particular attention is the ''/etc/fstab'' file. The file currently present in the guest root filesystem is a direct replica of the file used by the host operating system. It is almost certain that this file will not be configured to work with the disk represented by our root filesystem and swap images. The following shows a typical empty ''/etc/fstab'' file from an Ubuntu system immediately after it has been created as part of the debootstrap process:
<pre>
1,798
edits

Navigation menu