How to change the default Storage Pool from libvirt

kvm-virtualizationlibvirtvirsh

I'm trying to use a different Storage Pool on KVM in order to store the virtual disks of my VMs and also the ISOs from the operating systems which I'm using.

For example: I want to use the directory /media/work/kvm which is mounted over /dev/sda5, as the default Storage Pool for all future situations

To configure, create and start a new storage pool, it is pretty easy, but a least in Ubuntu, it doesn't matter if I'm selecting and ISO from a different storage pool, Virtual Machine Manager always points me to the default Storage Pool (/var/cache/libvirt) as the storage where the virtual disks from my VMs will be created.

How can I avoid this?

Best Answer

Before following the steps, be sure that you are running these commands as normal user and that your user belongs to the group libvirtd (on some systems libvirt).

Here are the following commands which I used:

Listing current pools:

$ virsh pool-list
    
Name                 State      Autostart 
-------------------------------------------
default              active     yes 

Destroying pool:

$ virsh pool-destroy default
Pool default destroyed

Undefine pool:

$ virsh pool-undefine default
Pool default has been undefined

Creating a directory to host the new pool (if it does not exist):

$ sudo mkdir /media/work/kvm

Defining a new pool with name "default":

$ virsh pool-define-as --name default --type dir --target /media/work/kvm
Pool default defined

Set pool to be started when libvirt daemons starts:

$ virsh pool-autostart default
Pool default marked as autostarted

Start pool:

$ virsh pool-start default
Pool default started

Checking pool state:

$ virsh pool-list
Name                 State      Autostart 
-------------------------------------------
default              active     yes  

From now, when creating virtual machines, Virtual Machine Manager will inform you that the *.img file (virtual disk of your VM), will be saved at /media/work/kvm.

Related Topic