Virtualization with libvirt

De Wiki de Sistemas Operativos
Revisión del 16:53 23 nov 2021 de Pneira (discusión | contribuciones) (Página creada con «For the realization of this practice you will need an Ubuntu Cloud image that we will download from https://cloud-images.ubuntu.com/ and we will need a host system with Ubu...»)
(dif) ← Revisión anterior | Revisión actual (dif) | Revisión siguiente → (dif)
Saltar a: navegación, buscar

For the realization of this practice you will need an Ubuntu Cloud image that we will download from https://cloud-images.ubuntu.com/ and we will need a host system with Ubuntu 18.04.

In this practice we will use the image downloaded from the Ubuntu Cloud website and we will use the cloud-init tool to configure it.

Next, we will use the Ubuntu image already configured to be imported to the virtualization software libvirt'.

= Step 1: Downloading the Ubuntu Cloud image

We enter https://cloud-images.ubuntu.com/ and download the Ubuntu 18.04 LTS (Long Time Support) image.

You can download it directly with the command wget:

wget https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img

if it started downloading you will see output similar to this:

-2019-08-06 12:26:26-- https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img
Resolving cloud-images.ubuntu.com (cloud-images.ubuntu.com).... 91.189.88.89, 2001:67c:1560:8001::8001
Connecting to cloud-images.ubuntu.com (cloud-images.ubuntu.com)[91.189.88.89]:443... connected.
HTTP request sent, waiting for response... 200 OK
Length: 343474176 (328M) [application/octet-stream] [application/octet-stream] [application/octet-stream]...
Saving to: "bionic-server-cloudimg-amd64.img"

bionic-server-cloudimg-amd64.img. 0%[ ] 2.21M 472KB/s eta 14m 6s

Wait until the image is 100% downloaded.

The Ubuntu cloud image comes with 2 GBytes of space by default, you can expand the size with the following command before using it in the virtual machine:

qemu-img resize bionic-server-cloudimg-amd64.img +8G

This increases the image by 8 Gbytes, so you are left with a 10 GByte Ubuntu cloud image.

Step 3: Installing the libguestfs package

Next, you have to install the packages that provide the virt-customize tool to configure the Ubuntu image you downloaded.

We can install these packages with the apt' tool from the shell.

For Ubuntu 18.04:

sudo apt install libguestfs

For Ubuntu 20.04:

sudo apt install libguestfs-tools

On the practice classroom computers these packages will already be pre-installed, so you can skip this step.

Step 3: Configuring the Ubuntu image with virt-customize

The virt-customize command allows you to set the password of the administrator user of the image we have downloaded.

virt-customize -a bionic-server-cloudimg-amd64.img --root-password password:coolpass

The above example shows how to configure the downloaded image to have the user root, and in this case, the password is coolpass.


Translated with www.DeepL.com/Translator (free version)