12.4.3. Creating an LVM-based Storage Pool with virsh
This section outlines the steps required to create an LVM-based storage pool with the
virsh
command. It uses the example of a pool named guest_images_lvm from a single drive (/dev/sdc
). This is only an example and your settings should be substituted as appropriate.
Procedure 12.3. Creating an LVM-based storage pool with virsh
- Define the pool name guest_images_lvm.
virsh pool-define-as guest_images_lvm logical - - /dev/sdc libvirt_lvm \ /dev/libvirt_lvm
# virsh pool-define-as guest_images_lvm logical - - /dev/sdc libvirt_lvm \ /dev/libvirt_lvm Pool guest_images_lvm defined
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Build the pool according to the specified name. If you are using an already existing volume group, skip this step.
virsh pool-build guest_images_lvm
# virsh pool-build guest_images_lvm Pool guest_images_lvm built
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Initialize the new pool.
virsh pool-start guest_images_lvm
# virsh pool-start guest_images_lvm Pool guest_images_lvm started
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Show the volume group information with the
vgs
command.vgs
# vgs VG #PV #LV #SN Attr VSize VFree libvirt_lvm 1 0 0 wz--n- 465.76g 465.76g
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Set the pool to start automatically.
virsh pool-autostart guest_images_lvm
# virsh pool-autostart guest_images_lvm Pool guest_images_lvm marked as autostarted
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - List the available pools with the
virsh
command.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The following commands demonstrate the creation of three volumes (volume1, volume2 and volume3) within this pool.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - List the available volumes in this pool with the
virsh
command.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The following two commands (
lvscan
andlvs
) display further information about the newly created volumes.Copy to Clipboard Copied! Toggle word wrap Toggle overflow