Ubuntu: How to fully remove QEMU/KVM?



Question:

I have QEMU installed but as I don't really use it and it's recently had lots of security vulnerabilities discovered in it so I would like to fully remove it. I installed it with sudo apt-get install qemu as far as I know. When I run sudo apt-get purge qemu it only says that it removes qemu but when it had its most recent update I saw that it had many dependencies and other packages called qemu something which it didn't remove along with the qemu package.

So how can I fully remove it so that all of its config files and packages installed by it are removed? Obviously if dependencies are used by other programs that it uses then I don't want to remove them too, but only things it installed and that are not needed by other programs. I tried running sudo apt-get autoremove which is the equivalent to what the answers here say so that didn't help (it didn't remove anything).

I am running Ubuntu GNOME 15.10 with GNOME 3.18.

Information Update:

I upgraded my machine to Ubuntu GNOME 16.04 with GNOME 3.20, I don't remember whether I reinstalled qemu before or after the upgrade, but I did along with qemu-kvm and the virt-manager package. But now even after purging all three of them and seemingly removing all of the dependencies they installed, I still have a problem. It doesn't seem to have actually removed all the changes they made to my system.

For instance this was the output from systemctl status qemu-kvm.service:

● qemu-kvm.service - LSB: QEMU KVM module loading script     Loaded: loaded (/etc/init.d/qemu-kvm; bad; vendor preset: enabled)     Active: failed (Result: exit-code) since Sun 2016-08-14 13:19:28 BST; 33min ago       Docs: man:systemd-sysv-generator(8)    Process: 2099 ExecStart=/etc/init.d/qemu-kvm start (code=exited, status=5)    Aug 14 13:19:28 <Computer-Name> systemd[1]: Starting LSB: QEMU KVM module loading script...  Aug 14 13:19:28 <Computer-Name> systemd[1]: qemu-kvm.service: Control process exited, code=exited status=5  Aug 14 13:19:28 <Computer-Name> systemd[1]: Failed to start LSB: QEMU KVM module loading script.  Aug 14 13:19:28 <Computer-Name> systemd[1]: qemu-kvm.service: Unit entered failed state.  Aug 14 13:19:28 <Computer-Name> systemd[1]: qemu-kvm.service: Failed with result 'exit-code'.  

And this was the output from journalctl | grep qemu:

Aug 14 13:19:23 <Computer-Name> ureadahead[866]: ureadahead:/lib/udev/rules.d/60-qemu-system-common.rules: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-alpha: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/lib/x86_64-linux-gnu/qemu/block-curl.so: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-arm: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/lib/x86_64-linux-gnu/qemu/block-iscsi.so: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/lib/x86_64-linux-gnu/qemu/block-dmg.so: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/lib/x86_64-linux-gnu/qemu/block-rbd.so: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-aarch64: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-cris: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-i386: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-lm32: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-m68k: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-microblaze: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-microblazeel: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-x86_64: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-ppc64: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-ppcemb: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-sh4: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-sh4eb: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-sparc: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-sparc64: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-unicore32: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-xtensaeb: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-mips: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-mips64el: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-mipsel: No such file or directory  Aug 14 13:19:24 >Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-or32: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-ppc: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-xtensa: No such file or directory  Aug 14 13:19:24 <Computer-Name> ureadahead[866]: ureadahead:/usr/bin/qemu-system-mips64: No such file or directory  Aug 14 13:19:25 <Computer-Name> systemd[1]: qemu-kvm.service: Control process exited, code=exited status=5  Aug 14 13:19:25 <Computer-Name> systemd[1]: qemu-kvm.service: Unit entered failed state.  Aug 14 13:19:25 <Computer-Name> systemd[1]: qemu-kvm.service: Failed with result 'exit-code'.  Aug 14 13:19:25 <Computer-Name> ureadahead[866]: ureadahead:/usr/share/qemu/init/qemu-kvm-init: No such file or directory  Aug 14 13:19:27 <Computer-Name> systemd[1]: qemu-kvm.service: Control process exited, code=exited status=5  Aug 14 13:19:27 <Computer-Name> systemd[1]: qemu-kvm.service: Unit entered failed state.  Aug 14 13:19:27 <Computer-Name> systemd[1]: qemu-kvm.service: Failed with result 'exit-code'.  Aug 14 13:19:28 <Computer-Name> systemd[1]: qemu-kvm.service: Control process exited, code=exited status=5  Aug 14 13:19:28 <Computer-Name> systemd[1]: qemu-kvm.service: Unit entered failed state.  Aug 14 13:19:28 <Computer-Name> systemd[1]: qemu-kvm.service: Failed with result 'exit-code'.  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-arm: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-armeb: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-cris: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-m68k: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-mips: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-mips64: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-mipsel: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-mips64el: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-ppc: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-ppc64: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-ppc64abi32: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-ppc64le: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-s390x: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-sh4: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-sh4eb: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-sparc: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-microblaze: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-sparc32plus: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-aarch64: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-alpha: No such file or directory  Aug 14 13:19:31 <Computer-Name> ureadahead[866]: ureadahead:/var/lib/binfmts/qemu-sparc64: No such file or directory  Aug 14 13:19:32 <Computer-Name> ureadahead[866]: ureadahead:/etc/libvirt/qemu/Ubuntu_GNOME_16-04_GNOME_3-18.xml: No such file or directory  Aug 14 13:19:32 <Computer-Name> ureadahead[866]: ureadahead:/etc/libvirt/qemu/Ubuntu_GNOME_16-10_GNOME_3-21.xml: No such file or directory  Aug 14 13:19:32 <Computer-Name> ureadahead[866]: ureadahead:/etc/libvirt/qemu/Ubuntu_Unity_16-04.xml: No such file or directory  Aug 14 13:19:32 <Computer-Name> ureadahead[866]: ureadahead:/etc/libvirt/qemu/Ubuntu_GNOME_16-04_GNOME_3-20.xml: No such file or directory  Aug 14 13:20:42 <Computer-Name> /usr/lib/gdm3/gdm-x-session[3320]: dbus-update-activation-environment: setting LIBVIRT_DEFAULT_URI=qemu:///system  

So clearly QEMU isn't completely gone. But I want it to be so how do I completely remove it and all the changes it made?

When I run service --status-all | grep qemu this is the output:

 [ - ]  qemu-kvm  

So it appears that it is there even though it may not be active as it does not seem to currently be running and I think that the - sign probably indicates its current status as many of the other services have + signs. So would it be safe then to just remove this service? And if so, how can this be done?


Solution:1

First some clarification : qemu is a metapackage, depending on all other qemu-related packages.
As I use the synaptic package management tool which has the possibility to save the complete installation history of all time, I am able to tell you which packages are installed alongside qemu.

Commit Log for Thu Apr 21 18:34:38 2016      Installed the following packages:      cpu-checker (0.7-0ubuntu7)    ipxe-qemu (1.0.0+git-20150424.a25a16d-1ubuntu1)    libaio1 (0.3.110-2)    libboost-random1.58.0 (1.58.0+dfsg-5ubuntu3)    libboost-thread1.58.0 (1.58.0+dfsg-5ubuntu3)    libcacard0 (1:2.5.0-2)    libfdt1 (1.4.0+dfsg-2)    libiscsi2 (1.12.0-2)    librados2 (10.1.2-0ubuntu1)    librbd1 (10.1.2-0ubuntu1)    libspice-server1 (0.12.6-4)    libusbredirparser1 (0.7.1-1)    libxen-4.6 (4.6.0-1ubuntu4)    libxenstore3.0 (4.6.0-1ubuntu4)    msr-tools (1.3-2)    qemu (1:2.5+dfsg-5ubuntu10)    qemu-block-extra (1:2.5+dfsg-5ubuntu10)    qemu-slof (20151103+dfsg-1ubuntu1)    qemu-system (1:2.5+dfsg-5ubuntu10)    qemu-system-arm (1:2.5+dfsg-5ubuntu10)    qemu-system-common (1:2.5+dfsg-5ubuntu10)    qemu-system-mips (1:2.5+dfsg-5ubuntu10)    qemu-system-misc (1:2.5+dfsg-5ubuntu10)    qemu-system-ppc (1:2.5+dfsg-5ubuntu10)    qemu-system-sparc (1:2.5+dfsg-5ubuntu10)    qemu-system-x86 (1:2.5+dfsg-5ubuntu10)    qemu-user (1:2.5+dfsg-5ubuntu10)    qemu-user-binfmt (1:2.5+dfsg-5ubuntu10)    qemu-utils (1:2.5+dfsg-5ubuntu10)    seabios (1.8.2-1ubuntu1)    sharutils (1:4.15.2-1)  

To remove all the qemu related packages - open a terminal and execute the following command :

sudo apt-get purge cpu-checker ipxe-qemu libaio1 libboost-random1.58.0 libboost-thread1.58.0 libcacard0 libfdt1 libiscsi2 librados2 librbd1 libspice-server1 libusbredirparser1 libxen-4.6 libxenstore3.0 msr-tools qemu qemu-block-extra qemu-slof qemu-system qemu-system-arm qemu-system-common qemu-system-mips qemu-system-misc qemu-system-ppc qemu-system-sparc qemu-system-x86 qemu-user qemu-user-binfmt qemu-utils seabios sharutils    

Note : This is from Ubuntu 16.04 - in case that a single package (example : libboost-random1.58.0) has a different name in Ubuntu 15.10 you can check this with dpkg --get-selections. But most packages should have the same name ... now you have completely removed every trace of qemu.

I have checked the packages for wilyon packages.ubuntu.com and I found one package with a different name : libxen-4.6 which in wily is libxen-4.5 - so you have to replace this in the purge command. You also may consider to keep the lib packages, just to be on the safe side.

Update addressing your comment that you still have a not running qemu-kvm service listed :

This is a startup service which is running when you additionally installed the qemu-kvm package.

qemu-kvm

You have two options, you can disable the service with systemctl disable qemu-kvm or you can remove the service with sudo rm /etc/init.d/qemu-kvm. To also remove the configuration file, execute sudo rm /etc/init/qemu-kvm.conf. Now reboot the system - the service will be gone.


Solution:2

you can use

sudo apt-get purge --auto-remove qemu-kvm  

this will delete all releated qemu files and folders


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »