Skip to content

Instantly share code, notes, and snippets.

@plembo
Last active November 13, 2024 17:38
Show Gist options
  • Save plembo/13ce29c9279807adfd9bd6b959f43fac to your computer and use it in GitHub Desktop.
Save plembo/13ce29c9279807adfd9bd6b959f43fac to your computer and use it in GitHub Desktop.
Create the default KVM storage pool for images

Create the default KVM storage pool for images

Some distributions create the defaut KVM (libvirtd) storage pool for images when they install KVM, others do this upon the creation of the first KVM guest. Creating the default pool from scratch is pretty straightforward. Here's how to do it with virsh.

First verify there is no existing default pool:

$ virsh pool-list --all
 Name      State    Autostart
-----------------------------

NOTE: If a default pool already exists, follow this gist to relocate it to your preferred storage volume.

Assuming no pre-existing default pool exists and you want the physical path of the new pool to be /data1/libvirt/images, create that directory (sudo mkdir -p /data1/libvirt/images) and run the following commands:

$ virsh pool-define-as default dir --target "/data1/libvirt/images"
$ virsh pool-build default
$ virsh pool-start default
$ virsh pool-autostart default

Check the status with virsh-info:

$ virsh pool-info default
Name:           default
UUID:           8b806f67-87b4-403b-ae64-c652c0764641
State:          running
Persistent:     yes
Autostart:      yes
Capacity:       915.82 GiB
Allocation:     1.15 GiB
Available:      914.66 GiB

And then the configuration with pool-dumpxml:

$ virsh pool-dumpxml default
<pool type='dir'>
  <name>default</name>
  <uuid>8b806f67-87b4-403b-ae64-c652c0764641</uuid>
  <capacity unit='bytes'>983349346304</capacity>
  <allocation unit='bytes'>1238208512</allocation>
  <available unit='bytes'>982111137792</available>
  <source>
  </source>
  <target>
    <path>/d1/libvirt/images</path>
    <permissions>
      <mode>0755</mode>
      <owner>0</owner>
      <group>0</group>
    </permissions>
  </target>
</pool>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment