Headless VM setup guide
1. Download the latest version of VirtualBox (https://www.virtualbox.org/wiki/Downloads). NOTE: Even if you have VirtualBox already installed, it's important that you follow this step, as there was recently a major version release that changed the interface.
2. From the same page, download the VirtualBox Extension Pack.
3. Install VirtualBox, then double-click on the Extension Pack, and VirtualBox will prompt you to install it.
4. Open VirtualBox, click the menu across from "Tools", and select "Network".
5. Click "Create" in the top left, and verify that the new network is called vboxnet0
, and that the IP is 192.168.56.1/24
.
6. Download the UChicago CS VM (https://howto.cs.uchicago.edu/vm:index). This is a fairly large download - should take about 10 minutes on the UChicago network.
7. In VirtualBox, choose File → Import Appliance, and then find and select the .ova file you downloaded in step 6. You can leave all the options at their defaults.
8. Right click on the VM's entry in the VirtualBox sidebar, and click "Settings…"
9. Under "Network" → "Adapter 2", select "Enable Network Adapter". Then, select "Host-only Adapter" for the "Attached to" field, and make sure that "vboxnet0" is selected for the "Name" field.
10. Since you will be running this VM in headless mode, we will be setting up a *shared folder* on your computer that you will be able to access from inside the VM. Select a directory on your computer for this purpose; we will refer to it as SHARED_DIR
from this point onwards.
In VM's setting, under "Shared Folders", click the blue folder icon with the green plus icon on the right hand side. Under "Folder Path" select "Other", navigate to SHARED_DIR
, and click "Open" in the bottom right. For "Folder Name", enter the name vbox-shared
. Then, select "Make Permanent" (if available - it sometimes doesn't show up, that's okay too) and click "OK", and then "OK" again.
11. Start the VM and log in. The password is uccs
.
12. In the VM, launch a terminal and run the following commands:
$ sudo adduser student vboxsf $ sudo apt-get update $ sudo apt-get -y install openssh-server
Next, run ifconfig
. Look for the entry that says inet addr:192.168.56.101
. Note down the device name (it should be something like enp0s8
). Then, run the following command:
$ nmcli con show
Find the interface name corresponding to the device name you found above. It should be something like Wired connection 1
. Then run:
$ nmcli con mod "INTERFACE_NAME_HERE" ipv4.method "manual" ipv4.addresses "192.168.56.101/24"
13. Run the following command:
$ sudo nano /etc/fstab
This will open up your system's volume mounting configuration. At the bottom of the file, add the following line:
vbox-shared /media/vbox-shared vboxsf gid=1000,uid=1000
Then, to quit nano, press Ctrl+x
, then press y
, then press Enter
.
14. Shut down the VM (click the gear icon in the top right, and click "Shut Down").
15. Launch a terminal on your local machine (i.e. not inside the VM). Run the following commands:
$ mkdir -p ~/.ssh $ nano ~/.ssh/config
The last command there will open up your SSH configuration file. Add the following lines to that file:
Host cs-vm User student HostName 192.168.56.101
Then, to quit nano, press Ctrl+x
, then press y
, then press Enter
.
16. In VirtualBox, right click on the VM and choose "Start" → "Headless Start".
17. Wait ~15s for the VM to start up fully. Then, in a terminal on your local machine, run:
$ ssh cs-vm
18. Once you're logged in, you'll see the prompt change to something like student@cs-vm:~$
. Then, run the following commands:
$ ln -s /media/vbox-shared ~/vbox-shared
19. If you will be accessing a Git repository from inside the VM, you should also run the following commands:
$ git config --global core.fileMode false $ git config --global push.default simple $ git config --global credential.helper store $ git config --global user.email "YOUR_UCHICAGO_EMAIL_HERE" $ git config --global user.name "YOUR_FULL_NAME_HERE"
And now you're done! This was a long guide, so let's recap what you can do now:
- Edit code on your local machine in your preferred editor. For example, if you like using Sublime Text on your Mac, you can use that by opening
REPO_ROOT
in sublime text. - Test code inside the VM, without launching the full GUI and suffering through its slowness. You'll do this by launching the VM in headless mode as described earlier, and running
ssh cs-vm
from your local machine. The~/vbox-shared
folder on your VM will mirror theREPO_ROOT
folder on your local machine, exactly and instantly.