Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Virtual Machines and Linux

Your computer is one of your most important educational companions. So you want to protect the health of your computer and avoid problems caused by redundant or even malicious software. For this reason, it is recommended to install all software used on this website on a so-called Virtual Machine (VM). This page explains what VMs are, what advantages they have exactly, and how you can install Debian Linux, one of the most stable and secure operating systems. It does not matter if you use Apple’s mac OS or Microsoft’s Windows, or if you already use Linux: The VM will look the same at the end.

About

What is a Virtual Machine (VM)?

A Virtual Machine (VM) represents a virtual operating system (OS) running on a host system that directly runs on a physical computer. The physical computer (hardware) resources of the host system are allocated via so-called hypervisors. For this reason, the virtual machine is referred to as a guest machine and the hypervisor as a host machine. Thus, a guest machine is an isolated, virtualized environment that runs independently on the host operating system.

Why use a VM?

Free resources on a computer represent, from an economic point of view, dead storage space that causes costs without generating income. This is why system administrators often create multiple virtual servers to better allocate physical resources and save energy. A VM is also useful for smart end-users such as researchers and engineers. Here are some advantages of a VM:

In the context of hydro-informatics for water resources management, a VM can serve to execute various Python scripts with different dependencies or, most importantly, to set up a clean and efficient environment for the execution of numerical models such as open TELEMAC-MASCARET.

This tutorial provides guidance on creating a new VM, re-using an existing VM, and working with Debian Linux on a VM.

Contents and Debian Linux

This page guides through the installation of a Debian Linux virtual machine. The host hypervisor is assumed to be Oracle’s VirtualBox on Windows. If you are not using Windows, just download the VirtualBox installer that suits your system. While VirtualBox works x-platform, there are other, more powerful platform specific utilities for creating VMs:

GNOME boxes(Linux)
UTM app (mac / iOS)
sudo apt install gnome-boxes
sudo apt install virt-manager qemu-kvm libvirt-daemon-system

The guest machine will run Debian Linux, which is one of the most stable Linux distributions, and it is freely available. Because of its stability, Debian is an ideal baseline for running numerical simulations that may last for days or even weeks. Of course, there are other options, and Debian is rather one of the best options than the best option.

There are a couple of Debian Linux spin-offs, such as Ubuntu with some other derivatives that are more lightweight (and faster). New Linux users will have an easy start with the Ubuntu variants Linux Mint (Xfce) or Lubuntu. Most versions Ubuntu can be used instead of the Debian Linux presented here to complete the tutorials on this website.

Get prerequisites (required software)

Estimated duration: 5-30 minutes (depends on connection speed).

Remember where the downloaded Linux .ISO file is stored.

Create a VM with VirtualBox

Estimated duration: 5-8 minutes.

In your host system (e.g., Windows 11), click on Start, type Oracle VM VirtualBox, and hit enter. In the opened VirtualBox manager window:

Install Debian Linux

Estimated duration: 30 minutes.

To install Debian Linux to the VM, start the before-created Debian Linux VM in the VirtualBox manager window (click on the Debian Linux VM and then on the green Start arrow). The VirtualBox VM window will ask for the .iso file to use (confirm the selected one), and start navigating through the installation:

Once the VM is shut down, re-open the VM Settings (from VirtualBox Manager window) and go to the Storage tab. Verify that there is again an Empty disk symbol in the Controller: IDE field.

Re-use (Export/Transfer or Copy) a VM on another Host

Once you have created a VM on a virtual hard disk (the *.vdi file), you can always transfer it to another host system with its ecosystem. To copy (or transport) the VM:

Now, the virtual machine should be visible in the list of virtual machines in VirtualBox.

Import an Existing VM in Oracle VM VirtualBox

Instead of creating a new VM from scratch, you can import an existing VM into Oracle VM VirtualBox. This is useful when a VM has already been configured with the required OS, software, settings, and user environment.

Existing VMs are commonly provided in one of the following formats:

The import procedure depends on the file type.

Import a VM Appliance

Make sure that Oracle VM VirtualBox is installed, as described in the VM requirements. Then open VirtualBox and:

