Show Table of Contents
12.3.3. Creating a Directory-based Storage Pool with virsh
Create the storage pool definition
Use thevirsh pool-define-ascommand to define a new storage pool. There are two options required for creating directory-based storage pools:- The
nameof the storage pool.This example uses the name guest_images. All furthervirshcommands used in this example use this name. - The
pathto a file system directory for storing guest image files. If this directory does not exist,virshwill create it.This example uses the /guest_images directory.
# virsh pool-define-as guest_images dir - - - - "/guest_images" Pool guest_images defined
Verify the storage pool is listed
Verify the storage pool object is created correctly and the state reports it asinactive.# virsh pool-list --all Name State Autostart ----------------------------------------- default active yes guest_images inactive no
Create the local directory
Use thevirsh pool-buildcommand to build the directory-based storage pool for the directory guest_images (for example), as shown:# virsh pool-build guest_images Pool guest_images built # ls -la /guest_images total 8 drwx------. 2 root root 4096 May 30 02:44 . dr-xr-xr-x. 26 root root 4096 May 30 02:44 .. # virsh pool-list --all Name State Autostart ----------------------------------------- default active yes guest_images inactive no
Start the storage pool
Use the virsh commandpool-startto enable a directory storage pool, thereby allowing allowing volumes of the pool to be used as guest disk images.# virsh pool-start guest_images Pool guest_images started # virsh pool-list --all Name State Autostart ----------------------------------------- default active yes guest_images active no
Turn on autostart
Turn onautostartfor the storage pool. Autostart configures thelibvirtdservice to start the storage pool when the service starts.# virsh pool-autostart guest_images Pool guest_images marked as autostarted # virsh pool-list --all Name State Autostart ----------------------------------------- default active yes guest_images active yes
Verify the storage pool configuration
Verify the storage pool was created correctly, the size is reported correctly, and the state is reported asrunning. If you want the pool to be accessible even if the guest virtual machine is not running, make sure thatPersistentis reported asyes. If you want the pool to start automatically when the service starts, make sure thatAutostartis reported asyes.# virsh pool-info guest_images Name: guest_images UUID: 779081bf-7a82-107b-2874-a19a9c51d24c State: running Persistent: yes Autostart: yes Capacity: 49.22 GB Allocation: 12.80 GB Available: 36.41 GB # ls -la /guest_images total 8 drwx------. 2 root root 4096 May 30 02:44 . dr-xr-xr-x. 26 root root 4096 May 30 02:44 .. #
A directory-based storage pool is now available.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.