RHCSA – Autostarting a vm after a reboot

Overview

By the end of this article you should be able to answer the following questions:


What tasks do you need to perform to ensure vm starts up at boot time?

1. start+enable the libvirtd.service
2. enter into virsh cli, and apply to the autostart setting to the vm

What is the command to start the virtualisation service?

$ systemctl start libvirtd.service
$ systemctl enable libvirtd.service

What is the command to enable the vm called 'puppetmaster'?

$ virsh
virsh # autostart puppetmaster


By default when you restart your host machine, then any guest VMs that were running at the time won’t automatically start up again after the reboot.

To make sure that your VMs do start up after a host machine’s reboot, you need to do 2 things. First you need to ensure that the libvirtd daemon is enabled, so that it starts up after the reboot.

$ systemctl start libvirtd.service
$ systemctl enable libvirtd.service

Then you need to start a virsh interactive session and apply the autostart setting:

# virsh
Welcome to virsh, the virtualisation interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # list                     # only lists running vms. 
 Id    Name                           State
----------------------------------------------------

virsh # list --all               # lists all vms even those that are not currently running. 
 Id    Name                           State
----------------------------------------------------
 -     testVM                         shut off
virsh # autostart testVM
Domain testVM marked as autostarted
virsh #

After this the vm will now autostart after a host machine’s reboot.