Chapitre 14. Managing storage for virtual machines
A virtual machine (VM), just like a physical machine, requires storage for data, program, and system files. As a VM administrator, you can assign physical or network-based storage to your VMs as virtual storage. You can also modify how the storage is presented to a VM regardless of the underlying hardware.
The following sections provide information about the different types of VM storage, how they work, and how you can manage them using the CLI or the web console.
14.1. Understanding virtual machine storage
If you are new to virtual machine (VM) storage, or are unsure about how it works, the following sections provide a general overview about the various components of VM storage, how it works, management basics, and the supported solutions provided by Red Hat.
You can find information about:
14.1.1. Introduction to storage pools
A storage pool is a file, directory, or storage device, managed by
libvirt to provide storage for virtual machines (VMs). You can divide storage pools into storage volumes, which store VM images or are attached to VMs as additional storage.
Furthermore, multiple VMs can share the same storage pool, allowing for better allocation of storage resources.
Storage pools can be persistent or transient:
A persistent storage pool survives a system restart of the host machine. You can use the
virsh pool-defineto create a persistent storage pool.
A transient storage pool only exists until the host reboots. You can use the
virsh pool-createcommand to create a transient storage pool.
- A persistent storage pool survives a system restart of the host machine. You can use the
Storage pool storage types
Storage pools can be either local or network-based (shared):
Local storage pools
Local storage pools are attached directly to the host server. They include local directories, directly attached disks, physical partitions, and Logical Volume Management (LVM) volume groups on local devices.
Local storage pools are useful for development, testing, and small deployments that do not require migration or have a large number of VMs.
Networked (shared) storage pools
Networked storage pools include storage devices shared over a network using standard protocols.
14.1.2. Introduction to storage volumes
Storage pools are divided into
storage volumes. Storage volumes are abstractions of physical partitions, LVM logical volumes, file-based disk images, and other storage types handled by
libvirt. Storage volumes are presented to VMs as local storage devices, such as disks, regardless of the underlying hardware.
On the host machine, a storage volume is referred to by its name and an identifier for the storage pool from which it derives. On the
virsh command line, this takes the form
--pool storage_pool volume_name.
For example, to display information about a volume named firstimage in the guest_images pool.
# virsh vol-info --pool guest_images firstimage Name: firstimage Type: block Capacity: 20.00 GB Allocation: 20.00 GB
14.1.3. Storage management using libvirt
libvirt remote protocol, you can manage all aspects of VM storage. These operations can also be performed on a remote host. Consequently, a management application that uses
libvirt, such as the RHEL web console, can be used to perform all the required tasks of configuring the storage of a VM.
You can use the
libvirt API to query the list of volumes in a storage pool or to get information regarding the capacity, allocation, and available storage in that storage pool. For storage pools that support it, you can also use the
libvirt API to create, clone, resize, and delete storage volumes. Furthermore, you can use the
libvirt API to upload data to storage volumes, download data from storage volumes, or wipe data from storage volumes.
14.1.4. Overview of storage management
To illustrate the available options for managing storage, the following example talks about a sample NFS server that uses
mount -t nfs nfs.example.com:/path/to/share /path/to/data.
As a storage administrator:
You can define an NFS storage pool on the virtualization host to describe the exported server path and the client target path. Consequently,
libvirtcan mount the storage either automatically when
libvirtis started or as needed while
- You can simply add the storage pool and storage volume to a VM by name. You do not need to add the target path to the volume. Therefore, even if the target client path changes, it does not affect the VM.
You can configure storage pools to autostart. When you do so,
libvirtautomatically mounts the NFS shared disk on the directory which is specified when
libvirtmounts the share on the specified directory, similar to the command
mount nfs.example.com:/path/to/share /vmdata.
You can query the storage volume paths using the
libvirtAPI. These storage volumes are basically the files present in the NFS shared disk. You can then copy these paths into the section of a VM’s XML definition that describes the source storage for the VM’s block devices.
In the case of NFS, you can use an application that uses the
libvirtAPI to create and delete storage volumes in the storage pool (files in the NFS share) up to the limit of the size of the pool (the storage capacity of the share).
Note that, not all storage pool types support creating and deleting volumes.
You can stop a storage pool when no longer required. Stopping a storage pool (
pool-destroy) undoes the start operation, in this case, unmounting the NFS share. The data on the share is not modified by the destroy operation, despite what the name of the command suggests. For more information, see
14.1.5. Supported and unsupported storage pool types
Supported storage pool types
The following is a list of storage pool types supported by RHEL:
- Directory-based storage pools
- Disk-based storage pools
- Partition-based storage pools
- iSCSI-based storage pools
- LVM-based storage pools
- NFS-based storage pools
- SCSI-based storage pools with vHBA devices
- Multipath-based storage pools
- RBD-based storage pools
Unsupported storage pool types
The following is a list of
libvirt storage pool types not supported by RHEL:
- Sheepdog-based storage pools
- Vstorage-based storage pools
- ZFS-based storage pools
- iSCSI-direct storage pools
- GlusterFS storage pools