This guide walks through the process of setting up VirtualBox for CS 5007.
Step 0: What is VirtualBox? Why do I need to do this?
All the students in this class have laptops and/or computers, but not
everyone has the same setup. We use what's called a "Virtual Machine"
to ensure that everyone has the same computing experience, and that it
matches that of a Linux machine that has the capabilities we need for the course.
With these virtual machine instructions, you can all have the same experience on your own machine.
Virtual machines (https://en.wikipedia.org/wiki/Virtual_machine)
are emulated computer instances running inside a special program
you install on your desktop or laptop computer (which we call the host machine). The virtual machine
can run a completely different operating system than its host - for example,
you could run a Linux or a Windows 10 virtual machine on your Macintosh laptop,
or a Linux virtual machine on your Windows machine.
How Does It Work?
Virtual machines run inside some other program. There are numerous applications,
on most platforms, that fulfill this need. The instructions here are for VirtualBox.
We'll evaluate your assignments and provide code using VirtualBox, but other options
are available-- in particular, VMWare is a good option if VirtualBox is not working for you.
If you have any issues with installing and running VirtualBox, reach out to course staff for help.
Set the memory to 4096 MB. If VirtualBox complains, set this amount to 2048.
Specify that you want to create a virtual hard disk.
Change the file size to 32 GB.
(click Create)
(click Save)
Now, the machine is created.
Start it up and we’ll configure the machine. For now, do a “Normal Start”.
The image below shows that it's pointing at the ubuntu image. Click the folder
and select the ubuntu file you downloaded in Step 1 (probably in the
Downloads directory)
Download updates while installing
Erase disk and install Ubuntu
Continue, etc.
When you get to the point where you create a username, make your password easy.
This won’t be open to anyone to log into; easy is good.
You can also select "log in automatically"
When the box restarts, it might say "remove installation medium and press enter".
That's okay, just press enter.
Step 4: Set up the new box
Now,
Click the little button (upper left hand corner) and search for “terminal” to launch the terminal.
At the command line, enter the following commands to install the important tools:
Enable Copy/Paste from the host machine (your laptop) and the guest machine (the virtual machine you just created):
Shutdown your machine with Cmd + Q or Ctrl + Q (quit).
(You can choose "Save Machine State")
In the VirtualBox console, right-click your virtual machine and select Settings
Select General at the top, and then the Advanced tab.
Where is says "Shared Clipboard", select "Bidirectional", then click okay.
Start the virtual machine.
When it starts, go to the Devices menu.
Select "Insert Guest Additions CD..."
Follow the instructions
Restart the machine
To paste into ubuntu, use Ctrl + Shift + V
To paste into Emacs use Ctrl + y (to "yank" stuff from the
clipboard).
To copy in Ubuntu, use Ctrl + Shift + C.
Step 5: Run some code to check it all out
Now, you can try re-creating HelloWorld from class to ensure everything works.
At the command line:
mkdir cs5007
cd cs5007
mkdir lect1
cd lect1
emacs helloworld.c &
copy/paste:
#include <stdio.h>
int main(){
printf(“\nHello World!\n”);
return 0;
}
Ctrl-X Ctrl-S to save it
Back at the terminal:
gcc helloworld.c
./a.out
Step 6: [Optional] Run VirtualBox in headless mode and ssh into it
The VirtualBox UI can be pretty slow and cumbersome. You can use the
VirtualBox OS by running it in headless mode, sshing into it, and working
on the command line.
Open VirtualBox, right-click on the VM, and choose settings. Then choose Network.
Create a new Network Adapter.
Start the machine normally.
Open a terminal on the machine, and enter ifconfig. In the image below, my IP address is 192.168.56.101. I'm looking for the entry that says "link encap:Ethernet", then the inet address.(We'll learn what that all means later in the semester).
Go to your terminal on the host machine. Open a terminal,
and type ssh adrienne@192.168.56.101. BUT, use YOUR
username and the IP address from your machine. You'll be asked for
your password (which is your password for your username on the
VirtualBox machine). Enter it.
AT this point, you're on the virtual machine. You can do things like
use emacs, vi, gcc, etc., but you can't use the programs
you have on your host machine (like, Sublime).
When you're done, logout will get you out of the virtual machine.