VirtualBox - Sharing a host folder on Ubuntu guest
I have been using VirtualBox to run Ubuntu Server on my Windows PC over the last couple of weeks. The more time I spend with it, the more I find the need to get myself acclimatized with the good old command line method to interact with your OS. Though I'm a pretty fast learner and have spent quite a bit of time on Linux and its variants in the past, the sheer number of commands that one has to learn to manage the large array of interfaces in present-day OS is astounding.
For example, I wanted to share a folder from my Windows host to the Ubuntu guest. How do I go about doing it? How do I mount a USB stick on guest OS?
Luckily, answers to most of these questions are only a few clicks away with the help of Google. However, since I expect to carry out some of these tasks quite often in the future, I'm going to try and record things that I discover and re-learn in various blog posts, so as to act as a reference for myself. This post talks about how to go about accessing a Host folder that is shared through VirtualBox in the Ubuntu guest through command line.
1. Install Guest Additions Package
For this, you have to first install the Guest Additions package that comes with VB. It's rather straightforward if you have the Ubuntu GUI installed -- just select the supplied .iso image as your CD drive content and voila, the autorun-like mechanism pops. But on a OS without the GUI, you need to mount it yourself. This is how:
mount -o loop /dev/sr0 /media/cdrom
2. Mount the Shared Folder
sudo mount -t vboxsf temp /mnt/winshare/temp