Questo contenuto non è disponibile nella lingua selezionata.
12.2.3. Creating a Partition-based Storage Pool Using virsh
This section covers creating a partition-based storage pool with the
virsh
command.
Warning
Do not use this procedure to assign an entire disk as a storage pool (for example,
/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-as
command 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
name
parameter determines the name of the storage pool. This example uses the name guest_images_fs in the example below. - device
- The
device
parameter with thepath
attribute specifies the device path of the storage device. This example uses the partition /dev/sdc1. - mountpoint
- The
mountpoint
on the local file system where the formatted device will be mounted. If the mount point directory does not exist, thevirsh
command 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"
# virsh pool-define-as guest_images_fs fs - - /dev/sdc1 - "/guest_images" Pool guest_images_fs defined
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The new pool and mount points are now created.Verify the new pool
List the present storage pools.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the mount point
Use thevirsh pool-build
command to create a mount point for a pre-formatted file system storage pool.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Start the storage pool
Use thevirsh pool-start
command to mount the file system onto the mount point and make the pool available for use.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Turn on autostart
By default, a storage pool defined withvirsh
, is not set to automatically start each timelibvirtd
starts. To remedy this, enable the automatic start with thevirsh pool-autostart
command. The storage pool is now automatically started each timelibvirtd
starts.Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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.Copy to Clipboard Copied! Toggle word wrap Toggle overflow