VirtualBox and shared folders with host machine. Ubuntu virtual machine.

Sometimes I want to separate something that I need to do into a separate virtual machine. I am using VirtualBox for virtualization on my MacBook Pro 2019 16'' for that matter. Even when I setup a virtual machine, the purpose is often that I do not want to install the software I need for a project on the host machine itself, but I still want the source code and artifacts on my host machine. This is where shared folders comes in handy. Specify which folders I want to be available and then automatically mount them on boot time.

The name that is given to the folders in the VirtualBox GUI is the name that also is used in fstab when setting up the automatic mounting. I found out that by selecting that the folders should be mounted automatically from VirtualBox have me the wrong permission and was not easy to work sound when I started the virtual machine, therefore editing the fstab file myself was easier solution.

testfolder	/mnt/test	vboxsf	defaults,uid=1000,gid=1000,rw	0	0

The uid and gid is the id of the user and group that should have the ownership to the folder. I always set this to my user in the virtual machine, so I have full control. To find the uid, the command id -u <username> can be used and then to find the gid for the user its as easy as writing groups.

There is also a need to add one line to the file /etc/modules, the line that need to be added is vboxsf.

When this is set, the shared folders from the host to guest operating system will be mounted on boot with the user as owner.

Teis Lindemark

Read more posts by this author.