KVM

From WeBWorK_wiki
Jump to navigation Jump to search

QEMU/KVM running on a Ubuntu 22.04 Desktop host

First install Qemu-KVM

It is probably a good idea to first update and upgrade the system packages:

$ sudo apt update
$ sudo apt upgrade

Now install Qemu-KVM

$ sudo apt install -y qemu-kvm virt-manager libvirt-daemon-system virtinst libvirt-clients bridge-utils

Enable and start libvirtd

$ sudo systemctl enable --now libvirtd
$ sudo systemctl start libvirtd

and check that all is OK

$ sudo systemctl status libvirtd

Now wwadmin to the kvm and libvirt groups.

$ sudo usermod -aG kvm $USER
$ sudo usermod -aG libvirt $USER


=Convert the image to qcow2 format

cd to whatever directory you downloaded the WW2.18_Ubuntu22.04_Server.ova file to, (maybe "Downloads") and then untar it

tar -xvf WW2.18_Ubuntu22.04_Server.ova

which might take awhile. then run the command

qemu-img convert -p -f vmdk -O qcow2 WW2.18_Ubuntu22.04_Server-disk1.vmdk WW2.18_Ubuntu22.04_Server.qcow2

and move the qcow2 image to the correct location sudo mv WW2.18_Ubuntu22.04_Server.qcow2 /var/lib/libvirt/images/

=Boot up your virtual machine

Start up Virtual Machine Manager (search for VM in the app manager) and start up the WeBWorK vm.

Note that if you run into problems at this stage, the first thing to try is rebooting your host machine.

Networking

Accessing your server involves the same procedure as in VirtualBox 7 running on a Windows 11 host above. So you have to

  1. Find the name of the virtual nic (network interface card)
  2. Edit 00-installer-config.yaml
  3. Reboot your WeBWorK guest
  4. Find your WeBWorK guest's ip address

See VirtualBox 7 running on a Windows 11 host above for details.

Except that

  1. You do not need port forwarding
  2. Instead of using a terminal emulator, just open a terminal window on your host and ssh into your new system, e.g.
$ ssh  wwadmin@192.168.122.233

(where of course you need to use the actual ip address of your guest WeBWorK server).

Now login to your server using the password "wwadmin".

Expand the disk drive

You can do most of this from the graphical Virtual Machine Manager (select the machine, then Edit, Virtual Machine Details). Below are commands to this from the command line. I think you have to actually expand the disk from the command line but you can get information and add cpu's and/or memory from the graphical Virtual Machine Manager.

I'm assume the name of your WeBWorK guest is wwserver and it is Shutoff. First find the location of the disk. Run the command

$ sudo virsh domblklist wwserver
[sudo] password for wwadmin: <wwadmin password>

and you will see something like

 Target   Source
-------------------------------------------------------------------------
 sda      /var/lib/libvirt/images/WW2.15_Ubuntu20.04_Server-disk1.qcow2

Now get some info about the disk

$ sudo qemu-img info /var/lib/libvirt/images/WW2.15_Ubuntu20.04_Server-disk1.qcow2
[sudo] password for wwadmin: <wwadmin password>

and you will see something like

image: /var/lib/libvirt/images/WW2.15_Ubuntu20.04_Server-disk1.qcow2
file format: qcow2
virtual size: 12 GiB (12884901888 bytes)
disk size: 6.76 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

and now lets resize it to 20 GB by adding 8 GB

sudo qemu-img resize /var/lib/libvirt/images/WW2.15_Ubuntu20.04_Server-disk1.qcow2 +8G
[sudo] password for wwadmin: <wwadmin password>
Image resized.

You still have to repartition the disk and expand the file system on you guest. For that see Increase disk space above.

Continue the Installation

Return to the Accessing Your Server from a Terminal Emulator on your Host instructions above.