In this post, I’ll talk about how to set up a virtual machine on a PC, in order to run outdated software that may have been optimized for a different version of Windows. For example, a collaborator of mine uses the EPA Water Treatment Plant model which only seems to work under 32-bit versions of the operating system.
Setting up a Virtual Machine [VM] for Remote Code Development
Many times you’ll be asked to develop applications on remote machines. Generally these machines are running some flavor of Linux or Unix (*nix systems). Often, this can be quite complicated for those who are unfamiliar with using command lines or the “vi” editor. This guide will get you started using a virtual machine to run a Linux operating system on your Window’s PC, and will help alleviate some of the headache associated with remote development.
I’m suggesting the use of a VM for remote development as opposed to separate SSH and X-Server forwarding software such as Cygwin because the VM gives you access to a lot of the software and features of the remote machines on your local machine. Even things like LaTeX become readily available. I’m suggesting setting up a local development area because once you’ve “cut your chops” on remote development, you’ll appreciate being able to rapidly develop code locally and then push updates to the remote machines for ‘production’ runs.
This guide will help you get up an running with the VirtualBox VM, with a version of CentOS (a popular flavor of Linux). CentOS comes with software packages which are directed at software development, such as Eclipse, and contains features available on large cluster systems. You’ll even be able to install openmpi, and be able to program and test parallel applications, if you so choose.
VirtualBox is a pretty well-supported, open-source piece of software. The homepage is located at www.virtualbox.org, and contains links to installers as well as users guides and documentation. You’ll need to download the Host Software as well as a Guest OS. The Host software, (VirtualBox) runs the virtual machine (the Guest). Just like a standalone computer, you’ll need an OS to run on the Guest. Here’s a quick link to their download page:
You’ll want to head over there and download the latest version of VirtualBox for Windows Hosts (x86/amd64). This is the VM software that will manage your virtual machines. At the time of this writing, VirtualBox is at version 4.1.8. They have a pretty solid install guide in their manual, located here:
Go ahead and install VirtualBox, and configure a new virtual machine. A good video guide (though slightly dated) is provided below. When they get to the step where they determine the size of the hard drive, they use dynamically-sized storage. You’ll want to change it to fixed-size; around 20 gigabytes or more if you can handle it. Our settings will be for Red Hat (the core Linux within CentOS). We’ll get to installing an OS on the virtual machine shortly.
Installing an OS to the VM
Congratulations! You now have a computer running within a computer. This is where things may become complicated if you’ve never installed an OS before. It’s become much easier than in the past, and there’s a pretty good video posted on YouTube with an example walkthrough. You’ll want to make sure your computer is connected to the internet before you start the install. Virtualbox will automatically connect to the net, and the OS installation will grab some packages from the net if you tell it to. Around 3:15 in the video, you’ll see an example of the package selection screen. You’ll want to select the “Software Development Workstation” option.
Installing Additional Software: VirtualBox Guest Addons
Now that the OS is up and running, you want to be able to fully use all the fancy features and graphics packages of VirtualBox to maximize its performance and ease of use. This is done through the VirtualBox Guest Addons. It will allow you to “fullscreen” the VM, as well as some other nifty tricks. Technically this is optional, but it really should be required. A walkthrough is provided byVirtualBox, and can be found here:
Simply follow the provided instructions for Guest Additions for Linux. Since we’ve installed CentOS, we’re using a variant of Red Hat Enterprise Linux (RHEL), so scroll to the specific instructions for CentOS, Red Hat Enterprise Linux and Oracle Enterprise Linux. A video walkthrough is provided below:
Configuring Remote Display
This is where things get easy. Since you’re running Linux in the VM, you’re basically already set up to push GUIs and windows back to your local machine from the remote one. All it takes is the command:
ssh -Y <username>@<remote-system>
The -Y option for ssh allows the remote system to forward X11 data (GUIs, windows) back to your machine. Pretty easy, right? Log in to a machine and type xterm to push a remote terminal window back through your ssh connection to test it.
First, I’d like to note that a virtual machine is useful for running multiple OS for various reasons, however you take a hit to performance due to the virtualization layer. Most modern computers are multi-core, which allows your primary OS to offload the virtualization to one core, and run calculations with the other. This alleviates some of the performance hits, but does not remove it completely. Some newer Intel systems can use specialized hardware to improve performance and even use the 64-bit (x86_64) versions of OS. Such optimizations are beyond the scope of this guide, but if there’s enough demand I’ll write a more in-depth version including it.
Installing Additional (Optional) Software: Netbeans
While the Software Development Package comes with an Integrated Development Environment (IDE) called Eclipse, my personal IDE-du-jour is Netbeans. Eclipse is more versatile when it comes to languages, but if you’re a C/C++ developer, Netbeans is also pretty convenient. It is a little simpler to configure for remote development, and is easier to switch between local and remote. If you wish to familiarize yourself with Eclipse, a good resource can be found here and at the Eclipse website, here.
From inside your remote machine, head over to netbeans.org and download the install script for the “All” version. Remember where you download it, as you’ll have to navigate to the script on the command line. Installation instructions can be found here, but remember to perform these commands as “su” using the sudo command:
sudo chmod +x <installer file name> sudo ./<installer file name>
During the installation, agree to the licenses, and if you’d like feel free to install the Glassfish server and Apache Tomcat packages. If you don’t know what they are, you probably don’t need them, unless you’re deep into open-source development and web environments for Java.
Once installed, you’ll be able to find the software in the Applications->Programming menu.
Installing Additional (Optional) Software: OpenMPI
You can do this one of two ways: through the Add Software GUI, just search for openmpi and it’ll come up in the list of packages.
or on the command line, by running:
sudo yum install openmpi openmpi-devel