Cockpit/Web Console is a web application that we can use to manage not only the host but the guest virtual machines that run on QEMU/KVM hypervisors
Cockpit runs in the user space and leverages a plugin to use libvirt
to access the underlying hypervisor. Because of this, Cockpit doesn't have to know how to "talk to" the hypervisor, it only has to communicate with libvirt
via the libvirtd
service
From the Cockpit Project website:
"The easy-to-use, integrated, glanceable, and open web-based interface for your servers."
Install cockpit
and the cockpit-machines
plugin
-
Check to see if
Cockpit
orvirt
are already installedsudo dnf list installed | egrep -i "cockpit|virt"
-
Install required packages
sudo dnf -y install libvirt cockpit cockpit-machines
-
Check for any updates
sudo dnf -y update
-
List the current firewall config - ensure
cockpit
service is allowed (http/9090) - see link to setupsudo firewall-cmd --list-all
-
Add a
<user>
to the libvirt group - this allows non-root users to administer Virtual Environmentsudo usermod -a -G libvirt 'id -un'
sudo usermod -a -G libvirtdbus 'id -un'
sudo usermod -a -G libvirt libvirtdbus
sudo usermod -a -G libvirt qemu
-
Change the Default Location for Virtual Disk File Location
- Default location is
/var/lib/libvirt/images
- Default location is
-
Create a new
location
for the Virtual Hard Disk(s)sudo mkdir /home/Virtual_Machines
-
Set the
Ownership
(qemu) andGroup Ownership
(libvirt) on the foldersudo chown -R qemu:libvirt /home/Virtual_Machines
-
Set the Permissions on the folder
sudo chmod 0770 /home/Virtual_Machines
-
Check changes
sudo ls -la /home
-
Ensure the
cockpit
service is running (e.g. enabled and active)-
sudo systemctl status cockpit
To Enable
sudo systemctl enable cockpit.socket --now
-
-
Ensure the
libvirtd
service is running (e.g. enabled and active)-
sudo systemctl status libvirtd
To Enable
sudo systemctl enable libvirtd --now
-
-
Point a browser at
http://<hostname> or <ip-address>:9090
-
Login with the
<user>
setup above (that has permissions to manage the virtual environment)
- Note the
Storage Pools
andNetworks
-
Download an ISO
- Browse or
curl
- Place .iso file in /tmp
- Browse or
-
Ensure the .iso file exists
ls -la /tmp
-
Login to
Cockpit
http://<hostname> or <ip-address>:9090
-
Setup a
Storage Pool
for the/home/Virtual_Machines
folder created earlier (to store the Virtual Disk File Location)- Connection =
QEMU/KVM
- Name =
Virtual_Machines
- Type =
Filesystem Directory
- Target Path =
/home/Virtual_Machines
- Startup on boot =
true
- Connection =
-
Create New Virtual Machine
- Connection =
QEMU/KVM
- Name =
my-new-vm
- Installation Source Type =
Local Install Media
- Installation Source =
path-to-iso-file
(e.g./tmp/myiso.iso
) - Storage =
NO STORAGE
- we want to setup Storage in a non-default location (/home/Virtual_Machines
) - Memory = 2GB
- OS Vender =
choose from list
- Operating System =
choose from list
- Immediately Start VM = NO / FALSE - No Storage yet so wont boot!
- Create
- Connection =
-
Add a new Virtual Disk and attach it to the VM
- From the Cockpit Web
- Locate the Virtual Machine
- Locate Disk
- Click Add Disk
- Choose
Pool
(e.g.Virtual_Machines
) - Name the
Volume
- Enter size
- Format =
qcow2
- Persistence =
Always attach
= TRUE
-
Install the OS
- From the console - Click
install
- Follow standard OS Installation
- From the console - Click
-
Start the VM
- Following OS Installation, click
Start
- Following OS Installation, click
-
Patch
sudo dnf -y update
-
Shutdown / Power Off
sudo systemctl poweroff
-
Add CPU Cores / Memory
- Locate the VM in Cockpit
- Ensure the VM is Powered Off
- Click Edit next to CPU / Memory
- Change value as desired
- Start VM
- Validate Memory change
grep MemTotal /proc/meminfo
- Validate the CPU change
grep -i processor /proc/cpuinfo
-
Add Disk
- Review our current Disk setup
sudo fdisk -l
- Review our current Virtual Devices
ls -la /dev/vd*
- Locate the VM and Click
Add disk
- Choose
Pool
(e.g.Virtual_Machines
) - Name the Volume
- Enter size
- Format =
qcow2
- Persistence =
Always attach
= TRUE
- Choose
- Validate the New Volume
ls -la /dev/vd*
- Validate the New Disk
sudo fdisk -l
- Review our current Disk setup