Este conteúdo não está disponível no idioma selecionado.
20.29. Storage Pool Commands
20.29.1. Searching for a Storage Pool XML Copiar o linkLink copiado para a área de transferência!
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
20.29.2. Finding a storage Pool Copiar o linkLink copiado para a área de transferência!
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
# virsh find-storage-pool-sources-as disk --host myhost.example.com
20.29.3. Listing Storage Pool Information Copiar o linkLink copiado para a área de transferência!
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
20.29.4. Listing the Available Storage Pools Copiar o linkLink copiado para a área de transferência!
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
20.29.5. Refreshing a Storage Pool List Copiar o linkLink copiado para a área de transferência!
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
# virsh pool-refresh vdisk
Pool vdisk refreshed
20.29.6. Creating, Defining, and Starting Storage Pools Copiar o linkLink copiado para a área de transferência!
20.29.6.1. Building a storage pool Copiar o linkLink copiado para a área de transferência!
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
# virsh pool-build vdisk
Pool vdisk built
20.29.6.2. Defining a storage pool from an XML file Copiar o linkLink copiado para a área de transferência!
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
virsh pool-define vdisk.xml
# 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 Copiar o linkLink copiado para a área de transferência!
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
virsh pool-create vdisk.xml
# 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 Copiar o linkLink copiado para a área de transferência!
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--typetype defines the storage pool type. See Section 20.29.4, “Listing the Available Storage Pools” for the types you can use.--source-hosthostname - the source host physical machine for underlying storage--source-pathpath - the location of the underlying storage--source-devpath - the device for the underlying storage--source-namename - the name of the source underlying storage--source-formatformat - the format of the source underlying storage--targetpath - 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
# virsh pool-create-as --name vdisk --type dir --target /mnt
Pool vdisk created
20.29.6.5. Defining a storage pool Copiar o linkLink copiado para a área de transferência!
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--typetype defines the storage pool type. See Section 20.29.4, “Listing the Available Storage Pools” for the types you can use.--source-hosthostname - source host physical machine for underlying storage--source-pathpath - location of the underlying storage--source-devdevicename - device for the underlying storage--source-namesourcename - name of the source underlying storage--source-formatformat - format of the source underlying storage--targettargetname - 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
# virsh pool-define-as --name vdisk --type dir --target /mnt
Pool vdisk defined
20.29.6.6. Starting a storage pool Copiar o linkLink copiado para a área de transferência!
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
# 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 Copiar o linkLink copiado para a área de transferência!
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
# virsh pool-autostart vdisk
Pool vdisk autostarted
20.29.7. Stopping and Deleting Storage Pools Copiar o linkLink copiado para a área de transferência!
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
# 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
# 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
# virsh pool-undefine vdisk
Pool vdisk undefined
20.29.8. Creating an XML Dump File for a Pool Copiar o linkLink copiado para a área de transferência!
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
20.29.9. Editing the Storage Pool's Configuration File Copiar o linkLink copiado para a área de transferência!
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