Creating a custom image#

This guide will show you how to create a custom VM image on OpenNebula.

You may wish to do this if you want to customise one of the existing images, perhaps with some extra software packages or specific configuration and then save these changes as a new Virtual machine template for yourself or other to use.

Note

This guide will only cover how to create new images within the OpenNebula interface. Its possible to create images offline and upload them into the image store but that will not be covered in this document.

Step by step guide#

Tip

In this example we will be taking the Ubuntu 18.04 Desktop base image and customising it by installing some additional packages. We will then save this new customised image as a VM and allows others to create instances of this new custom image.

Launch an instance#

  • You will need to start by creating an instance using the base image of the VM you would like to customise. In this example we will be making a custom image based on the Ubuntu 18.04 Desktop image. It’s fine for this to be a non persistent instance.

  • Once you have created your instance and it is running you will need to connect to it and login to add your customisations.

Customise the system#

  • Once you are logged into your instance you can make any changes to the system as you usually would. In this instance we are going to install 2 new packages. Wireshark and mysql-server.

Ubuntu desktop#

../../_images/vm_desktop.png
  • In this example I have opened a terminal and used the command sudo apt install wireshark mysql-server to install my 2 packages. I need to use the sudo command as package installs on Linux require elevated privileges.

Note

On the Ubuntu base image the default user is called “user” and the password is “password” ?. This information can usually be found in the VM’s description field in the OpenNebula interface.

  • Once the command has finished running I checked both of the packages are installed.

Wireshark is installed#

../../_images/vm_wireshark.png
  • mysql-server doesn’t have an icon in the applications menu so a quick apt show mysql-server command confirmed its installation status.

mysql-server is installed#

../../_images/vm_sql.png
  • Once you have finished making changes to your VM you need to shut it down. You can do this as you would usually shut down the machine from within the operating system you are using.

  • Eventually when the system has finished shutting down its status will display as “POWEROFF” on the VM’s screen

VM is powered off#

../../_images/poweroff.png

Create the image#

  • Now the VM is shutdown we can clone the disk to create a new image.

  • Click on the VM you want to create an image from and you will open the VM’s info screen. On this screen you want to view the storage tab.

VM screen storage tab#

../../_images/vmstoragescreen.png
  • This screen shows all the VM’s attached storage devices. We want to create an image of the VM’s main system disk, in this case “sda”.

  • Under the actions column there is a small disk icon. Click on this and you will be able to save the disk as a new image.

Naming the new image#

../../_images/nameimage.png
  • Give your new image a name and click “Save as”

Note

This step is very important as it will help you and others to identify it. You will want to make its name relevant, perhaps a course/class reference number?

  • OpenNebula will now save your VM disk as a new images and add it to the image store.

Save in progress#

../../_images/savingdisk.png
  • When the save has completed (use the grey refresh button if you want check) you will be able to find the image listed in the images list.

  • The images screen can be found by clicking on Storage > Images in the menu on the left.

The images screen#

../../_images/imagesscreen.png
  • You should now see your image in the list

You have successfully created a custom image

Permissions#

Note

The image you have created is currently owned by your user, and by default you are the only user permitted to use it.

If you would like to “publish” your image for others to use (which will be necessary if you intend anyone else to be able to run a VM that uses this image) then you will need to edit the permissions of the image.

  • In the images screen click on your image and this will display the images “info” screen.

  • On the right-hand side you will see the permissions for this image.

Setting image permissions#

../../_images/imagepermissions.png
  • As shown in the above screenshot the default permission is that only the owner of the image can use it or manage it (change settings, delete it, etc).

  • If you want others to be able to use your VM you will need to check the “Use” box in the row for “Other”. If this VM is intended for your use only then the current settings are fine.

To use this image in a VM you will need to create a VM template.