Last Updated:

Gnome Boxes won't start virtual machines

masonbee Fedora

Although this is a specific use case it will show the solution to a possible problem of Gnome Boxes not booting images.

In this case it is because I wanted place my virtual machines on another disk so I deleted the images directory at /home/username/.local/share/gnome-boxes and replaced it with a soft link to another directory /Virtual which is on another disk but is owned by my user and group. This is on Fedora 34 by the way.

Unfortunately when trying to boot the a virtual machine it would fail and I couldn't really find anything in the logs that was helpful (admittedly, I did not look for long). After that I looked at the SELinux Troubleshooter to see if there were any errors and low and behold there were and there was also a solution. A slightly verbose one.

SELinux Troubleshooter says if you scroll down,

If you want to allow qemu-system-x86 to have read access on the images lnk_file
Then you need to change the label on images
# semanage fcontext -a -t FILE_TYPE 'images'
where FILE_TYPE is one of the following: admin_home_t, alsa_etc_rw_t, alsa_home_t, antivirus_home_t, audio_home_t, auth_home_t, bin_t, boot_t, cache_home_t, cert_t, chrome_sandbox_home_t, config_home_t, container_file_t, container_home_t, container_ro_file_t, cvs_home_t, data_home_t, dbus_home_t, device_t, devlog_t, etc_runtime_t, etc_t, fetchmail_home_t, fonts_cache_t, fonts_t, gconf_home_t, git_user_content_t, gkeyringd_gnome_home_t, gnome_home_t, gpg_secret_t, gstreamer_home_t, home_bin_t, home_cert_t, home_root_t, icc_data_home_t, iceauth_home_t, irc_home_t, irc_tmp_t, irssi_home_t, kismet_home_t, krb5_home_t, ld_so_t, lib_t, local_login_home_t, locale_t, mail_home_rw_t, mail_home_t, man_cache_t, man_t, mandb_home_t, mnt_t, mozilla_home_t, mpd_home_t, mpd_user_data_t, mplayer_home_t, mysqld_home_t, net_conf_t, nfs_t, openshift_var_lib_t, polipo_cache_home_t, polipo_config_home_t, proc_t, procmail_home_t, public_content_rw_t, public_content_t, pulseaudio_home_t, qemu_var_run_t, rlogind_home_t, root_t, rpm_script_tmp_t, rssh_ro_t, rssh_rw_t, sandbox_file_t, screen_home_t, security_t, shell_exec_t, spamc_home_t, speech_dispatcher_home_t, src_t, ssh_home_t, svirt_home_t, svirt_image_t, svirt_tmp_t, svirt_tmpfs_t, sysfs_t, system_conf_t, system_db_t, systemd_home_t, telepathy_cache_home_t, telepathy_data_home_t, telepathy_gabble_cache_home_t, telepathy_logger_cache_home_t, telepathy_logger_data_home_t, telepathy_mission_control_cache_home_t, telepathy_mission_control_data_home_t, telepathy_mission_control_home_t, telepathy_sunshine_home_t, texlive_home_t, textrel_shlib_t, thumb_home_t, tmp_t, tvtime_home_t, udev_var_run_t, uml_ro_t, uml_rw_t, usbfs_t, user_fonts_cache_t, user_fonts_config_t, user_fonts_t, user_home_dir_t, user_home_t, user_tmp_t, usr_t, var_run_t, var_t, virt_content_t, virt_etc_rw_t, virt_home_t, virt_image_t, virt_var_lib_t, virt_var_run_t, vmware_conf_t, vmware_file_t, wine_home_t, wireshark_home_t, xauth_home_t, xdm_home_t.
Then execute:
restorecon -v 'images'

Which is great because it pretty much tells you exactly what to do.

Change to the images parent directory,

cd /home/username/.local/share/gnome-boxes

And run semanage with the given qemu_var_run_t as the FILE_TYPE in the example command.

sudo semanage fcontext -a -t qemu_var_run_t 'images'

Then run restorecon to set the changes,

restorecon -v 'images'

And suddenly your virtual machines will start loading. I strongly recommend installing the SELinux Troubleshooter to beginners with SELinux. It's really very helpful and a good first stop when things mysteriously fail to work.

On Fedora 34 you can install it with,

sudo dnf install setroubleshoot

in the terminal or by searching for selinux in Gnome Software.

Featured image used without alteration from Wikipedia under the Creative Commons Attribution-Share Alike 4.0 International.