Create a Virtual Machine based on Ubuntu, containing QGIS and the Semi-Automatic Classification Plugin


In this tutorial we are going to create a virtual machine based on Ubuntu.
The purpose of this virtual machine is to include the required GIS software for land cover classification: QGIS, Orfeo Toolbox, and SAGA GIS. Also, the intention is to produce a fast virtual machine that occupies little disk space and is adequate to low-spec computers.
The following steps are mainly the same ones that I have used for the creation of the Semi-Automatic OS.

The system will be based on Ubuntu 12.04 Precise, therefore we need to download the installation image .iso from here. Select the PC (Intel x86) alternate install CD (if you have a 64-bit PC you can choose the AMD64 version) and download the .iso file (about 700 MB).

In order to create a virtual machine, we need to install VirtualBox that is open source softwareDownload VirtualBox from here (select a proper version according to your operating system), and install it (restart your system when the installation is finished).

  1. Create a new virtual machine in VirtualBox
    • Run VirtualBox and click the button New;
    • Type a name for the virtual machine (for instance Ubuntu); select Linux and Ubuntu as Type and Version respectively; click Next;
    • Set the memory size (this parameter can be changed at any time); the more is the better, but this parameter should not exceed a half of the host system RAM (for instance if your system has 1 GB of RAM, type 512 MB), and it should not be below 256 MB; click Next;
    • In the Hard drive settings select Create a virtual hard drive now and click Create;
    • In the Hard drive file type you can choose between several alternatives; if you wish that your virtual machine is compatible with other virtualization programs select VMDK, otherwise select VDI for VirtualBox format; in this tutorial we select VMDK and click Next;
    • Select Dynamically allocated (the virtual hard disk is a file that dynamically grows according to the space occupied in the virtual systemand click Next;
    • Under File location and size set a proper size according to the free space in your hard disk (at least 5 GB); here we select 8 GB and click Create
    • The Ubuntu virtual machine is now listed in the VirtualBox menu; right click on Ubuntu in the VirtualBox menu, and select Settings... ; select Storage and click Controller: IDE > Empty; under Attributes click the CD icon and select Choose a virtual CD/DVD disk file; select the downloaded  file Ubuntu.iso, check Live CD/DVD and click OK.

  1. Install the Ubuntu command line system
    We are going to create a basic Ubuntu system in order to install only the required GIS programs.
    • Double click Ubuntu in the VirtualBox menu to start the virtual machine; the Ubuntu installation process will start automatically;
    • Select your installation language and press Enter;
    • Press F4 and, using the arrow keys, select Install a command-line system; then press Enter to start the installation;
    • Select your language and press Enter; select your location and press Enter; select Yes in Configure keyboard layout and press Enter; then press the keyboard as requested;
    • In Configure the network type the hostname (for instance Ubuntu);
    • In Set up user and passwords type the user name (for instance user) and the password; choose not to encrypt your home directory; set your time zone and press Enter;
    • In Partition disk select Guided - use entire disk and press Enter; press Enter to select the virtual disk partition; then select Yes to write the changes to the virtual disk; 
    • Press Enter to start the base system installation (it requires an internet connection); 
    • When requested, leave empty the HTTP proxy and press Enter (the installation will continue); after a few minutes the installation is finished;
    • Select Yes to install the GRUB boot loader and press Enter;
    • Select Continue in Finish installation and press Enter; after the virtual machine reboot, login as user (type username and password).

  1. Configure the system and install software
    • Type the following command and press Enter (type the user password when requested):
sudo apt-get install lxde xorg midori --no-install-recommends
    • Type Y and press Enter to start the installation;
    • The option --no-install-recommends allows you not to install recommended programs that are not required, for the purpose of reducing the system size; when the installation is finished, type the following command and press Enter to start the desktop:
startx
    • Now we have a LXDE desktop interface; from the menu LXDE, open a LXTerminal;

Hint: from the menu LXDE, open Midori Web Browser and visit this page, in order to copy and paste the following commands easily.

    • We are going to install several programs that are quite useful; in the terminal type the following command and press Enter (type your user password when requested), confirm the installation and press Enter (it requires an internet connection):
sudo apt-get install leafpad gpicview synaptic lxtask gamin policykit-1-gnome unzip --no-install-recommends
    • Now we need to add the GIS repository; in the terminal type the following command and press Enter:
sudo leafpad /etc/apt/sources.list
    • In the text editor, add the following line to the end of the file; then click File > Save and close the text editor:
deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu precise main
    • We are going to install the GIS programs; in the terminal type the following commands and press Enter (when requested, type Y and press Enter):
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 314DF160
sudo apt-get update
sudo apt-get install qgis
sudo apt-get install otb-bin monteverdi saga python-matplotlib abiword gnumeric --no-install-recommends
    • In the terminal type the following commands (replace user with your username), which ensure that QGIS can access to the user directory:
sudo chown user:user /home/user/.qgis
sudo chmod u+wrx /home/user/.qgis
    • In order to allow for better integration of the virtual machine in the host system we install the VirtualBox guest utils;  type the following command in the terminal and press Enter:
sudo apt-get install virtualbox-guest-utils


  1. Set the automatic login 
    • In the terminal type the following command and press Enter:
sudo leafpad /etc/init/tty1.conf

    • Edit the file tty1.conf and replace the line:
exec /sbin/getty -8 38400 tty1


    • with the following line (replace user with your username):

exec /bin/login -f user < /dev/tty1 > /dev/tty1 2>&1


    • then click File > Save and close the text editor;

    • In the terminal type the following command (replace user with your username) and press Enter:
leafpad /home/user/.bash_profile
    • Edit the file and type:
startx
    • To restart the system, type the following command in the terminal and press Enter:
sudo reboot
    • If you wish to shut down the system, type the following command in the terminal and press Enter:
sudo shutdown -h now

Hint: if you do not want to enter the user password with every command sudo, edit the file /etc/sudoers and replace the lines (this option is not safe for the host system, but it is acceptable for virtual machines):
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
with the following
# Allow members of group sudo to execute any command
%sudo ALL=(ALL) NOPASSWD:ALL

Now, it is possible to run QGIS and configure the Semi-Automatic Classification Plugin, following the guide here.
As you can see in the following screenshot, this virtual machine requires very little hardware resources (76 MB of RAM used with QGIS running), and very little disk space (less than 3 GB); therefore, this virtual machine is ideal for low specs computer.
Also, you can download this virtual machine (the Semi-Automatic OS) from here.


Newer posts Older posts