Based on the title of this article, the main subject or topic of this article is mainly about how to remove storage pool in a libvirtd service. Libvirtd is a daemon which is used for handling libvirtd management. What is libvirtd actually ?, well based on the manual page in Linux operating system, libvirtd can be described as a daemon program in the server side responsible for libvirt virtualization management system.
The trigger for removing storage pool in a libvirt virtualization management system is when the libvirtd as the libvirt daemon of virtualization management system is being checked. The command executed is for checking the status of the running process or the running daemon of libvirt virtualization management system. Below is the command executed :
root@hostname:~# systemctl status libvirt-bin ● libvirt-bin.service - Virtualization daemon Loaded: loaded (/lib/systemd/system/libvirt-bin.service; enabled; vendor preset: enabled) Active: active (running) since Sel 2017-07-25 16:21:49 ; 3s ago Docs: man:libvirtd(8) http://libvirt.org Main PID: 21487 (libvirtd) Tasks: 18 Memory: 95.0M CPU: 444ms CGroup: /system.slice/libvirt-bin.service ├─ 2742 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper ├─ 2743 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper └─21487 /usr/sbin/libvirtd Jul 25 16:21:50 hostname dnsmasq[2742]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses Jul 25 16:21:50 hostname dnsmasq-dhcp[2742]: read /var/lib/libvirt/dnsmasq/default.hostsfile Jul 25 16:21:50 hostname libvirtd[21487]: libvirt version: 1.3.1, package: 1ubuntu10.1 (dann frazier <[email protected]> Fri, 03 Jun 2016 14:41:21 -0600) Jul 25 16:21:50 hostname libvirtd[21487]: hostname: hostname Jul 25 16:21:50 hostname libvirtd[21487]: cannot open path '/home/user/images': No such file or directory Jul 25 16:21:50 hostname libvirtd[21487]: Failed to autostart storage pool 'images': cannot open path '/home/user/images': No such file or directory Jul 25 16:21:50 hostname libvirtd[21487]: cannot open path '/home/user/Infrastructure/Server/Images': No such file or directory Jul 25 16:21:50 hostname libvirtd[21487]: Failed to autostart storage pool 'Images': cannot open path '/home/user/Infrastructure/Server/Images': No such file or directory Jul 25 16:21:50 hostname libvirtd[21487]: cannot open path '/home/user/base-image': No such file or directory Jul 25 16:21:50 hostname libvirtd[21487]: Failed to autostart storage pool 'base-image': cannot open path '/home/user/base-image': No such file or directory root@hostname:~#
As shown in the above output, there are several storage pool which cannot be started. That information about storage pool list can also be shown in general by executing the following command :
virsh pool-list all
The above command when it is being executed, the output more or less can be shown below :
root@hostname:~# virsh pool-list --all Name State Autostart ------------------------------------------- base-image inactive yes default active yes user active yes images inactive yes Images inactive yes root@hostname:~#
To remove all the ‘inactive’ storage pool, it can be done easily by removing removing the XML file which associated with each of the storage pool listed. So, access the location of those XML files which each of it represents each storage pool listed in ‘/etc/libvirt/storage’ :
root@hostname:/etc/libvirt/storage# ls -al total 40 drwxr-xr-x 5 root root 4096 Jul 25 22:19 . drwxr-xr-x 6 root root 4096 Jul 25 19:57 .. drwxr-xr-x 2 root root 4096 Jan 11 2017 autostart -rw------- 1 root root 543 Jan 11 2017 base-image.xml -rw------- 1 root root 538 Jan 9 2016 default.xml -rw------- 1 root root 522 Okt 14 2016 user.xml -rw------- 1 root root 531 Des 14 2016 images.xml -rw------- 1 root root 560 Jan 11 2017 Images.xml root@hostname:/etc/libvirt/storage#
To avoid removing the wrong file, check the content of the XML file listed above. It can be done by using any kind of text editor available in the operating system. Below is how to check the content of the XML file using ‘vim’ as the text editor :
<!-- WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE OVERWRITTEN AND LOST. Changes to this xml configuration should be made using: virsh pool-edit user or other application using the libvirt API. --> <pool type='dir'> <name>user</name> <uuid>ce150bc8-e3d9-43c6-acf7-0a94b189dcb3</uuid> <capacity unit='bytes'>0</capacity> <allocation unit='bytes'>0</allocation> <available unit='bytes'>0</available> <source> </source> <target> <path>/home/user</path> </target> </pool>
Match the path described in the XML file content with the one presented at the time libvirt status service check is being executed. Those files that matches, just remove it so that the ‘inactive’ storage pool associated will also be removed automatically. Just execute the following command to remove the associated XML file :
root@hostname:/etc/libvirt/storage# rm -rf user.xml images.xml Images.xml root@hostname:/etc/libvirt/storage# ls -al total 28 drwxr-xr-x 5 root root 4096 Jul 25 22:22 . drwxr-xr-x 6 root root 4096 Jul 25 19:57 .. drwxr-xr-x 2 root root 4096 Jan 11 2017 autostart -rw------- 1 root root 543 Jan 11 2017 base-image.xml -rw------- 1 root root 538 Jan 9 2016 default.xml root@hostname:/etc/libvirt/storage#
Re-execute the command for checking the status of the libvirt-bin service. There shouldn’t be any messages anymore concerning about storage pool path cannot be opened as shown below :
root@hostname:/etc/libvirt/storage# systemctl status libvirt-bin ● libvirt-bin.service - Virtualization daemon Loaded: loaded (/lib/systemd/system/libvirt-bin.service; enabled; vendor preset: enabled) Active: active (running) since Sel 2017-07-25 16:28:03; 6s ago Docs: man:libvirtd(8) http://libvirt.org Main PID: 22250 (libvirtd) Tasks: 18 Memory: 97.2M CPU: 455ms CGroup: /system.slice/libvirt-bin.service ├─ 2742 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper ├─ 2743 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper └─22250 /usr/sbin/libvirtd Jul 25 16:28:03 hostname systemd[1]: Starting Virtualization daemon... Jul 25 16:28:03 hostname systemd[1]: Started Virtualization daemon. Jul 25 16:28:03 hostname dnsmasq[2742]: read /etc/hosts - 91 addresses Jul 25 16:28:03 hostname dnsmasq[2742]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses Jul 25 16:28:03 hostname dnsmasq-dhcp[2742]: read /var/lib/libvirt/dnsmasq/default.hostsfile root@hostname:/etc/libvirt/storage#
Another method which can be utilized to prove whether the storage pool has already been removed from the list is also to re-execute the following command :
root@hostname:/etc/libvirt/storage# virsh pool-list --all Name State Autostart ------------------------------------------- default active yes user active yes root@hostname:/etc/libvirt/storage#
As shown in the above storage pool list, the previous ‘inactive’ storage pool has gone.