Use shared folder to develop with a VirtualBox Ubuntu Server guest

Recently the company that I work for change my Lenovo T440 with Ubuntu 16.04 for a MacBook Air with macOS and although I never really liked Mac (Too expensive for the specs provided) I loved the change but there are several differences that, when it comes to web development, I need to take in account, so I just installed a local Ubuntu 16.04 server with VirtualBox to test my work before to put it out.

To avoid having to pull the source code each time I just wanted to share the development folder with the guest machine and in order to do that we need to make the following steps

Install the VirtualBox Guest Additions in the guest

Just run the machine, and then go to “Devices” -> “Insert Guest Additions CD Image..”

Install some required packages

sudo apt-get install build-essential linux-headers-`uname –r`

Mount the CD and install the additions, then reboot

sudo mount /dev/cdrom /media/cdrom
sudo /media/cdrom/
sudo reboot

Share the folder that you want


Keep in mind that the “Folder name” will be the one that we use to reference that folder.

Mount the folder in the Ubuntu Server

sudo mount -t vboxsf [FolderName] [MountingPoint]

[FolderName]: is the name that we give previously on the settings
[MountingPoint]: It needs to be an empty directory created where you want on the machine

This is the simple way, but it does not fit to my requirements because I wanted that the owner was my user and the group be www-data because thats how I roll. No really, because I need to test the permissions also.

To change the owner and group of the newly mounted folder, well, first unmount it and then mount it with the proper options

mount -t vboxsf -o umask=0022,gid=[GID],uid=[UID] [FolderName] [MountingPoint]

[GID]: This is the group id, to obtain it just run id -g www-data where www-data is the group desired
[UID]: This is the user id, to obtain it just run id -u dnetix where dnetix is the username desired

If you need to unmount (sorry) just run the command

sudo umount [MountingPoint]



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s