You are here: Home / ECPE 170 / Tutorials / Virtual Machine Setup

Virtual Machine Setup

Overview

All labs and programming projects in this course will be done on Linux, in order to prepare you for future CS courses (and employers) that use a diversity of computing systems. Your first assignment in class is to build your own Linux system.  The standard method in this class is to use a virtual machine on top of your native OS.   Other options, like dual-booting, are available to you if desired. 

To run a virtual machine, you will need to install a virtual machine manager onto your computer.

Enable Virtualization Extensions

In order for your computer to properly run guest operating systems with reasonable performance, some hardware features of your CPU need to be enabled. For Intel processors, these features are called "VT-X", and for AMD processors, they are called AMD-V. It's hit or miss whether these features are enabled by default on consumer computers - in prior classes about 25% of students had to enable them manually.

If you have a Mac: Congratulations, any modern Intel-based Mac should already have VT-x enabled. If you wish to verify this out of an abundance of caution, launch the Terminal app and run the following command, and look for VMX in the output:

$ sysctl -a | grep machdep.cpu.features    ## Look for "VMX" to appear

If you have a Windows 10 PC: Run the Task Manager program. In the Performance tab, look for a line labeled "Virtualization", and confirm that it says enabled. Look here for an example of the desired output along with some alternate methods of confirming CPU virtualization extensions are enabled.

If virtualization extensions are not enabled, you will need to enable them before continuing. The location of the specific button is not in Windows, however. It's buried deep in the BIOS or UEFI software that runs immediately after your computer is powered on, before Windows even starts. The step-by-step process to enable this option is unfortunately very computer dependent. Typically the process involves restarting your computer and immediately starting to repeatedly press the F2 key. Or F10. Or DEL. The correct key varies by vendor. You might see a quick message "Press <some key> to enter Setup" flash very briefly on the screen. Or, you might need to do a search for "Access BIOS" followed by your specific computer make and model. Once you are in the BIOS, you can navigate using the arrow keys (or newer UEFI systems allow you to use the mouse). Navigate through the settings looking for a "Virtualization Extensions" (or similar) option that you can change from Disabled to Enabled. If you can't find anything, you might need to search for instructions for your specific model of computer. Save the BIOS settings (via the keyboard shortcut listed at the bottom of the screen), let the computer reboot, and then check if Windows says that Virtualization is enabled now.

Choose a Virtual Machine Manager

First, download the appropriate software for your computer. You have a few choices here:

 Paid products - RECOMMENDED CHOICE

Free products

 

Second, install it! (Accepting the default options is generally reasonable)

Virtualization Setup FAQs

Which is better - VMware or VirtualBox?

In previous classes, the VMware products typically work more smoothly out of the box. But, the free VirtualBox product can always be setup correctly, it just might take some additional effort. Both are supported methods in this course.

I have an older software version than what is listed above - can I use it?

Using an older virtual machine manger is highly discouraged. These are complex programs that are regularly updated to (a) improve compatibility with their host operating systems, (b) improve compatibility with the guest/virtual operating systems being created, and (c) fix security vulnerabilities that would allow a malicious guest OS to break out into the host OS. These should all be important to you as security professionals, particularly the point about vulnerabilities! Update your virtual machine manager regularly, even if it means giving VMware more money...

 

Linux Virtual Machine for ECPE 170

There are many different variants of Linux available, called "distributions". Examples include "RedHat", "Ubuntu", "Debian", "Mint", "openSUSE", and many others. While the core operating system functionality (the "kernel") remains the same, each distribution bundles the kernel with a different mix of software.

The chosen Linux distribution for ECPE 170 is:  
Ubuntu 20.04 Long-Term Support (LTS) 64-bit edition, released August 2020. 

Do you have a different favorite Linux distribution? All of the projects use an extremely common set of tools, and thus should work across any and all Linux distributions of a recent vintage. You are more than welcome to use any distribution you see fit, but be warned that you are responsible for fixing any problems that arise!

