Setting up a virtual machine on your personal computer

What is a virtual machine?

A virtual machine (VM) is in some ways a simulation of a physical machine. You will need special software to run a VM on your personal computer. To run a VM, you can use either VMware Player (VMware Fusion on Mac) or Virtual Box, although we suggest the former.

Please follow the instructions for your platform.

Installing VMware Player

On Windows

Go to http://www.vmware.com/products/player/ and click on 'Download'. Follow the instructions to register with VMware, activate your account, and bring up the download page. Click on the 'Download' button that corresponds to 'VMware Player 3.1.3 for 32-bit and 64-bit Windows'. When the download completes, run the executable, and follow instructions to install VMware Player on your machine. Restart Windows to complete the installation, as instructed.

Proceed to downloading the VM.

On Linux

Go to http://www.vmware.com/products/player/ and click on 'Download'. Follow the instructions to register with VMware, activate your account, and bring up the download page. Click on the 'Download' button that corresponds to 'VMware Player 3.1.3 for 32-bit Linux' or 'VMware Player 3.1.3 for 64-bit Linux', depending on which version of version of Linux you're running. When the download completes, open up a command prompt and cd to the directory containing the downloaded bundle. This bundle is actually a bash script, so you can execute it by running sudo bash VMware-Player-3.1.3-324285.i386.bundle

Note that you will need root access to complete the installation.

Follow instructions to complete the installation of VMware Player on your machine.

Proceed to downloading the VM.

On Mac OS X

VMware Player is not available for Mac OS X. Instead, VMware Fusion can be used to run VMs on a Mac. Although Fusion is not free software, you can get a free copy you can use for the course. Follow these directions:

  1. Go to Stanford Software Licensing
  2. Click on the "Click Here To Start Shopping"
  3. Click on "More Software" and scroll to bottom
  4. Click on "VMWare Fusion 4 (for Mac OS X)"
  5. Click "Add to Cart"
  6. Enter your SUNet ID and then click "Check Out" to complete the purchase

Note that at the end of the download (on your order summary page) you will get a serial number that you will need to enter after installation.

Proceed to downloading the VM.

Using VirtualBox

If you're set on avoiding VMware products, you can try VirtualBox. We aren't as familiar with it, so you'll pretty much be on your own. You can download VirtualBox binaries here.

Once you are done installing VirtualBox, follow the steps below to boot up your virtual machine. These steps are only tested to work on Mac.

  1. Run VirtualBox and click the "New" button on the top right corner.
  2. Press "Continue" once.
  3. On the "VM Name and OS Type" window, enter a name as you want and select Linux Ubuntu as OS Type. Continue.
  4. Default memory should be enough. Continue.
  5. Select "Use existing hard disk" and select CS110-Ubuntu.vmdk. Look at downloading the VM for how to download the virtual machine. Continue.
  6. Now, you're done! Just start the virtual machine you created.
Now, you're ready to proceed to Developing Locally on the VM.

Downloading the VM

Now that you've installed software that can run VMs, you need an actual VM to run. As such, you need to download the VM from the course page. Note that the downloaded file is actually an archive (.zip) file, so you will need to unzip this file to extract the VM materials from it. This should be straightforward on Mac, Linux, and Windows machines. Unzipping the file should yield a directory containing the VM. Make sure this directory is placed in a safe place on your computer (where you would not accidentally delete it). You are now ready to boot up the VM.

Booting up the VM

Run VMware Player. If your computer is running Windows, the installer will have placed a shortcut either on your Desktop or in the Programs menu. If your computer is running Ubuntu, then the installer will have placed a shortcut under Applications->System Tools. Accept the EULA (you have no choice — bwahaha). When VMware Player comes up, click on 'Open a Virtual Machine'. Navigate to the directory ("CS110-Ubuntu") that contains the VM and select the .vmx file in that directory. Lastly, click on "Play virtual machine". Your VM should now boot into Ubuntu (a distribution of Linux). The default username in this installation of Ubuntu is 'cs110'.

You are almost there! You just need to get the starter code onto your VM so you can actually work on the assignments.

Developing Locally on the VM

A note on AFS

In previous quarters, we recommended that students link their AFS directory to the VM. (If you've never heard of AFS, we're referring to the networked filesystem on which your Stanford home directory and the /usr/class/cs110 directory, among other things, are stored. Don't worry about the details.) Many students have experienced poor performance using AFS inside the VM. We haven't been able to diagnose or fix these problems, so we now recommend that you avoid AFS altogether.

To develop locally, you'll need to download the starter code to your VM. To properly run and test your code, you'll also need to download the test disks for each assignment (except assignment 2, which has no test disks). These instructions were written for assignment 1, but they should apply equally well to the other assignments.

Getting the Starter Code

To get the starter code, you'll have to download the appropriate archive from the course website. Each assignment's archive can be found in that assignment's directory:

/usr/class/cs110/assn[#]/assn[#].tar.gz

Perform the following actions in a terminal in the VM.

  1. Create and cd to a directory where you'd like to store the CS110 assignments (e.g., ~/cs110).
  2. Download the archive: wget http://www.stanford.edu/class/cs110/assn1/assn1.tar.gz
  3. Unarchive the assignment: tar -xzf assn1.tar.gz

Using the Test Disks Locally

There are no test disks for assignment 2; this step does not apply to that assignment.

To be able to run and test your code on the VM, you'll have to copy the testdisks folder over to the VM. The test disks for each assignment can be found in that assignment's directory: /usr/class/cs110/assn[#]/testdisks.tar.gz Perform the following actions in a terminal in the VM.

  1. cd to the assignment directory (e.g., readfiles for assignment 1).
  2. Download the testdisks archive (Note that the assignments do not all use the same test disks. Make sure you use the assignment 1 test disks when working on assignment 1, and so on.): wget http://www.stanford.edu/class/cs110/assn1/testdisks.tar.gz
  3. Unarchive the testdisks folder: tar -xzf testdisks.tar.gz

You're done!

You have successfully configured your own VM that you can use for all of the assignments in this class. Note that, in contrast to developing on the cluster machines, your materials are stored locally on the VM. Although you're not relying on network connectivity and can work on the assignments offline, you're also left to your own devices with respect to data availability and backup. If you're not regularly backing up your machine's hard drive, we at least recommend periodically saving your code somewhere (copied to one of the cluster machines, a flash drive, etc.). We won't have mercy for accidental deletion of your source code.

Submitting from the VM

To submit from the VM, you'll have to make a tarball (a .tar.gz archive) with all your work. Since this can get complicated, we put together a script to take care of this work for you. Here's how to submit from the VM:

  1. cd to the assignment directory (e.g., readfiles for assignment 1).
  2. Download the script: wget http://www.stanford.edu/class/cs110/scripts/make_tarball.sh
  3. Make the script executable: chmod +x ./make_tarball.sh
  4. Run the script: ./make_tarball.sh num
  5. where num is the assignment number (1 through 4).
  6. The result will be a timestamped tarball in the readfiles directory. Now open Firefox inside the VM, go to the submission page and submit this tarball.
You haven't submitted your assignment until you go to the submission page and upload your tarball! Make sure that you submit the timestamped tarball you created with the make_tarball.sh script and not the tarball that you originally downloaded when you started the assignment.

You can check the status of all submissions you have made this quarter on this page.