Questo contenuto non è disponibile nella lingua selezionata.
Chapter 12. Storage Pools
Example 12.1. NFS storage pool
/path/to/share should be mounted on /vm_data). When the pool is started, libvirt mounts the share on the specified directory, just as if the system administrator logged in and executed mount nfs.example.com:/path/to/share /vmdata. If the pool is configured to autostart, libvirt ensures that the NFS share is mounted on the directory specified when libvirt is started.
Note
Warning
12.1. Disk-based Storage Pools Copia collegamentoCollegamento copiato negli appunti!
Warning
/dev/sdb). Use partitions (for example, /dev/sdb1) or LVM volumes.
12.1.1. Creating a Disk-based Storage Pool Using virsh Copia collegamentoCollegamento copiato negli appunti!
virsh command.
Warning
Create a GPT disk label on the disk
The disk must be relabeled with a GUID Partition Table (GPT) disk label. GPT disk labels allow for creating a large numbers of partitions, up to 128 partitions, on each device. GPT partition tables can store partition data for far more partitions than the MS-DOS partition table.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the storage pool configuration file
Create a temporary XML text file containing the storage pool information required for the new device.The file must be in the format shown below, and contain the following fields:- <name>guest_images_disk</name>
- The
nameparameter determines the name of the storage pool. This example uses the name guest_images_disk in the example below. - <device path='/dev/sdb'/>
- The
deviceparameter with thepathattribute specifies the device path of the storage device. This example uses the device /dev/sdb. - <target> <path>/dev</path></target>
- The file system
targetparameter with thepathsub-parameter determines the location on the host physical machine file system to attach volumes created with this storage pool.For example, sdb1, sdb2, sdb3. Using /dev/, as in the example below, means volumes created from this storage pool can be accessed as /dev/sdb1, /dev/sdb2, /dev/sdb3. - <format type='gpt'/>
- The
formatparameter specifies the partition table type. This example uses the gpt in the example below, to match the GPT disk label type created in the previous step.
Create the XML file for the storage pool device with a text editor.Example 12.2. Disk based storage device storage pool
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Attach the device
Add the storage pool definition using thevirsh pool-definecommand with the XML configuration file created in the previous step.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Start the storage pool
Start the storage pool with thevirsh pool-startcommand. Verify the pool is started with thevirsh pool-list --allcommand.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Turn on autostart
Turn onautostartfor the storage pool. Autostart configures thelibvirtdservice to start the storage pool when the service starts.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the storage pool configuration
Verify the storage pool was created correctly, the sizes reported correctly, and the state reports asrunning.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Remove the temporary configuration file
Remove the temporary storage pool XML configuration file if it is not needed.rm ~/guest_images_disk.xml
# rm ~/guest_images_disk.xmlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
12.1.2. Deleting a Storage Pool Using virsh Copia collegamentoCollegamento copiato negli appunti!
- To avoid any issues with other guest virtual machines using the same pool, it is best to stop the storage pool and release any resources in use by it.
virsh pool-destroy guest_images_disk
# virsh pool-destroy guest_images_diskCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Remove the storage pool's definition
virsh pool-undefine guest_images_disk
# virsh pool-undefine guest_images_diskCopy to Clipboard Copied! Toggle word wrap Toggle overflow