20.29. Storage Pool Commands
20.29.1. Searching for a Storage Pool XML
virsh find-storage-pool-sources type
command displays the XML describing all storage pools of a given source that could be found. Types include: netfs, disk, dir, fs, iscsi, logical, and gluster. Note that all of the types correspond to the storage back-end drivers and there are more types available (see the man page for more details). You can also further restrict the query for pools by providing an template source XML file using the --srcSpec option.
Example 20.71. How to list the XML setting of available storage pools
# virsh find-storage-pool-sources logical
<sources>
<source>
<device path='/dev/mapper/luks-7a6bfc59-e7ed-4666-a2ed-6dcbff287149'/>
<name>RHEL_dhcp-2-157</name>
<format type='lvm2'/>
</source>
</sources>
20.29.2. Finding a storage Pool
virsh find-storage-pool-sources-as type
command finds potential storage pool sources, given a specific type. Types include: netfs, disk, dir, fs, iscsi, logical, and gluster. Note that all of the types correspond to the storage back-end drivers and there are more types available (see the man page for more details). The command also takes the optional arguments host, port, and initiator. Each of these options will dictate what gets queried.
Example 20.72. How to find potential storage pool sources
virsh hostname
first:
# virsh find-storage-pool-sources-as disk
--host myhost.example.com
20.29.3. Listing Storage Pool Information
virsh pool-info pool
command lists the basic information about the specified storage pool object. This command requires the name or UUID of the storage pool. To retrieve this information, use the pool-list
command.
Example 20.73. How to retrieve information on a storage pool
# virsh pool-info vdisk
Name: vdisk
UUID:
State: running
Persistent: yes
Autostart: no
Capacity: 125 GB
Allocation: 0.00
Available: 125 GB
20.29.4. Listing the Available Storage Pools
virsh pool-list
command lists all storage pool objects known to libvirt. By default, only active pools are listed; but using the --inactive
argument lists just the inactive pools, and using the --all
argument lists all of the storage pools. This command takes the following optional arguments, which filter the search results:
--inactive
- lists the inactive storage pools--all
- lists both active and inactive storage pools--persistent
- lists the persistent storage pools--transient
- lists the transient storage pools--autostart
- lists the storage pools with autostart enabled--no-autostart
- lists the storage pools with autostart disabled--type type
- lists the pools that are only of the specified type--details
- lists the extended details for the storage pools
--persistent
restricts the list to persistent pools, --transient
restricts the list to transient pools, --autostart
restricts the list to autostarting pools and finally --no-autostart
restricts the list to the storage pools that have autostarting disabled.
dir
, fs
, netfs
, logical
, disk
, iscsi
, scsi
, mpath
, rbd
, sheepdog
, and gluster
.
--details
option instructs virsh
to additionally display pool persistence and capacity related information where available.
Note
Example 20.74. How to list all storage pools
# virsh pool-list --all
Name State Autostart
-----------------------------------------
default active yes
vdisk active no
20.29.5. Refreshing a Storage Pool List
virsh pool-refresh pool
command refreshes the list of storage volumes contained in storage pool.
Example 20.75. How to refresh the list of the storage volumes in a storage pool
# virsh pool-refresh vdisk
Pool vdisk refreshed
20.29.6. Creating, Defining, and Starting Storage Pools
20.29.6.1. Building a storage pool
virsh pool-build pool
command builds a storage pool using the name given in the command. The optional arguments --overwrite
and --no-overwrite
can only be used for an FS storage pool or with a disk or logical type based storage pool. Note that if [--overwrite] or [--no-overwrite] are not provided and the pool used is FS, it is assumed that the type is actually directory-based. In addition to the pool name, the storage pool UUID may be used as well.
--no-overwrite
is specified, it probes to determine if a file system already exists on the target device, returning an error if it exists, or using mkfs
to format the target device if it does not. If --overwrite
is specified, then the mkfs
command is executed and any existing data on the target device is overwritten.
Example 20.76. How to build a storage pool
# virsh pool-build vdisk
Pool vdisk built
20.29.6.2. Defining a storage pool from an XML file
virsh pool-define file
command creates, but does not start, a storage pool object from the XML file.
Example 20.77. How to define a storage pool from an XML file
<pool type="dir"> <name>vdisk</name> <target> <path>/var/lib/libvirt/images</path> </target> </pool>
# virsh pool-define vdisk.xml
Pool vdisk defined
virsh pool-list --all
command as shown in Example 20.74, “How to list all storage pools”. When you run the command, however, the status will show as inactive as the pool has not been started. For directions on starting the storage pool see Example 20.81, “How to start a storage pool”.
20.29.6.3. Creating storage pools
virsh pool-create file
command creates and starts a storage pool from its associated XML file.
Example 20.78. How to create a storage pool from an XML file
<pool type="dir"> <name>vdisk</name> <target> <path>/var/lib/libvirt/images</path> </target> </pool>
# virsh pool-create vdisk.xml
Pool vdisk created
virsh pool-list --all
command as shown in Example 20.74, “How to list all storage pools”. When you run the command, however, the status will show as inactive as the pool has not been started. For directions on starting the storage pool see Example 20.81, “How to start a storage pool”.
20.29.6.4. Creating storage pools
virsh pool-create-as name
command creates and starts a pool object name from the raw parameters given. This command takes the following options:
--print-xml
- displays the contents of the XML file, but does not define or create a storage pool from it--type
type defines the storage pool type. See Section 20.29.4, “Listing the Available Storage Pools” for the types you can use.--source-host
hostname - the source host physical machine for underlying storage--source-path
path - the location of the underlying storage--source-dev
path - the device for the underlying storage--source-name
name - the name of the source underlying storage--source-format
format - the format of the source underlying storage--target
path - the target for the underlying storage
Example 20.79. How to create and start a storage pool
/mnt
directory:
# virsh pool-create-as --name vdisk --type dir
--target /mnt
Pool vdisk created
20.29.6.5. Defining a storage pool
virsh pool-define-as <name>
command creates, but does not start, a pool object name from the raw parameters given. This command accepts the following options:
--print-xml
- displays the contents of the XML file, but does not define or create a storage pool from it--type
type defines the storage pool type. See Section 20.29.4, “Listing the Available Storage Pools” for the types you can use.--source-host
hostname - source host physical machine for underlying storage--source-path
path - location of the underlying storage--source-dev
devicename - device for the underlying storage--source-name
sourcename - name of the source underlying storage--source-format
format - format of the source underlying storage--target
targetname - target for the underlying storage
--print-xml
is specified, then it prints the XML of the pool object without creating or defining the pool. Otherwise, the pool requires a specified type to be built. For all storage pool commands which require a type, the pool types must be separated by comma. The valid pool types include: dir
, fs
, netfs
, logical
, disk
, iscsi
, scsi
, mpath
, rbd
, sheepdog
, and gluster
.
Example 20.80. How to define a storage pool
virsh pool-start
command to activate the storage pool:
# virsh pool-define-as --name vdisk --type dir
--target /mnt
Pool vdisk defined
20.29.6.6. Starting a storage pool
virsh pool-start pool
command starts the specified storage pool, which was previously defined but inactive. This command may also use the UUID for the storage pool as well as the pool's name.
Example 20.81. How to start a storage pool
# virsh pool-start vdisk
Pool vdisk started
virsh pool-list --all
command and confirm that the status is active, as shown in Example 20.74, “How to list all storage pools”.
20.29.6.7. Auto-starting a storage pool
virsh pool-autostart pool
command enables a storage pool to automatically start at boot. This command requires the pool name or UUID. To disable the pool-autostart
command use the --disable
argument in the command.
Example 20.82. How to autostart a storage pool
# virsh pool-autostart vdisk
Pool vdisk autostarted
20.29.7. Stopping and Deleting Storage Pools
virsh pool-destroy pool
command stops a storage pool. Once stopped, libvirt will no longer manage the pool but the raw data contained in the pool is not changed, and can be later recovered with the pool-create
command.
Example 20.83. How to stop a storage pool
# virsh pool-destroy vdisk
Pool vdisk destroyed
virsh pool-delete pool
command destroys the resources used by the specified storage pool. It is important to note that this operation is non-recoverable and non-reversible. However, the pool structure will still exist after this command, ready to accept the creation of new storage volumes.
Example 20.84. How to delete a storage pool
# virsh pool-delete vdisk
Pool vdisk deleted
virsh pool-undefine pool
command undefines the configuration for an inactive pool.
Example 20.85. How to undefine a storage pool
# virsh pool-undefine vdisk
Pool vdisk undefined
20.29.8. Creating an XML Dump File for a Pool
virsh pool-dumpxml pool
command returns the XML information about the specified storage pool object. Using the option --inactive
dumps the configuration that will be used on next start of the pool instead of the current pool configuration.
Example 20.86. How to retrieve a storage pool's configuration settings
# virsh pool-dumpxml vdisk
<pool type="dir">
<name>vdisk</name>
<target>
<path>/var/lib/libvirt/images</path>
</target>
</pool>
20.29.9. Editing the Storage Pool's Configuration File
pool-edit pool
command opens the specified storage pool's XML configuration file for editing.
Example 20.87. How to edit a storage pool's configuration settings
# virsh pool-edit vdisk
<pool type="dir">
<name>vdisk</name>
<target>
<path>/var/lib/libvirt/images</path>
</target>
</pool>