After the import, the VM should appear in the list of available VMs in VirtualBox.

Register an Existing Virtual Disk

If the VM is provided as a virtual disk image rather than an appliance, create a new VM and attach the existing disk:

Before starting the VM, check the VM settings and adjust them if needed.

Start and Configure the Imported VM

After importing or registering the VM, start it from the VirtualBox main window. On the first start, check the following items:

For Linux guests, system updates can usually be started from the graphical update manager or from the terminal. For Debian- or Ubuntu-based systems, use:

sudo apt update
sudo apt full-upgrade
sudo apt autoremove

Before using the VM for larger computations or software installations, review the following settings:

A snapshot allows you to return to a previous VM state if an update, installation, or configuration step fails.

Debian Linux

Setup Linux

Estimated duration: 15 minutes.

Start the Debian Linux VM from the VirtualBox manager window. Once Debian Linux has started, log on with your user credentials.

To enable the full functionality of the system, open the Linux Terminal (CTRL + Alt + T or go to Activities > Files (filing cabinet symbol), right-click in any folder and select Open in Terminal). In Terminal type:

su

Enter the above-created password for the root user name (see installation section).

Install all packages required for building kernel modules:

apt update
apt install build-essential dkms linux-headers-$(uname -r)

Find the Devices drop-down menu of the VirtualBox VM window (not in Debian Linux itself) and select Insert Guest Additions CD image... (depending on the version of VirtualBox, this menu can be on the top or the bottom of the window).

Back in the Debian Linux Terminal, mount the Guest Additions iso file by typing in Terminal:

sudo mkdir -p /mnt/cdrom
sudo mount /dev/cdrom /mnt/cdrom

Navigate to the mounted directory and execute the VBoxLinuxAdditions.run file with the --nox11 flag to avoid spawning an xterm window.

cd /mnt/cdrom
sudo sh ./VBoxLinuxAdditions.run --nox11

The kernel modules will be installed now and Terminal should prompt a message that invites you to reboot the system. Do so by typing:

shutdown -r now

After rebooting, make sure that the installation was successful. In Terminal type:

lsmod | grep vboxguest

The installation was successful if the Terminal’s answer is something like vboxguest 358395 2 vboxsf. Read more about Guest Additions on the VirtualBox developer’s website.

To improve the visual experience do the following:

Linux Terminal

Estimated duration: 60 minutes.

To get familiar with Debian Linux, go to the Activities menu and find the applications LibreOffice-Writer, Firefox, the Software application (shopping bag symbol), and the File manager (filing container symbol). Find more applications by clicking on the four dots on the left of the menu bar - can you find the Text Editor? To shutdown Debian Linux (i.e., the VM), click on the top-right corner arrow and press the Power symbol.

The GNOME Terminal is one of the most important features, even though it optically shows only an empty window with a blinking cursor at the beginning. There are many ways to open Terminal and here are two options:

  1. Go to Applications and type Terminal in the search box, or

  2. Open the File browser (Applications > Files - the filing container symbol), navigate to the folder where you want to run Terminal, right-click in the free space, and left-click on Open in Terminal.

Terminal runs many powerful native Linux (UNIX) commands, which is the most robust way to install and execute features. There are a couple of tutorials for learning to use Terminal and one of the most comprehensive is provided on the Linux Ubuntu website (Ubuntu is based on Debian Linux). It is highly recommended to go through the tutorial provided by the Ubuntu community (estimated duration: 51 minutes), for better understanding some contents of this eBook. In particular, memorize the commands cd (change directory), su/sudo (superuser), ls (listen) and mkdir (make directory).

User Rights

When installing software later, it is good practice to install it for your user account and not for root. Such system-relevant actions require superuser (su) rights. However, your default user name is not on the so-called sudoers list, which is essentially a file where all user accounts are listed that are authorized to use sudo in front of any command. So add your user account to the su-doers list by opening Terminal and typing:

su
    password: ...
sudo usermod -aG sudo YOUR-USER-NAME

Open a new Terminal tab (Shift + CTRL + T), which should open up in your default user space with default user rights. Check if your account is on the sudoers list by typing:

