How to change the default Storage Pool from libvirt?

Solution 1:

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.

Solution 2:

If you just want to change the image path, you can also edit the storage path in the default pool by running:

$ virsh pool-edit default

The above command will open the default pool xml in an editor (vim/nano), now:

  1. edit the path
  2. save the changes and
  3. restart libvirt service

Solution 3:

Aside from the reply above showing how todo it from the command line, you can also change this from virt-manager directly. In the main virt-manager window, go to the menu 'Edit -> Host Details'. In the dialog box that appears, switch to the 'Storage' tab. You can now delete the 'default' storage pool and create a new storage pool to replace it.