# Manage virtual machines with Cockpit

Cockpit is an easy application to love.
It puts your entire fleet of servers and workstations in a centralized control panel, and gives you a fair amount of control over them.
Perhaps it's unsurprising that this includes virtual servers and workstations, but it many sysadmins don't realise that they can manage virtual machine creation from Cockpit, too.
If you've been using `virt-manager`, GNOME Boxes, or some other tool to spin up virtual machines, but you use Cockpit for diagnostics  and maintenance, you can now consolidate your tasks by managing virtual machines in the same interface.

## Install

To create and manage virtual machines with Cockpit, you must install the `cockpit-machines` module on the computer you run Cockpit on:

```bash
$ sudo dnf install cockpit-machine
```

This assumes that you already have Cockpit and virtual machines running on the machine.
If you're just starting out with these tools, then install these requirements:

```bash
$ sudo dnf install \
cockpit cockpit-machine libvirtd
```

Start `Cockpit` and `libvirtd`:

```bash
$ sudo systemctl start libvirtd
$ sudo systemctl start Cockpit
```

To log in to Cockpit, open your web browser to `localhost:9090` and enter your username and password.

## Virtual machines in Cockpit

After installing the `cockpit-machine` module, there's a new **Virtual Machines** entry in the left column of Cockpit.
Click on it to open the virtual machine panel.

If you have existing virtual machines you run with `libvirt`, Cockpis likely to detect them and list them in this panel.
Should Cockpit fail to detect existing virtual machines, you can import them by clicking the **Import VM** button.

Cockpit, just as GNOME Boxes or `virt-manager` does, knows the state of the virtual machine, and can start or stop them.
In the pop-up menu on the right, you can clone, rename, and delete them.

![Cockpit virtual machine view](cockpit-panel-vm.jpg)

## Create a storage pools with Cockpit

A storage pool is space that you designate as being available to store virtual machine images.
There's nothing necessarily special about it, but there's flexibility in what you can use.
For instance, you can set a network location, an iSCSI target, or a file system.

To create a storage pool, click the **Storage pool** button at the top of the virtual machine panel, and then click **Create storage pool** button.

![Cockpit storage pools](cockpit-storage-pool.jpg)

## Create a new virtual machine

You can create a virtual machine directly from Cockpit.
To create a new one, click the **Create VM** button on the right of the virtual machine panel.

All the usual options are present.
You can download a recent OS version from a drop-down list, or you can choose an ISO image on your local drive, or you can have the VM boot from a PXE server.

![Creating a new VM](cockpit-create-vm.jpg)

## Manage everything

Cockpit doesn't quite manage everything on your network, but it can manage a lot more than you might at first think from its default settings.
Start using Cockpit to manage your virtual machines today, and you just might find yourself adding other modules to manage your RHEL subscriptions, Podman containers, and more!