12.3. Directory-based Storage Pools
virt-manager or the
virsh command line tools.
12.3.1. Creating a Directory-based Storage Pool with virt-manager
Create the local directory
Optional: Create a new directory for the storage poolCreate the directory on the host physical machine for the storage pool. This example uses a directory named /guest virtual machine_images.
# mkdir /guest_images
Set directory ownershipChange the user and group ownership of the directory. The directory must be owned by the root user.
# chown root:root /guest_images
Set directory permissionsChange the file permissions of the directory.
# chmod 700 /guest_images
Verify the changesVerify the permissions were modified. The output shows a correctly configured empty directory.
# ls -la /guest_images total 8 drwx------. 2 root root 4096 May 28 13:57 . dr-xr-xr-x. 26 root root 4096 May 28 13:57 ..
Configure SELinux file contextsConfigure the correct SELinux context for the new directory. Note that the name of the pool and the directory do not have to match. However, when you shutdown the guest virtual machine, libvirt has to set the context back to a default value. The context of the directory determines what this default value is. It is worth explicitly labeling the directory virt_image_t, so that when the guest virtual machine is shutdown, the images get labeled 'virt_image_t' and are thus isolated from other processes running on the host physical machine.
# semanage fcontext -a -t virt_image_t '/guest_images(/.*)?' # restorecon -R /guest_images
Open the storage pool settings
- In the
virt-managergraphical interface, select the host physical machine from the main window.Open the Edit menu and select Connection Details
Figure 12.7. Connection details window
- Click on the Storage tab of the Connection Details window.
Figure 12.8. Storage tab
Create the new storage pool
Add a new pool (part 1)Press the + button (the add pool button). The Add a New Storage Pool wizard appears.Choose a Name for the storage pool. This example uses the name guest_images. Change the Type to
dir: Filesystem Directory.
Figure 12.9. Name the storage poolPress the Forward button to continue.
Add a new pool (part 2)Change the Target Path field. For example, /guest_images.Verify the details and press the Finish button to create the storage pool.
Verify the new storage poolThe new storage pool appears in the storage list on the left after a few seconds. Verify the size is reported as expected, 36.41 GB Free in this example. Verify the State field reports the new storage pool as Active.Select the storage pool. In the Autostart field, confirm that the On Boot check box is checked. This will make sure the storage pool starts whenever the
Figure 12.10. Verify the storage pool informationThe storage pool is now created, close the Connection Details window.