Site Overlay

Sharing Folders on a VirtualBox Host and client Ubuntu 20.04 Server

Sharing folders between a VirtualBox host and a client is normally presented as a no-brainer: Insert the (virtual) guest addons CD on the client machine, have the addons installed, go into the shared folders settings of the VirtualBox Host installation and start working. However things can get tricky at two moments:

  1. When you have to adapt the correct file and directory privileges for a shared resource (both on the host machine as well as on the client). This is where we have to dive into the chmod and chown world.
  2. When you have no desktop client system where you just can flip in the guest additions CD and install the necessary software on the client system. This is the first hurdle to take when you want to share a folder from your (desktop) host system with a (console) server running in the VirtualBox.

1. What I wanted to achieve … and why

In my situation I am running a Mayan EDMS installation on a Ubuntu 20.04 Server in a VirtualBox. Documents can be fed into Mayan on different routes that Mayan calls “sources“.

The most straightforward way to feed a document into Mayan by web form upload. This involves just dragging and dropping a document to an upload zone shown on a Mayan browser page. Very similar to Dropbox and the likes.

But there are a couple of more sophisticated ways (“sources”) to get documents into Mayan. These can be email accounts that Mayan or watch folders that Mayan scans at regular intervals. In case Mayan finds any documents inside these folders or mail accounts, it automatically downloads them, checks them in as documents and finally. Furthermore, Mayan allows staging folders that precollect the documents that a user can then manually check in.

Now my setup with respect to watch and staging folders looks as follows:

Setup of Mayan EDMS environment
Scanner icons from Mobile Phone in Hands Icon from Upload Computer icon from OpenNote Scanner, Nextcloud and Mayan EDMS logos from respective software developers. All other graphic elements from LibreOffice clip art collections.

So with respect to our shared folders we want to share the watch folder on our Ubuntu desktop machine at /home/someuser/nextcloud/mayan/watch to /home/mayan/watch in our Ubuntu 20.04 Server which runs in VirtualBox.

Note that the mayan user on the Ubuntu 20.04 server needs the same access rights (inlcuding read and write privileges) as the user username on the desktop host machine:

  • Anything which is added to the watch and staging folders on the Ubuntu 20.04 desktop host system – be it directly or through uploads to the folder from a Nextcloud (e.g. by mobile or web upload) should be reflected as an addition in the shared folder on the Ubuntu 20.04 Server side.
  • Anything which is deleted by or through Mayan EDMS on the server side inside the watch and staging folders should be reflected in the Nextcloud folder.

Step 1: Install VirtualBox addons on the server

The first thing we need is a VirtualBox Addons on the server side. I followed these instructions on and it worked quite smoothly. The only trouble I ran into was that I was first unable to Insert the VM Guest Addons CD and got the following message:

The solution to this problem can be found at Basically, you have to first shut down the server, then go to the Storage settings of your virtual server, remove whatever VDMI image is there under IDE drives, then restart the server. Do not start the server headless – you need the main window with the DevicesInsert Guest Additions CD Image... menu. Then you should be able to insert the image without an error message. Continue with the instructions from Create a directory for the virtual CD mount, mount the image and install the Guest Additions.

2. Add settings for the shared folder on the host machine

Shut down your Ubuntu Server. In the VirtualBox manager on your Ubuntu desktop add the settings for your shared folder:

Shared folder in the VirtualBox manager on your Ubuntu desktop host machine

3. Add entry in /etc/fstab on the server side

First thing we need is a mount point in our /home/mayan directory. Keep in mind that this directory is in user mayan‘s /home and should be owned by mayan. We will first set the access privileges as generous as possible (chmod 777). This will be adjusted by the fstab settings in the next step:

Finally to have a permanent mount, we need to add an entry in our /etc/fstab configuration file:

Now shutdown your server.

4. Test the setup

Reboot the server. You should now be able to perform the following tests successfully:

  • If you run ls -alh from /home/mayan, you should get the following access and ownership information for your watch directory. It’s important that on the server the watch directory is owned by mayan:mayan and that the owner has full access to that directory:
  • Next from on your Ubuntu desktop host or from any device that allows a Nextcloud upload to the Nextcloud watch folder, add some file (preferably a text file). Check if the upload is mirrored (1) in your Nextcloud, (2) on your local mirror directory on the desktop host machine and – above all – (3) in the /home/mayan/watch directoryof the server.
  • In /home/mayan/watch on the server check if you have read access to the file by. Note that you must impersonate user mayan by issuing some command like sudo -u mayan cat mytestfile.tex.
  • Again in /home/mayan/watch on the server, check if user mayan has the privilege to delete any document by issuing a command like sudo -u mayan rm mytestfile.tex. Check if the local folder on the desktop machine reflects the deletion and if it is synced in the Nextcloud instance.