Difference between revisions of "KVM"

From WeBWorK_wiki
Jump to navigation Jump to search
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
===QEMU/KVM running on a Ubuntu 22.04 Desktop host===
 
===QEMU/KVM running on a Ubuntu 22.04 Desktop host===
First install Qemu-KVM . See e.g. https://itslinuxfoss.com/install-kvm-ubuntu-22-04/
 
  +
====First install Qemu-KVM====
====Importing the ova File====
 
sudo apt install virt-v2v
 
   
sudo virt-v2v -i ova WW2.18_Ubuntu22.04_Server.ova -of qcow2
 
  +
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
   
   
First cd to whatever directory you downloaded the <code>WW2.16_Ubuntu20.04_Server.ova</code> file to, (maybe "Downloads"). Then untar it
 
  +
====Convert the image to qcow2 format===
tar -xvf WW2.16_Ubuntu20.04_Server.ova
 
which might take awhile and then run the command
 
sudo virt-convert WW2.16_Ubuntu20.04_Server.ovf -D qcow2 --destination /var/lib/libvirt/images/
 
   
This will take awhile but eventually your guest WeBWorK server will start up automatically in a Virt Viewer window. Login as wwadmin with password wwadmin and then go on to the next section.
 
  +
cd to whatever directory you downloaded the <code>WW2.18_Ubuntu22.04_Server.ova</code> 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====
 
====Networking====
   
Accessing your server involves the same procedure as in [[#VirtualBox 6 running on a Windows 10 host|VirtualBox 6 running on a Windows 10 host]] above. So you have to
+
Accessing your server involves the same procedure as in [[#VirtualBox 7 running on a Windows 11 host|VirtualBox 7 running on a Windows 11 host]] above. So you have to
# Find the name and MAC address of the virtual nic (network interface card)
+
# Find the name of the virtual nic (network interface card)
 
# Edit 00-installer-config.yaml
 
# Edit 00-installer-config.yaml
 
# Reboot your WeBWorK guest
 
# Reboot your WeBWorK guest
 
# Find your WeBWorK guest's ip address
 
# Find your WeBWorK guest's ip address
See [[#VirtualBox 6 running on a Windows 10 host|VirtualBox 6 running on a Windows 10 host]] above for details.
+
See [[#VirtualBox 7 running on a Windows 11 host|VirtualBox 7 running on a Windows 11 host]] above for details.
   
 
'''Except that'''
 
'''Except that'''

Latest revision as of 10:54, 11 September 2023

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.