Download the .iso (disk image) file containing the installer for Ubuntu Linux, version 20.04 LTS, 64-bit edition (there's no need to be bleeding-edge in this class, and the slightly older "Long Term Support" version works better in a virtual machine)

 Then, launch your Virtual Machine Manager (e.g. VMware Workstation or VMware Fusion). Point the graphical wizard to the installer .iso file for Linux, accept the "EZ Install" option, and then specify that you want your virtual machine to be allocated 4GB of RAM, 20GB of disk space, and 2 CPU cores.  And let the installer run! 

 Here are some sample screen snapshots from Ubuntu 20.04 as I worked my way through the installer on my laptop using VMWare Fusion on Mac and the "EZ Install" option to skip over some generic Ubuntu screens (where I would have just accepted the default choices anyway).


Application Installation

In Ubuntu, login and launch the command prompt (aka Terminal). The keyboard shortcut is <CTRL><ALT><T>. Or, you can search for "Terminal" by clicking on the App button in the bottom-left corner (i.e., the Ubuntu equivalent of the Windows "start" button).

For the rest of this course, commands to enter at the terminal are going to be given in the following format:

unix>  This is the command that you should enter

The "unix>" part of the line should not be typed in, and it will not look the same on your computer. Rather, it might look something like this:  username@computername:/current-directory$, i.e. a combination of your username, computer name, and the current directory you are in.  Thus, it will be constantly changing as you work!  To simplify tutorials, this is written as unix>

 

 

The following commands refer to installing software on the computer.  Let's break these commands apart:

  • sudo:  sudo allows you (a regular user) to run a command as an Administrative ("root") user by typing your password. Everything that comes after sudo is the command to run as an Administrative user. Administrative access is required to install software.
  • apt:  apt-get is a utility that can add or remove software programs.  Anything that comes after apt changes the behavior of this utility: Are we installing or removing software? What specific software?

 

Update all programs on the system to the latest versions. The 'update' commands gets the list of latest programs, and the 'upgrade' command downloads and installs them. There may be a lot of files to download!

unix>  sudo apt update
(Enter your password so that sudo can run the command as root / Administrator)
unix>  sudo apt upgrade 
(Type Y for YES when prompted to begin installation)
unix> sudo reboot 

When the virtual machine finishes rebooting, launch the command prompt again via CTRL-ALT-T.

Install some software that we will use later in the semester:

  • git is a version control system
  • strace is a utility that intercepts and logs calls that applications make into the operating system
  • valgrind is a utility that monitors program memory usage and looks for leaks and other bugs
  • kcachegrind is a GUI display utility for valgrind traces
  • ttf-mscorefonts-installer includes some Microsoft fonts frequently used
  • python3-matplotlib installs a Python-based math / graphing engine
  • ghex is a file viewer (at the byte level)
  • g++ is a C++ compiler
  • iotop is a monitor for disk activity
  • gedit is a text editor. It comes with Ubuntu, but I include it here for anyone running a different Linux distribution.
  • libreoffice is a Office suite (similar to Microsoft office).  It comes with Ubuntu, but I include it here for anyone running a different Linux distribution.
  • make is a utility to automate program compilation
  • eog (Eye of GNOME) is an image viewer
unix> sudo apt install git strace valgrind kcachegrind eog 
unix> sudo apt install ttf-mscorefonts-installer python3-matplotlib ghex iotop
unix> sudo apt install g++ gcc make gedit libreoffice

Note: For the font package, use the <TAB> key and <ARROW> keys to accept the EULA license terms when prompted.

On the assumption that 95% of the class will use the GEdit text editor, make three changes to the editor preferences:

  • Disable automatic backup files (because this will litter your directory with backup copies of files where the filename ends in a tilde (~) character).
  • Enable line numbers to simplify program debugging later.
  • Enable auto-indenting (to preserve the current level of indenting).

(These could also be set via the GUI preferences inside of GEdit, but what fun would that be?)

unix>  gsettings set org.gnome.gedit.preferences.editor create-backup-copy false
unix> gsettings set org.gnome.gedit.preferences.editor display-line-numbers true
unix> gsettings set org.gnome.gedit.preferences.editor auto-indent true 

 

Test your virtual machine: Can you copy and paste between your normal OS and Linux?  (i.e. can you copy one of the commands above and paste it into the Linux Terminal?)   Can you resize the virtual machine window or set Linux to full-screen mode, and have the guest OS resize to take up the new available space?

  • If Yes: Your virtual machine is ready for use. Enjoy!
  • If No: See Troubleshooting Tips below

 

Troubleshooting Tips for VMWare Player / Fusion

The "EZ Install" option should have already installed the necessary drivers/tools for VMWare Player or Fusion to improve the performance and integration of your new virtual machine.  But, if you have problems, you can try installing the open-source version of the tools manually.

unix>  sudo apt install open-vm-tools open-vm-tools-desktop
(Enter your password so that sudo can run the command as root / Administrator) 
(Type Y for YES when prompted to begin installation)
unix> sudo reboot

 

Or, as a fall-back position, you could try manually re-installing the VMWare-provided tools:

  • Find the tools installer:
    • For Player: Click on Player->Manage->Reinstall VMWare Tools...
    • For Fusion: Look for a similar menu option to Reinstall VMWare Tools.
  • You should see a folder appear in Linux with a file: VMWareTools-######.tar.gz
  • Right-click on that .tar.gz compressed archive file and choose "Extract To...".  Select the Desktop as the destination and click Extract.
  • Open the Terminal via CTRL-ALT-T
  • We want to run the script vmware-install.pl in the folder you just created as the root (Administrator) user.  Use the following command:
unix>  sudo ~/Desktop/vmware-tools-distrib/vmware-install.pl
(Enter your password so that sudo can run the command as Administrator) 

Just keep hitting ENTER until it finishes.  All the default choices should be safe.

 

Do the graphics look "funny" after you log into Ubuntu?  (Missing/blurred menu bar at top and program icons on the right?)  It may be that the graphics card or driver on your computer is not fully compatible with GPU acceleration. Fortunately, that feature can be disabled.

  • Shut down the virtual machine
  • In VMWare Player, right-click on your virtual machine and choose "Virtual Machine Settings"
  • Select "Display"
  • Make sure the "Accelerate 3D Graphics" is NOT checked.
  • Select "OK".
  • Launch your virtual machine again. Do the menu bar and program icons appear now?

 

Does the network in the host OS work, but networking in the guest OS is broken?  Can you ping to an IP address (8.8.8.8) but can't ping to a hostname? (google.com).  This weird error has affected a small subset of students in the past. Try specifying a fixed DNS server to use instead of relying on DHCP autoconfiguration.  Google Public DNS is a good choice that will work both on and off campus.  Use the GUI to specify DNS servers of 8.8.8.8 and 8.8.4.4.

 

Is there no networking at all in the guest OS? (Does "ip link" show that the Ethernet link is down?).  Here are some troubleshooting tips:

  1. Shutdown and start (or restart) Ubuntu. Don’t just suspend/resume it
  2. Restart Windows/Mac
  3. Check in VMware and install any updates available (and restart Ubuntu afterwards)
  4. [For Windows VMware Workstation Pro only]: Go to Edit->Virtual Network Settings. Click “Change Settings” and then “Restore Defaults”.   Restart OS and try again.

 

You can also try to force the network to an active state.

sudo ip link                 # Check the ensXX link - is it down?  Note its exact name
sudo ip link set ensXX up # Force it to run
sudo ip link # Is the link running now?
sudo dhclient ensXX # Force the network interface to obtain an IP address
sudo ip addr # Do you see an IP address on the interface now?
ping google.com # Can you ping google? Should see packets transmitted/received.
# CTRL-C to stop pinging

 

Troubleshooting Hardware Virtualization

 

In the event of BIOS updates, the hardware virtualization may be disabled. This may interfere with your Workstation/VirtualBox. The solution is simple: enable hardware virtualization.

 

Troubleshooting Tips for VirtualBox

Manually install drivers/tools for VirtualBox. These improve the performance and integration of your new virtual machine.

unix>  sudo apt install virtualbox-guest-dkms
(Enter your password so that sudo can run the command as Administrator)
(Type Y for YES when prompted to begin installation)
unix> sudo reboot 

Also, ensure that "Shared Clipboard" is enabled. Go to Settings (for your specific virtual machine) -> General -> Advanced -> Shared Clipboard and set it to Bidirectional.