Changes

Jump to: navigation, search
no edit summary
</pre>
To display any existing partitions on the device enter '''p''' to print the partition table. If existing paritions partitions exist be sure to back up any data on these partitions and then delete them using the '''d''' command. Assuming the disk is previosuly previously unpartitioned, or that existing partitions have been removed we can now create the first partition. The remainder of this section covers the creation of one 4Gb 4GB partition for the root filesystem and one 1Gb 1GB partition for swap. These values will differ depending on the size of your physical disk drive and the amount of space you wish to allocate to the root filesystem and swap respectively.
A new partition is created using the '''c''' command. When prompted we specify that this is a ''primary'' partition, it is partition number 1 and is to being begin at cylinder 1 (i.e . the beginning of the physical disk):
<pre>
</pre>
Next, ''fdisk'' asks us for the size of the first partition. This value may be specified in terms of the end cylinder of the partition, or the size in terms either kilobyte or megabyte units. If In the following example we make the partition 4000Mb in size:
<pre>
</pre>
Next we need to create a swap partition for our Xen guest operating system. Once again select '''n''', and create a primary partition, this time as partition 2. Since the remainder of the physical disk drive is to be used for this partition the default values offered for start and end cylinders will suffice:
<pre>
</pre>
With the new partitions created we now need to build a filesystem on partition one 1 and configure partition 2 to serve as swap space for our guest operating system:.
== Creating the a Filesystem on the Xen Guest Root Partition ==
== Configuring the Swap Partition for the Xen Guest System ==
In addition to a root filesystem the second pre-requisite for a Xen guest (domU) system (or any other Linux system for that matter) is swap space. When we partitioned our physical disk drive previously we did so with the intention using using the second partition (''dev/sdb2'') for swap space. In order to configure this partition as swap space we need to run the ''mkswap'' command passing the device name of the partition as a command-line argument:
<pre>
== Mounting the Root Filesystem ==
Now that we have created an empty root filesystem on the ''/dev/sda1'' the next step is populate it with the system files and directories necessary to create a functioning operating system which can be booted from within the Xen environment. Before this can be achieved, however, the partition needs to be mounted. For this we need to use the ''mount'' command in conjunction with a pre-existing directory to act as a ''mount point''. The following commands create a directory named /xen and then mounts mount the filesystem located on ''/dev/sdb1'' at this location:
<pre>
The following steps assume that the root filesystem for the Xen guest has been mounted in /xen as outlined in the previous section.
Having created the mount point and mounted our root filesystem image the next step is to copy the relevant files from the host operating system to guest filesystem image. Execute the following command to copy the required directories and files to the root filesystem (be very careful to substitute the correct destination path if you mounted the filesystem somewhere other than ''/xen''):
<pre>
</pre>
The ''tmp'' directory created above must have read/write access for all users. To ensure this the ''chmod '' command needs to be run:
<pre>
Note that using the default host system initial RAM disk can cause problems on some Linux distributions. If the system fails to boot it may be necessary to generate an initial RAM disk without SCSI modules. Details of this and solutions to other Xen problems can be found at [http://www.linuxtopia.org/ProblemSolutions/index.html Linuxtopia.org]
Next, the amount of memory to be allocated to the guest system is defined using the ''memory = '' directive. The following assigned assigns 512Mb to the guest:
<pre>
</pre>
Amount The optimal amount to allocate will depend on both the available memory on the host machine and the amount of space required by the guest system.
Each guest domain needs to have a name by which it can be referenced when using the Xen management tools. This is assigned using ''name = '':
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 disk partitions. The following shows a typical file from a CentOS, Red Hat Enterprise Linux or Fedora host operating system:
<pre>
== Booting the Guest OS ==
Now all that remains is to boot the guest operating system. before 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 Before booting the guest system it is important to first unmount the guest root filesystem:
<pre>
</pre>
The '''-c''' flag above instructs Xen to attach a console to the guest system so that we see output as the system boots. the The following output displays the initial phases of a successful boot:
<pre>
1,798
edits

Navigation menu