sudo -v

If visually nothing happens, you are good to go. Otherwise, if you get a message like Sorry, user [username] may not run sudo on [hostname]., verify that you correctly typed the above command and YOUR-USER-NAME (with correct cases).

VM Settings

Enable Folder Sharing between Host and Guest

Estimated duration: 5-10 minutes.

Sharing data between the host system (e.g., Windows 11) and the guest system (Debian Linux VM) enables the transfer of files to and from the VM to the host system.

share-folder

The shared folder will then be visible in the Files (Activities > Filing cabinet symbol) on the left (e.g., as sf_shared).

A Permission denied message is likely to appear when you click on sf_shared. The message may appear because your user name is not assigned to the vboxsf group. The vboxsf is the one, which is automatically assigned for accessing the shared folder. To verify the group name, go to the shared folder, right-click in the free space, and select Permissions. A window with group names that have access to the shared folder opens. To add your username type (in Terminal):

sudo usermod -aG vboxsf YOUR-USER-NAME

Afterward, reboot the Debian Linux VM and test if you can access the folder, and create and modify files. More information on Permission denied errors is provided in the troubleshooting section on Permission Denied Messages in Linux.


Enable OpenGL

VirtualBox experimentally enables OpenGL, which is used by many graphical user interfaces. To make OpenGL work on a virtual machine, the install X.Org X Window System (xserver):

sudo apt install xorg

Run Xorg as a normal user with:

startx

Or run Xorg as root (superuser) with:

sudo service gdm start

To edit the configuration of Xorg run:

sudo editor /etc/X11/xorg.conf

Add Nvidia repositories and drivers (often not necessary on Debian 12+ because the installer enables non-free-firmware by default):

sudo apt install software-properties-common
sudo add-apt-repository contrib
sudo add-apt-repository non-free
sudo add-apt-repository non-free-firmware
sudo apt update

Then install OpenGL libraries. On a non-Nvidia or generic setup, the GLVND-based packages are:

sudo apt install libopengl0 libglx0 libglvnd0 libgl1-mesa-dri

On a system with the Nvidia proprietary driver installed (replace xxx with the driver series shown by nvidia-detect or Driver Manager, e.g. 550 or 570):

sudo apt install libnvidia-gl-xxx

Software Management

Estimated duration: Variable.

Install Software

To install other software, preferably use the built-in software manager (Activities > Shopping bag symbol). The Software manager uses official releases in the stable Debian repository (read more about lists of sources).

The last command removes files that are not needed anymore and reduces system garbage.

Instructions for installing particular and Debian-compatible software (e.g., QGIS) can be found directly on the website of software developers. For example, to install Anaconda Python visit docs.anaconda.com and follow the installation instructions for Debian Linux.

The most popular software manager of Debian-based Linux distributions is called aptitude, which is the thing that you invoke when typing [sudo] apt [something]. There are more standard package managers, such as dpkg or synaptic (see the full list in the Debian package management faqs). To install a wide range of proprietary software (e.g., video conferencing tools), package management tools like snapd or flatpak can be useful. However, such third-party package managers are debated, and a more robust approach is to use apt whenever possible, or, if the software is not available through apt, look for AppImages.

Useful Software

System Monitoring

There are multiple options to monitor system resource of a Debian distro, and this section presents two of them, namely, htop and stacer. htop is a minimalistic tool that runs in Terminal. stacer is a graphical user interface providing more options, including optimization of battery life or system performance.

To install htop for visualizing CPU usage, type:

sudo apt update
sudo apt install htop

Start htop’s CPU monitor with:

htop

To install the more general stacer tool, type:

sudo apt update
sudo apt install stacer

After the installation, stacer can be opened from the system menu (search for stacer).

Add Package Repositories

For adding (trusted) software (package) repositories use software-properties-common, which provides the add-apt-repository command:

sudo apt install software-properties-common
sudo add-apt-repository contrib
sudo add-apt-repository non-free
sudo add-apt-repository non-free-firmware
sudo apt update

Find Packages

Some software will run into errors because of missing library files (e.g., libGLX.so.0: No such file or directory). To find out what package needs to be installed for getting the missing library file, install apt-file

