User Tools

Site Tools


vm:headless

This is an old revision of the document!


Headless VM setup guide

1. Clone your class repository to somewhere on your local machine. From now on in this guide, refer to this directory location as REPO_ROOT.

2. 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.

3. From the same page, download the VirtualBox Extension Pack.

4. Install VirtualBox, then double-click on the Extension Pack, and VirtualBox will prompt you to install it.

5. Open VirtualBox, click the menu across from "Tools", and select "Network".

6. 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.

7. 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.

8. 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.

9. Right click on the VM's entry in the VirtualBox sidebar, and click "Settings…"

10. 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.

11. 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 REPO_ROOT, and click "Open" in the bottom right. For "Folder Name", enter the name of your class. From now on, this location will be referred to as REPO_SHARED_NAME. Then, select "Make Permanent" and click "OK", and then "OK" again.

12. Start the VM and log in.

13. 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"

14. 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:

REPO_SHARED_NAME /media/sf_REPO_SHARED_NAME gid=1000,uid=1000

Be sure to replace REPO_SHARED_NAME with the appropriate name. For example, if you named your shared folder cs233, you would write:

cs233 /media/sf_cs233 gid=1000,uid=1000

Then, to quit nano, press Ctrl+x, then press y, then press Enter.

15. Shut down the VM (click the gear icon in the top right, and click "Shut Down").

16. 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.

17. In VirtualBox, right click on the VM and choose "Start" → "Headless Start".

18. Wait ~15s for the VM to start up fully. Then, in a terminal on your local machine, run:

$ ssh cs-vm

19. Once you're logged in, you'll see the prompt change to something like student@cs-vm:~$ . Then, run the following commands:

$ git config --global core.fileMode false
$ ln -s /media/sf_REPO_SHARED_NAME ~/REPO_SHARED_NAME
$ cd REPO_SHARED_NAME
$ chisubmit init

Be sure to replace REPO_SHARED_NAME with the appropriate name. For example, if you named your shared folder cs233, you would run:

$ ln -s /media/sf_cs233 ~/cs233

20. Run the following commands:

$ 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 ~/REPO_SHARED_NAME folder on your VM will mirror the REPO_ROOT folder on your local machine, exactly and instantly.
/var/lib/dokuwiki/data/attic/vm/headless.1550763455.txt.gz · Last modified: 2019/02/21 09:37 by borja

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki