Download Chapter 3. The Xen Hypervisor

Transcript
[root@dom0]# vgcreate xen_vg /dev/sda9
Volume group "xen_vg" successfully created
[root@dom0]#
Note
When creating a volume group with multiple physical volumes, you simply add more devices to the
vgcreate command line. For example, you could expand Listing 8.2 to be vgcreate xen_vg /dev/sda9
/dev/sda10 and that would make the xen_vg volume group be composed of both /dev/sda9 and
/dev/sda10. Also, notice that /dev/sda10 device would need to have been initialized with pvcreate.
After a VG has been created, LVs can be created from it. Recall that LVs are what actually get mounted and
used to store a Xen guest's system image. The command used to create an LV is lvcreate, or logical volume
create. The lvcreate command creates a new LV by allocating logical extents from the free logical extent pool
of the VG passed as arguments. Listing 8.3 shows the command to create a 4GB LV. The -L option is used to
specify the size of the LV, and the -n option is used to specify the name of the LV. The command in the example
creates a 4GB LV with the name guest_partition_lvm in the VG xen_vg.
Listing 8.3. Using lvcreate to Create a Logical Volume
[root@dom0]# lvcreate -L 4G -n guest_partition_lvm xen_vg
Logical volume "guest_partition_lvm" created
[root@dom0]#
The lvcreate command in Listing 8.3 creates a new entry in the /dev/<volume_group_name>/ directory for the
new LV. In this case, it is represented by the entry /dev/xen_vg/guest_partition_lvm. A new entry should
also be available in /dev/mapper, as the entry in /dev/xen_vg/guest_partition_lvm is typically a symbolic
link to a /dev/mapper/xen_vg* device node. The device, /dev/xen_vg/guest_partition_lvm, can now be used
like a physical partition. Listing 8.4 shows an example of how to format, mount, and populate the drive, as was
shown in Chapter 5, with a blank partition. In this example, a compressed file is extracted, but another
population method could be used just as easily. Population methods were discussed in Chapter 7, "Populating
Guest Images."
Listing 8.4. Populating the Logical Volume by Extracting Compressed File System into It