sudo apt install apt-file
sudo apt-file update

To find out the package name of a missing library file (e.g., libGLX.so.0), tap:

apt-file find libGLX.so.0

After a couple of seconds of searching, apt-file will prompt something like:

libglx0-glvnd-nvidia: /usr/lib/x86_64-linux-gnu/libGLX.so.0

That means, to get the library file libGLX.so.0, the package libglx0-glvnd-nvidia must be installed; for instance:

sudo apt install libglx0-glvnd-nvidia

Update Software

To update repositories and upgrade installed packages through apt, that is the standard Debian package manager aptitude, open Terminal and type:

sudo apt update
sudo apt full-upgrade
sudo apt autoremove
sudo apt autoclean

This will not update manually installed software, and packages installed through snapd and flatpak.

Windows Apps on Linux

Estimated duration: 10-15 minutes.

The Wine application provides a Windows-like environment on Linux systems, which enables installing and running Windows applications. Wine can be either used through the convenient sandboxes like Bottles or directly installed on your Linux system.

Bottles (flatpak)
Lutris
Steam Proton
PlayOnLinux
Wine (Direct Installation)

Bottles is a powerful tool that provides isolated sandboxes for running Windows software, even if your system’s wine installation is buggy. To install Bottles (via Flatpak - recommended) including relevant Vulkan libraries, fire up Terminal and tap:

flatpak install flathub com.usebottles.bottles
flatpak install flathub com.obsproject.Studio.Plugin.OBSVkCapture
flatpak install flathub org.freedesktop.Platform.VulkanLayer.MangoHud
flatpak install flathub org.freedesktop.Platform.VulkanLayer.vkBasalt
flatpak install flathub org.freedesktop.Platform.VulkanLayer.gamescope

Then run bottles:

flatpak run com.usebottles.bottles

Test with relevant software for numerical simulation (e.g., BlueKenue and HEC-RAS):

  1. Create a folder for Windows installers, like ~/installers/WindowsSoftware/

  2. Create a new Bottle: Open Bottles > Click + New Bottle > Choose:

    • Environment: Application

    • Name: HydroSoftware

    • Keep it 64-bit

  3. Install core dependencies before you do anything else:

  • Core fonts: allfonts

  • .NET framework: dotnet472 (for HEC-RAS - installation may take a while)

  • Visual C++ 2013 and 2015-2022 Redistributables (x64): vcredist2022 and vcredist2012

  1. Go back to the bottle and open the Settings of the bottle:

  • In the Components section, make sure the Runner (soda), DXVK, VKD3D, and DXVK NVAPI are enabled; LatencyFleX can be enabled, but no need for it; if things are buggy later, try switching off DXVK (and therefore VKD3D, too)

  • In the Display section, enable Discrete Graphics

  • In the Display section > Advanced Settings, disable Virtual Desktop (for stability); only enable Fullscreen Mouse Capture, Mouse Warp, and Window Manager Decorations; you may want to switch the Renderer -- this setting had no influence in our testing but GDI is said to perform best and stablest

  • In the Performance section, disable everything

  • In the Compatibility section, make sure Windows 10 in set (11 was still buggy during testing) and everything else is disabled

  • In the Snapshots section, disable everything

  1. Download relevant installers:

  • For BlueKenue, get the latest installer as described in the Telemac Forum and save it in ~/installers/WindowsSoftware/

  • For HEC-RAS, go to the HEC-RAS download page and download and installer into ~/installers/WindowsSoftware/; note: in our testing, we only succeeded with running HEC-RAS 5.0.7 (or earlier) -- newer versions sooner or later caused errors

  1. Install software inside the bottle

  • Open the bottle > Run Executable

  • Select the downloaded BlueKenue or HEC-RAS installer from ~installers/WindowsSoftware/

  • Install path: default is OK (e.g., C:\Program Files\HEC\...)

  • Finish installers

  1. Launch software:

  • After successful installation, new software should occur in the Bottle’s Programs section

  • If not, scroll down to the Tools section, expand Legacy Wine Tools, and click on Explorer to navigate through the sandbox system