Are you working on CS 168 Project 3 and would rather edit files on your host computer rather than inside your VM? This thing can help you with that, by using Vagrant to set up Virtualbox shared folders.
-
Some prerequisites before we begin (in the host computer):
- Download this repo, and
cd
into it. - Make sure Vagrant is installed.
On Mac:brew install Caskroom/cask/vagrant
- Download this repo, and
-
In your cs168proj3 VM:
-
In your host computer:
VBoxManage list vms
- You should see the following line, with the
x
's being variable:
"cs168proj3" {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
- Copy the
x
-string (this is your VM's UUID) bin/setup-vagrant xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
(Replacing thex
-string with actual UUID from above)
That's it!
Once you have completed setup, you do not have to use Vagrant anymore. You can ssh cs168@172.16.122.2
into the VM, just as before.
However, if continue to use Vagrant, you get the following benefits:
- The VM by default runs in the background ("headless mode"), using less CPU. If you need to use the GUI (i.e., to run Wireshark), open VirtualBox and click "Show" for the VM.
vagrant ssh
won't ask you for a password.- If you move your
proj3
directory in your host, your shared folder setup will break and the files will become inaccessible inside the VM. This will be fixed the next time youvagrant up
.
Vagrant command reference (make sure you're cd
'd into directory with the Vagrantfile
):
vagrant up
to start up the VMvagrant ssh
to SSH into the VMvagrant halt
to shut down the VM. Add-f
to force shutdown.vagrant reload
to restart the VM. Add-f
to force shutdown.
Here's what the setup process does:
- Tells Vagrant which VirtualBox VM to use with this folder.
- Tells VirtualBox to take a snapshot (backup) of the VM in case anything goes wrong.
- Sets up a VirtualBox shared folder linking this directory with
/home/cs168/public
in the VM. - Moves files from
/home/cs168/public-bak
into/home/cs168/public
. Because/home/cs168/public
is now a shared folder, this actually moves the files into the host computer, although they are visible from the VM too.
Something not working? Please open an issue! Include screenshots please.
Created by (@szhu) for CS 168 Fall 2014. Here's the original post.