layout |
---|
default |
Although a number of useable appliances are available in the Apps option of the Storage section to allow easily creating VMs from the UI, sometimes you may need a specific distribution or a different version that you can find on the AppMarket. In that case, you can resort to installing the operating system from scratch, as you would install it on your own laptop.
The following instructions explain how to make a VM installing the operating system from scratch, and we will be using CentOS 7 (Minimal Install) as an example.
NOTE:
For Ubuntu: You may also follow the same instructions to install Ubuntu from scratch. In steps where the commands may differ, we have added Note sections specifically for Ubuntu.
The steps you require to create a VM from scratch are:
- Prepare the installation
- Run the installation
- Prepare the VM for production
- Configure contextualization
We will be developing these topics in the following subsections.
NOTE: The VM that you will be making following this guide will be using contextualization. Make sure you have your public ssh-key configured either in your user profile or in the template, before you create your VM. That way you will be able to log into your VM with your private key.
In this section we will be setting up the environment within your project (or Group) space in the HPC Cloud. It involves:
- Creating an
image
that will be empty in the beginning, which will work as an empty hard drive where you will install CentOS - Creating an
image
with the CentOS installation media, by fetching the distribution ISO - Creating a
template
where you bring all these components together, which you can use to start a VM from
Analogously to your laptop, your VM needs a hard drive where the operating system can be installed and where it will live. We will create one here.
- On the UI: Go to the Images tab (under Storage) and locate the green [+] button on the top-left corner of the screen. Click it and you see a blank Create Image form.
- On the UI: In the Create Image form:
- type in a meaningful Name (e.g.: centos_drive, we will use this name later)
- type in a meaningful Description (optional)
- choose Type Generic storage datablock
- leave Datastore with 104: local_images_ssd
- check the checkbox: This image is persistent
- below Image location choose radio button Empty disk image
- and give it a Size in MB that is meaningful to you (e.g.: in our test we used 10GiB, which is approximately 10000 MB)
- On the UI: Click the green button Create on the form, to submit it. A new
image
will show on the Images list, and it will keep in status LOCKED while it is being created. When it is created it will come to status READY.
- On the UI: Go to the Images tab (under Storage) and locate the green [+] button on the top-left corner of the screen. Click it and you see a blank Create Image form.
- On the UI: In the Create Image form:
- type in a meaningful Name (e.g.: centos_iso, we will use this name later)
- type in a meaningful Description (optional)
- choose Type Readonly CD-ROM
- leave Datastore with 104: local_images_ssd
- leave the checkbox This image is persistent unchecked
- on the Image location: group, choose radio button Path in OpenNebula server; then, underneath, paste the URL (HTTP, not FTP) of the ISO in the Path text box (e.g.: in our case, we used the most recent "minimal" one from: http://ftp.nluug.nl/ftp/pub/os/Linux/distr/CentOS/7/isos/x86_64/)
- On the UI: Click the green button Create on the form, to submit it. A new
image
will show on the Images list, and it will keep in status LOCKED while it is being created. When it is created it will come to status READY.
NOTE:
For Ubuntu: At the Image location step above replace with the URL (HTTP, not FTP) of the ISO of your prefferable Ubuntu distribution (e.g.: in our case, we used the most recent one from: http://ftp.nluug.nl/ftp/pub/os/Linux/distr/ubuntu-releases/17.04/)
Now that we have all components ready in the UI, we are ready to bring them together. On the HPC Cloud, we do that on a template
.
- On the UI: On the VMs tab (under Templates), click on the green [+] button (on the top-left corner of the screen) to start creating a new
template
. The page will change into the Create Template screen. - On the UI: On the Create Template screen, on the General tab:
- type in a meaningful Name (e.g.: centos_setup, we will use this name later)
- type in a meaningful Description (optional)
- choose a Logo that you like
- type in (or use the arrow buttons) 8GB of Memory
- type in (or use the arrow buttons) 1 CPU
- On the UI: On the same Create VM Template screen, on the Storage tab:
- for the Disk 0 (on the left column of the screen), choose the centos_drive
image
(from the table on the right of the screen) that you created as the firstimage
of this guide - click on the + button (that will make a new Disk 1), and then choose the centos_iso
image
you created as a secondimage
of this guide
- On the UI: On the same Create VM Template screen, on the Network tab:
- for the Interface 0 (on the left column of the screen), choose the internet
network
(from the table on the right of the screen) - click on the + button (that will make a new Interface 1), and then choose your internal
network
(it will be the only othernetwork
that you can see on the right that is not called internet)
- On the UI: On the same Create VM Template screen, on the OS Booting tab select the boot order as displayed in the picture:
- Tick the box under Boot order and choose CDROM (e.g. centos_iso)
- Tick the box under Boot order and choose HD (e.g. centos_drive)
- On the UI: On the same Create VM Template screen, on the OS Booting tab, set some Features (click on Features on the left column):
- set in ACPI: yes
- set in Localtime: no
- On the UI: On the same Create VM Template screen, on the Input/Output tab:
- click on the VNC radio button
- on the Inputs group, choose Tablet on the first dropdown menu, then USB on the second dropdown menu and finally click on the Add button. A new entry will appear below those dropdowns with what you just selected.
- On the UI: We are ready defining the
template
, so click on the green Create button at the top of the screen. A newtemplate
will show on the Templates list.
We will now create a VM and run the CentOS installation on it.
- On the UI: Go to the VMs tab (under Instances). Click on the green [+] button (on the top-left corner of the screen) to start creating a new VM. A form will pop up.
- On the UI: On the form that popped up:
- choose the template you defined before (i.e.: centos_setup)
- type in a meaningful VM name (e.g.: centos_first)
- On the UI: We are ready defining the VM, so click on the green Create button at the bottom of the form. A new VM will show on the Virtual Machines list. It will go through several states (e.g.: PENDING, PROLOG...) until it reaches the RUNNING state.
- On the UI: You can then start operating within your VM. Click on the screen-like button that you can see to the right of your VM on the list. It will pop-up the VNC console, so you should be able to see the welcome screen of your CentOS installation.
- Now you need to install CentOS, by following the steps you would normally follow (note, however, that at this point you have no network connection unless you define it manually).
- Create a root and (optionally) a user account in order to login to the VM for the first time. This would allow setting up contextualisation in a later step.
- On the UI: Once the installation is complete and you are prompted to reboot the machine, go back to the UI dashboard and shut down the VM from the UI. For this, tick the box next to your freshly installed Centos VM and select from the drop down red icon Terminate. Wait until it disappears from the VM list. Next we will remove all the installation media and prepare your VM for production.
Once you have installed and configured your CentOS, you do not need the installation media any more. We will make a new template
to use only the disk that we need.
- On the UI: First change the image where you installed the OS (centos_drive) from
datablock
toOS
. From theimages
tab, click on the centos_drive row and then switch Type:OS
. - On the UI: Begin creating a new
template
the usual way. - On the UI: On the Create VM Template screen, on the General tab:
- type in a meaningful Name (e.g.: my_research_run)
- give it as much memory and as many CPU's as you need
- On the UI: On the same Create VM Template screen, on the Storage tab:
- for the Disk 0 (on the left column of the screen), choose the centos_drive
image
(from the table on the right of the screen) that you created as the firstimage
of this guide, and where you have installed CentOS
- On the UI: On the same Create VM Template screen, on the Network tab:
- for the Interface 0 (on the left column of the screen), choose the internet
network
(from the table on the right of the screen) - click on the + Add another nic button (that will make a new Interface 1), and then choose your internal
network
(it will be the only othernetwork
that you can see on the right that is not called internet)
- On the UI: On the same Create VM Template screen, on the OS Booting tab, you want to set some Features (click on Features on the left column):
- set in ACPI: yes
- set in Localtime: no
- On the UI: On the same Create VM Template screen, on the Input/Output tab:
- click on the VNC radio button
- on the Inputs group, choose Tablet on the first dropdown menu, then USB on the second dropdown menu and finally click on the Add button. A new entry will appear below those dropdowns with what you just selected.
- On the UI: On the same Create VM Template screen, on the Context tab:
- click on Files on the left column of the screen
- make sure you check the check box for the
file
one-context_4.14.1.rpm
- On the UI: We are ready defining the
template
, so click on the green Create button at the top of the screen. A newtemplate
will show on the Templates list.
From now on, you will use this template
to run your VM.
NOTE:
For Ubuntu: On step 8 above where you select the contextualisation package make sure you check the box for debian which is thefile
one-context_4.14.1.deb
Start your freshly installed CentOS from the new template you created in the previous step. The last step is to configure your VM so that it auto-configures itself on start up (e.g.: at this point, you can see that there is no active network connection, so you cannot even browse the web). OpenNebula deliver their own .rpm to allow contextualization, and you are able to read that .rpm from the CONTEXT CD-ROM because you added that file to the template in the previous section.
- On the VM: Start a VM from the template you created in the pervious step. In a Desktop environment you may open a file explorer, and browse the CONTEXT CD-ROM. You should be able to see at least 2 files on that CD-ROM. One of them should be the one we manually added to the Context tab of the
template
some steps ago, called: one-context-4.14.1.rpm. - On the VM: Open a terminal and mount the CONTEXT CD-ROM (the action has to be performed as root):
mount -t iso9660 -L CONTEXT -o ro /mnt
- On the VM: On the same terminal, install the .rpm file:
yum install /mnt/*.rpm
NOTE:
For Ubuntu: Install the .deb file as:sudo dpkg -i /mnt/*.deb
Once the rpm is installed you may optionally remove the CONTEXT file from your template (Context tab and then Files).
- On the VM: You can reboot your CentOS now within the VM. When it boots up, you should be able to browse the Internet now. You can also test SSH-ing into your VM with your private key (
ssh [email protected]
, where you should replace mmm and nnn to match the IP address of your VM).
- In case that your freshly installed VM does not react to the Terminate button from the UI, check whether
acpid
is installed and enabled (see also troubleshooting).
NOTE:
Alternatively, you can use cloud-init as a contextualization configurer. CentOS has support for it via the standard yum repos, so you can install it via
yum install cloud-init
. Our tests indicate that network works, but there does not seem to be a default user configured to use public/private keys to SSH to the VM.A possible way to do it: you can first use the one-context-XXX.rpm package, reboot to let the network be contextualised, then install cloud-init and after that uninstall the one-context-XXX.rpm package.
NOTE:
For Ubuntu:
- In case that you encounter the problem not having internet access to your VM, here a is a quick fix.
- In case that you cannot connect to your VM via
ssh
, then check whetheropenssh-server
is installed. If not, install withapt-get install openssh-server
.- When you attempt to terminate your VM from the UI with the
Terminate
button in Ubuntu Desktop environment, a shutdown prompt window pops up. To disable this option, open a terminal and insert this command:gsettings set com.canonical.indicator.session suppress-logout-restart-shutdown true