Difference between revisions of "Creating and Booting a Xen Guest domainU using an NFS Mounted Root Filesystem"
(New page: In this chapter of Xen Virtualization Essentials we will be looking at creating a root filesystem for a Xen domainU system on an NFS mounted filesystem. In many ways this is little dif...)
m (Creating and Booting from an NFS based Xen Root Filesystem moved to Creating and Booting a Xen Guest domainU using an NFS Mounted Root Filesystem)
Revision as of 19:06, 18 April 2008
In this chapter of Xen Virtualization Essentials we will be looking at creating a root filesystem for a Xen domainU system on an NFS mounted filesystem. In many ways this is little different from other techniques covered in preceding chapters in that similar techniques can be used to populate the root filesystem. The difference comes at the point that the domainU system is booted. Instead of running on a local filesystem, the root filesystem for our domainU system is instead located on a remote server. This is particularly useful when performing live migrations of running Xen based systems from one machine to another.
Kernel Requirements for NFS based Root Filesystems
There is one key requirement for booting a Xen domU with an NFS mounted root filesystem. By default, most Linux kernels are not configured to support NFS mounted root filesystems. It is essential, therefore, that a custom kernel with CONFIG_ROOT_NFS support enabled be built and referenced in the kernel= field of the Xen config file for the guest domain.
Populating the Root Filesystem
Once a custom Xen kernel with NFS root filesystem is available the next step is to populate a suitable disk partition with a root filesystem. In this tutorial we will assume that this partition is mounted at /xen. A number of options for creating the root fielsystem are available and have been covered in preceding chapters. Recommended chapters to read for this are as follows:
Exporting and Mounting the Xen Guest Root Filesystem
Before exporting the filesystem and mounting it on the remote system it is essential that NFS services be running on both systems. The specific steps to achieve this differ between Linux distributions but an internet search will provide a vast number of How To tips on how to achieve this for your distribution.
With the root filesystem populated on the NFS server and NFS services running, the next step is to export it so that it can be mounted on the remote system where we plan to boot our Xen guest domain. This is achieved by adding an entry to the /etc/exports file on the server. For example, to export the /xen filesystem such that it can be mounted over NFS by a system with an IP address of 192.168.2.11 we would add the following line to /etc/exports on the system acting as the NFS server:
The rw indicates that the system with the specified IP address is able to read and write to the NFS mounted filesystem when it mounted. The no_root_squash directive is used to allow the root user of the Xen domU to write to the NFS mounted root filesystem, (if this is not set they the root user will not have access to the guest system).
Once the /etc/exports file has been updated the exportfs command can be run to update the table of exported NFS filesystems. This command needs to be run as root using the -a flag:
su - exportfs -a
In order to verify the filesystem is correctly exported simply run exportfs without the -v command-line option:
exportfs -v /xen 192.168.2.11(rw,async,wdelay,no_root_squash,no_subtree_check)
Mounting the Xen Guest Root Filesystem
At this point we move to the remote system on which the Xen domU system is to be booted (in other words the Xen hosts system). In our example this is the system with the IP address specified in /etc/exports (i.e 192.168.2.11). For the purposes of this chapter we shall also be assuming the server on which we configured and exported root filesystem has an IP address of 192.168.2.4. In order to match the location of the root filesystem on the server we will created a /xen mount point on the current system:
su - mkdir /xen
With the mount point created all that remains in this phase of the configuration is to mount /xen on 192.168.2.4 using NFS so that it is available at /xen on the host (192.168.2.11):
mount 192.168.2.4:/xen /xen
A directory listing of /xen should reveal the root filesystem ready for use by our Xen documanU system.