Mounting VirtualBox shared folders on Ubuntu Server 18.04 LTS
This guide will walk you through steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest. Tested on Ubuntu Server 18.04
Steps:
-
Open VirtualBox
-
Right-click your VM, then click Settings
-
Go to Shared Folders section
-
Add a new shared folder
-
On Add Share prompt, select the Folder Path in your host that you want to be accessible inside your VM.
-
In the Folder Name field, type
shared
-
Uncheck Read-only and Auto-mount, and check Make Permanent
-
Start your VM
-
Once your VM is up and running, go to Devices menu -> Insert Guest Additions CD image menu
-
Use the following command to mount the CD:
sudo mount /dev/cdrom /media/cdrom
-
Install dependencies for VirtualBox guest additions:
sudo apt-get update sudo apt-get install build-essential linux-headers-`uname -r`
-
Run installation script for the guest additions:
sudo /media/cdrom/VBoxLinuxAdditions.run
-
Reboot VM
sudo shutdown -r now
-
Create "shared" directory in your home
mkdir ~/shared
-
Mount the shared folder from the host to your ~/shared directory
sudo mount -t vboxsf shared ~/shared
For set custom group and user id owner
sudo mount -t vboxsf -o uid=1000,gid=1000 shared ~/shared
- The host folder should now be accessible inside the VM.
cd ~/shared
Make the mount folder persistent
This directory mount we just made is temporary and it will disappear on next reboot. To make this permanent, we'll set it so that it will mount our ~/shared
directory on system startup
- Edit fstab file in /etc directory
sudo nano /etc/fstab
- Add the following line to fstab (separated by tabs) and press Ctrl+O to Save.
shared /home/<username>/shared vboxsf defaults 0 0
- Edit modules
sudo nano /etc/modules
- Add the following line to
/etc/modules
and savevboxsf
- Reboot the vm and log-in again
shutdown -r now
- Go to your home directory and check to see if the file is highlighted in green.
cd ~ ls
If it is then congratulations! You successfully linked the directory within your vm with your host folder.