12.2.3. Creating a Partition-based Storage Pool Using virsh
virsh command.
Warning
/dev/sdb). Guests should not be given write access to whole disks or block devices. Only use this method to assign partitions (for example, /dev/sdb1) to storage pools.
Procedure 12.2. Creating pre-formatted block device storage pools using virsh
Create the storage pool definition
Use the virshpool-define-ascommand to create a new storage pool definition. There are three options that must be provided to define a pre-formatted disk as a storage pool:- Partition name
- The
nameparameter determines the name of the storage pool. This example uses the name guest_images_fs in the example below. - device
- The
deviceparameter with thepathattribute specifies the device path of the storage device. This example uses the partition /dev/sdc1. - mountpoint
- The
mountpointon the local file system where the formatted device will be mounted. If the mount point directory does not exist, thevirshcommand can create the directory.The directory /guest_images is used in this example.
# virsh pool-define-as guest_images_fs fs - - /dev/sdc1 - "/guest_images" Pool guest_images_fs defined
The new pool and mount points are now created.Verify the new pool
List the present storage pools.# virsh pool-list --all Name State Autostart ----------------------------------------- default active yes guest_images_fs inactive no
Create the mount point
Use thevirsh pool-buildcommand to create a mount point for a pre-formatted file system storage pool.# virsh pool-build guest_images_fs Pool guest_images_fs built # ls -la /guest_images total 8 drwx------. 2 root root 4096 May 31 19:38 . dr-xr-xr-x. 25 root root 4096 May 31 19:38 .. # virsh pool-list --all Name State Autostart ----------------------------------------- default active yes guest_images_fs inactive no
Start the storage pool
Use thevirsh pool-startcommand to mount the file system onto the mount point and make the pool available for use.# virsh pool-start guest_images_fs Pool guest_images_fs started # virsh pool-list --all Name State Autostart ----------------------------------------- default active yes guest_images_fs active no
Turn on autostart
By default, a storage pool defined withvirsh, is not set to automatically start each timelibvirtdstarts. To remedy this, enable the automatic start with thevirsh pool-autostartcommand. The storage pool is now automatically started each timelibvirtdstarts.# virsh pool-autostart guest_images_fs Pool guest_images_fs marked as autostarted # virsh pool-list --all Name State Autostart ----------------------------------------- default active yes guest_images_fs active yes
Verify the storage pool
Verify the storage pool was created correctly, the sizes reported are as expected, and the state is reported asrunning. Verify there is a "lost+found" directory in the mount point on the file system, indicating the device is mounted.# virsh pool-info guest_images_fs Name: guest_images_fs UUID: c7466869-e82a-a66c-2187-dc9d6f0877d0 State: running Persistent: yes Autostart: yes Capacity: 458.39 GB Allocation: 197.91 MB Available: 458.20 GB # mount | grep /guest_images /dev/sdc1 on /guest_images type ext4 (rw) # ls -la /guest_images total 24 drwxr-xr-x. 3 root root 4096 May 31 19:47 . dr-xr-xr-x. 25 root root 4096 May 31 19:38 .. drwx------. 2 root root 16384 May 31 14:18 lost+found

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.