Virsh storage management allows you to control disks and storage for virtual machines. If you use libvirt, understanding storage is essential.
In this guide, we use Debian GNU/Linux 12 (Bookworm). All future examples in this series use this version.
Because virtual machines rely on disk images, proper storage management improves performance and organization.
Table of Contents
Understanding Storage in Libvirt
Before we explore virsh storage management commands, let us understand key concepts.
What Is a Storage Pool?
A storage pool is a logical container for virtual machine disks.
Think of it as a folder or storage backend where VM disk files live.
Common pool types include:
- Directory-based storage
- LVM volumes
- NFS shares
- iSCSI targets
By default, libvirt creates a pool at:
/var/lib/libvirt/images
You can list storage pools using:
virsh pool-list --all
What Is a Volume?
A volume is a disk image inside a storage pool.
Each VM disk is usually a volume.
You can list volumes using:
virsh vol-list default
Here, default is the pool name.
Because volumes represent VM disks, managing them properly is critical.
What Is QCOW2?
QEMU uses several disk formats. One popular format is qcow2.
QCOW2 stands for QEMU Copy-On-Write version 2.
Benefits of qcow2:
- Smaller disk size initially
- Snapshot support
- Backing file support
- Compression support
However, raw images may provide slightly better performance.
What Are Backing Files?
A backing file is a base image used by another qcow2 file.
Instead of copying a full OS image, you create a small overlay file.
Because of this, you save disk space.
For example:
- Base image:
debian12-template.qcow2 - New VM disk:
vm1.qcow2(uses base as backing file)
This approach is efficient and scalable.
What Are Templates?
A template is a preconfigured base image.
For example:
- Clean Debian 12 installation
- Updated and hardened system
- Pre-installed packages
You create new VMs from this template using backing files.
Therefore, templates speed up VM deployment.
Virsh Storage Management Commands
Now let us explore important virsh storage management commands.
1. virsh pool-list
This command lists storage pools.
virsh pool-list --all
It shows:
- Pool name
- State
- Autostart status
Use this to check if your pool is active.
2. virsh pool-define-as
This command defines a new storage pool.
Example: Create a directory-based pool.
virsh pool-define-as mypool dir --target /vm-storage
However, defining a pool does not start it.
You must start it manually.
3. virsh pool-start
Start a defined storage pool:
virsh pool-start mypool
To enable autostart:
virsh pool-autostart mypool
Because inactive pools cannot serve disks, always verify they are running.
4. virsh vol-list
List volumes inside a pool:
virsh vol-list mypool
This shows disk files available for virtual machines.
5. virsh vol-create
Create a new volume using an XML file:
virsh vol-create mypool volume.xml
Example XML:
<volume>
<name>vm1.qcow2</name>
<capacity unit="G">20</capacity>
<target>
<format type="qcow2"/>
</target>
</volume>
This creates a 20 GB qcow2 disk.
Because qcow2 supports snapshots, it is ideal for labs.
6. virsh vol-delete
Delete a volume:
virsh vol-delete vm1.qcow2 --pool mypool
Be careful. This permanently removes the disk.
Always verify before deletion.
Example Workflow: Creating Storage for a New VM
Here is a simple workflow using virsh storage management:
- Create a storage pool
- Start the pool
- Create a qcow2 volume
- Attach the volume to a VM
Because this method separates storage from VM configuration, management becomes cleaner.
Why Virsh Storage Management Matters
The virsh storage management approach gives you:
- Better disk organization
- Faster VM deployment
- Template-based provisioning
- Snapshot capability
In addition, using qcow2 with backing files reduces storage usage.
Therefore, it is ideal for labs and production environments.
FAQ Section
The default pool is usually /var/lib/libvirt/images
QCOW2 supports snapshots and backing files. Raw may be faster.
Yes. Libvirt supports LVM-based pools.
The VM disk is permanently removed.
No. However, templates simplify deployment.
Conclusion
Understanding virsh storage management is essential for managing disks in libvirt. Storage pools organize your disks. Volumes represent VM storage. QCOW2 provides flexibility. Backing files save space. Templates speed up deployment.
If you use Debian GNU/Linux 12 (Bookworm), mastering virsh storage management will improve both performance and scalability.
In the next guide, we will create a VM using a qcow2 backing file template.






[…] this works live, you can expand storage without […]