Linux/Ubuntu Mount VirtualBox Shared Folder
Here in this HowTo article, I will show you how you can easily access the shared folder inside the Linux/ubuntu guest using VirtualBox. VirtualBox is one of the most used virtualization technology for various purposes.
Accessing the shared folder is very simple when the guest operating system is Windows, but it needs some extra work if you need to access the shared folder inside Linux based guest OS.
So I am showing here those steps, which is needed to access the shared folder inside Linux based Guest OS. I am using Ubuntu, but these commands will work on any Linux distribution.
For this, you will need to perform the below steps:
- Setup a shared folder in VirtualBox.
- Install VirtualBox guest additions in guest OS.
- Mounting the shared folder in the guest OS.
Here are the details of these steps:
1. Setup shared folder in VirtualBox
Open VirtualBox settings for your virtual machine (the guest Linux OS), and go to the shared folder section. There add a new shared folder entry. For example, I am sharing my entire E drive as a shared folder, like in the below image.
2. Install Guest additions in the Guest OS
Now install the guest addition. So first your guest machine must be in running state. Now in your guest machine window, click on Devices and then click on Insert Guest Addition CD Image. This will insert and mount the guest addition inside the Linux system. It will automatically open the terminal and navigate to the folder, where files need to be installed are present. Now execute below commands in the same terminal:
sudo chmod +x VBoxLinuxAdditions.run
sudo ./VBoxLinuxAdditions.run
Note: If you get an error, then probably Linux header is not installed, so install it in the guest machine using below command, and after that again execute the above commands.
sudo apt-get install linux-headers-$(uname -r)
3. Mount the shared folder
Now the setup is completed, all we need to mount the shared folder. You can mount it to any path. Here in this example, I have created a new folder named “e” in the root. Steps for that is (For beginners: You don’t need to write $):
$ cd / /$ mkdir e
Execute the below command and it will mount it:
/$ sudo mount -t vboxsf -o uid=1000,gid=50 e /e
This will mount the shared folder at location /e in the Linux guest system. You can check it’s contents using ls, for example, ls /e.
If you face any problem, feel free to comment.
Thanks, I was looking for this shared folder solution from long time.