VirtualBox: mount.vboxsf: mounting failed with the error: No such device [closed] - macos

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I'm using VirtualBox with OS X as host and CentOS on the guest VM.
In OS X I created folder myfolder, added it as shared folder to the VM, turned on the VM, in CentOS created folder /home/user/myfolder and typing:
sudo mount -t vboxsf myfolder /home/user/myfolder
and have output:
/sbin/mount.vboxsf: mounting failed with the error: No such device
What I'm doing wrong?
UPDATED:
Guest Additions installed.

My shared folder/clipboard stopped to work for some reason (probably due to a patch installation on my virtual machine).
sudo mount -t vboxsf Shared_Folder ~/SF/
Gave following result:
VirtualBox: mount.vboxsf: mounting failed with the error: No such device
The solution for me was to stop vboxadd and do a setup after that:
cd /opt/VBoxGuestAdditions-*/init
sudo ./vboxadd setup

You're using share folders, so you need to install VirtualBox Guest Additions inside your virtual machine to support that feature.
Vagrant
If you're using Vagrant (OS X: brew cask install vagrant), run:
vagrant plugin install vagrant-vbguest
vagrant vbguest
In case it fails, check the logs, e.g.
vagrant ssh -c "cat /var/log/vboxadd-install.log"
Maybe you're just missing the kernel header files.
VM
Inside VM, you should install Guest Additions, kernel headers and start the service and double check if kernel extension is running.
This depends on the guest operating system, so here are brief steps:
Install kernel include headers (required by VBoxLinuxAdditions).
RHEL: sudo apt-get update && sudo apt-get install kernel-devel
CentOS: sudo yum update && sudo yum -y install kernel-headers kernel-devel
Install Guest Additions (this depends on the operating system).
Ubuntu: sudo apt-get -y install dkms build-essential linux-headers-$(uname -r) virtualbox-guest-additions-iso
If you can't find it, check by aptitude search virtualbox.
Debian: sudo apt-get -y install build-essential module-assistant virtualbox-ose-guest-utils
If you can't find it, check by dpkg -l | grep virtualbox.
manually by downloading the iso file inside VM (e.g. wget) and installing it, e.g.
wget http://download.virtualbox.org/virtualbox/5.0.16/VBoxGuestAdditions_5.0.16.iso -P /tmp
sudo mount -o loop /tmp/VBoxGuestAdditions_5.0.16.iso /mnt
sudo sh -x /mnt/VBoxLinuxAdditions.run # --keep
Extra debug: cd ~/install && sh -x ./install.sh /mnt/VBoxLinuxAdditions.run
Double check that kernel extensions are up and running:
sudo modprobe vboxsf
Start/restart the service:
manually: sudo /opt/VBoxGuestAdditions*/init/vboxadd setup (add sudo sh -x to debug)
Debian: sudo /etc/init.d/vboxadd-service start
Fedora: sudo /etc/init.d/vboxdrv setup
CentOS: sudo service VBoxService start
Building the main Guest Additions module
If above didn't work, here are more sophisticated steps to fix it. This assumes that you've already VBoxGuestAdditions installed (as shown above).
The most common reason why mounting shared folder doesn't work may related to building Guest Additions module which failed. If in /var/log/vboxadd-install.log you've the following error:
The headers for the current running kernel were not found.
this means either you didn't install kernel sources, or they cannot be found.
If you installed them already as instructed above, run this command:
$ sudo sh -x /opt/VBoxGuestAdditions-5.0.16/init/vboxadd setup 2>&1 | grep KERN
+ KERN_VER=2.6.32-573.18.1.el6.x86_64
+ KERN_DIR=/lib/modules/2.6.32-573.18.1.el6.x86_64/build
So basically vboxadd script is expecting your kernel sources to be available at the following dir:
ls -la /lib/modules/$(uname -r)/build
Check if the kernel dir exists (symbolic link points to the existing folder). If it's not, please install them to the right folder (e.g. in /usr/src/kernels).
So vboxadd script can enter your kernel source directory and run make kernelrelease, get the value and compare with your current kernel version.
Here is the logic:
KERN_VER=`uname -r`
KERN_DIR="/lib/modules/$KERN_VER/build"
if [ -d "$KERN_DIR" ]; then
KERN_REL=`make -sC $KERN_DIR --no-print-directory kernelrelease 2>/dev/null || true`
if [ -z "$KERN_REL" -o "x$KERN_REL" = "x$KERN_VER" ]; then
return 0
fi
fi
If the kernel version doesn't match with the sources, maybe you've to upgrade your Linux kernel (in case the sources are newer than your kernel).
CentOS
Try:
vagrant plugin install vagrant-vbguest vagrant vbgues
If won't work, try the following manual steps for CentOS:
$ sudo yum update
$ sudo yum install kernel-$(uname -r) kernel-devel kernel-headers # or: reinstall
$ rpm -qf /lib/modules/$(uname -r)/build
kernel-2.6.32-573.18.1.el6.x86_64
$ ls -la /lib/modules/$(uname -r)/build
$ sudo reboot # and re-login
$ sudo ln -sv /usr/src/kernels/$(uname -r) /lib/modules/$(uname -r)/build
$ sudo /opt/VBoxGuestAdditions-*/init/vboxadd setup

I am able to resolved this by running below commmand
modprobe -a vboxguest vboxsf vboxvideo

In addition to #Mats answer, I'm adding some more info (it helped me on Debian 8).
My shared folder/clipboard stopped to work for some reason (probably due to a patch installation on my virtual machine).
sudo mount -t vboxsf Shared_Folder ~/SF/
Gave me following result:
VirtualBox: mount.vboxsf: mounting failed with the error: No such device
The solution for me was to stop vboxadd and do a setup after that:
cd /opt/VBoxGuestAdditions-*/init
sudo ./vboxadd setup
At this point, if you still get the following error:
No such device. The Guest Additions installation may have failed. The error has been logged in /var/log/vboxadd-install.log
You need to install linux headers:
apt-get install linux-headers-$(uname -r)
then you can install Guest Additions:
sh /media/cdrom/VBoxLinuxAdditions.run --nox11
and restart your Linux by:
reboot
then you will be able to mount your shared folder!
mount -t vboxsf Shared_Folder ~/SF/
More informations (in French), check this page.

This was the only solution what worked for me:
Install Vagrant plugin: vagrant-vbguest, which can keep your VirtualBox Guest Additions up to date.
vagrant plugin install vagrant-vbguest
Source: https://github.com/aidanns/vagrant-reload/issues/4#issuecomment-230134083

This was resolved by:
yum install gcc kernel-devel make
workaround is here: https://gist.github.com/larsar/1687725

Shared folder was earlier working for me but all f sudden it stopped working (Virualbox - host was Windows 7, Guest was OpenSuSe)
modprobe -a vboxguest vboxsf vboxvideo
then
mount -t vboxsf testsf /opt/tsf (testsf was the folder in Windows C drive which was added in Virtualbox shared folder --- and /opt/tsf is the folder in OpenSuse

My host is Windows10 my VM guest is ubuntu build by vagrant. This worked for me:
vagrant plugin install vagrant-winnfsd

The solution for me was to update guest additions
(click Devices -> Insert Guest Additions CD image)

I also had a working system that suddenly stopped working with the described error.
After furtling around in my /lib/modules it would appear that the vboxvfs module is no more. Instead modprobe vboxsf was the required incantation to get things restarted.
Not sure when that change ocurred, but it caught me out.

I am running VirtualBox 5.1.20, and had a similar issue. Here is a url to where I found the fix, and the fix I implemented:
# https://dsin.wordpress.com/2016/08/17/ubuntu-wrong-fs-type-bad-option-bad-superblock/
if [ "5.1.20" == "${VBOXVER}" ]; then
rm /sbin/mount.vboxsf
ln -s /usr/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf
fi
The link had something similar to /usr/lib/VBoxGuestAdditions/other/mount.vboxsf, rather than what I have in the script excerpt.
For a build script I use in vagrant for the additions:
https://github.com/rburkholder/vagrant/blob/master/scripts/additions.sh
Seems to be a fix at https://www.virtualbox.org/ticket/16670

For me, on a mac, it turned out I had an old VirtualBox image stored on my machine that didn't have metadata, so it wasn't being updated to the latest version.
That old image had an older version of the vbguest plugin installed in it, which the newer vbguest plugin on my machine couldn't work with.
So to fix it, I just removed the image that my Vagrant was based on, and then Vagrant downloaded the newer version and it worked fine.
# Remove an old version of the virtual box image that my vagrant was using
$ vagrant box remove centos/7
You can find out which boxes you have cached on your machine by running:
$ vagrant box list
I had also upgraded my vbguest plugin in my earlier attempts at getting this to work, using the following process, but I don't think this helped. FYI !
# Get rid of old plugins
vagrant plugin expunge
# Globally install the latest version of the vbguest plugin`
vagrant plugin install vagrant-vbguest
If you find bring the box fails on guest addtions, you can try doing the following to ensure the plugins install correctly. This downloads the latest based image for your system (for me CentOS), and may resolve the issue (it did for me!)
$ vagrant box update

There can be errors/incorrect approach in two scenarios. Check both of it and figure it out
SCENARIO 1 :
Once you are running the VBoxLinuxAdditions.run or VBoxSolarisAdditions.pkg or VBoxWindowsAdditions.exe , check if all the modules are getting installed properly.
1.1.a. In case of VBoxLinuxAdditions, if Building the VirtualBox Guest Additions kernel modules gets failed,
check the log file in /var/log/vboxadd-install.log . If the error is due to kernel version update your kernel and reboot the vm. In case of fedora,
1.1.b. yum update kernel*
1.1.c. reboot
1.2. If nothing gets failed, then all is fine. You are already having the expected kernel version
SCENARIO 2 :
If the VBoxGuestAdditions is installed (check for a folder /opt/VBoxGuestAdditions-* is present .... * represents version) you need to start it before mounting.
2.1. cd /opt/VBoxGuestAdditions-*/init && ./vboxadd start
You need to specify the user id and group id of your vm user as options to the mount command.
2.2.a. Getting uid and gid of a user:
id -u <'user'>
id -g <'user'>
2.2.b. Setting uid and gid in options of mount command:
mount -t vboxsf -o uid=x,gid=x shared_folder_name guest_folder

On Ubuntu this worked:
sudo apt-get install build-essential linux-headers-`uname -r` dkms

Had the same issue with VirtualBox 5.0.16/rXXX
Installed latest VirtualBox 5.0.18 and installed latest Vagrant 1.9.3, issue went toodles.

I added as root user
/etc/rc.d/rc.local
/root/mount-vboxsf.sh
then
chmod +x /etc/rc.d/rc.local
and the sample script /root/mount-vboxsf.sh (set your own the uid and gid options)
modprobe -a vboxguest vboxsf vboxvideo
mount -t vboxsf NAME_SHARED_DIRECTORY /media/sf_NAME_SHARED_DIRECTORY -o rw,uid=0,gid=0
you need add
chmod + /root/mount-vboxsf.sh

I have similar issue, check header if it's not match then run below command
CentOS: sudo yum update && sudo yum -y install kernel-headers kernel-devel

If you're on Debian:
1) remove all installed package through Virtualbox Guest Additions ISO file:
sh /media/cdrom/VBoxLinuxAdditions.run uninstall
2) install Virtualbox packages:
apt-get install build-essential module-assistant virtualbox-guest-dkms virtualbox-guest-utils
Note that even with modprobe vboxsf returning nothing (so the module is correctly loaded), the vboxsf.so will call an executable named mount.vboxsf, which is provided by virtualbox-guest-utils. Ignoring this one will prevent you from understanding the real cause of the error.
strace mount /your-directory was a great help (No such file or directory on /sbin/mount.vboxsf).

An update did the trick for me !
$ vagrant box update
$ vagrant plugin install vagrant-vbguest

Below two commands works for me.
vagrant ssh
sudo mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant

Okay everyone is missing a basic fact.
mkdir /test - Makes sub directory in current directory.
sudo mkdir /test - Make directory in Root.
So if your shared directory name is shared and you do the following:
mkdir /test
sudo mount -t vboxsf shared /test
It generates this error:
sbin/mount.vboxsf: mounting failed with the error: No such file or directory
Because the directory is in the wrong place! Yes that's what this error is saying. The error is not saying reload the VBOX guest options.
But if you do this:
sudo mkdir ~/test
sudo mount -t vboxsf shared ~/test
Then it works fine.
It really amazes me how many people suggest reloading the Vbox guest additions to solve this error or writing a complex program to solve a directory created in the wrong place.

Related

Vagrant was unable to mount VirtualBox shared folders. ERROR: INVALID ARGUMENT

I know that other people during the years had met similar problems (like this ) however in my case the guest addition is installed (0.30.0 version) and I tried to reinstall it a lot of times.
I work on Windows10 and those are the version of VirtualBox and Virtual Machine.
Virtualbox on your host claims: 5.2.8
VBoxService inside the vm claims: 6.1.22
This is the code of the problem:
default: /vagrant => C:/Users/XXXX XXXX/Documents/src
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=1000,gid=1000,_netdev vagrant /vagrant
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: Invalid argument
I never found the error Invalid argument in similar cases so my question is if this need a particular procedure.
Thank you very much
Just had a similar problem after an update - was getting the same:
/sbin/mount.vboxsf: mounting failed with the error: Invalid argument
What I found in virtualbox startup was the message:
VirtualBox Guest Additions: Kernel headers not found for target kernel
5.4.0-81-generic. Please install them and execute
/sbin/rcvboxadd setup
Used "vagrant ssh" to access the virtualbox command line and ran:
sudo apt-get install linux-headers-$(uname -r)
After that restarted vagrant:
vagrant halt
vagrant up
Then it actually built the VirtualBox Guest Additions properly and mounted my shared folders.
Had the same exact error as you after making my second vagrant project - specifically after changing my public_network setting.
mount -t vboxsf -o uid=1000,gid=1000,_netdev vagrant /vagrant
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: Invalid argument
At I also tried several solutions from people's answers like the one mentioned here and updated my VirtualBox.
I'm not really sure how mine works but here's what I did:
I logged into the VM (vagrant ssh) and installed the guest additions manually
cd /opt
sudo wget -c
http://download.virtualbox.org/virtualbox/6.1.26/VBoxGuestAdditions_6.1.26.iso O VBoxGuestAdditions_6.1.26.iso
And then tried:
sudo mount VBoxGuestAdditions_5.1.28.iso -o loop /mnt
sudo sh /mnt/VBoxLinuxAdditions.run
But I got an error saying something like permission denied or no directory.
So I reload vagrant (vagrant reload), but the error still occurred. However, I still continued trying something else, so I thought maybe I should install the vbguest plugin and did this:
vagrant plugin install vagrant-vbguest
That removed the error for me after reload but when I logged into vagrant again, I still can't see my shared folders so I halted my vb and run provision:
vagrant up --provision
Then I got a message which said that there was an error while executing VBoxManage so on and so forth. So I paused all running machine in my VB, closed all running VB apps in my desktop, and run the command:
vagrant destroy
After recreating vagrant vagrant up, everything miraculously worked! I can now navigate to my shared folders' directory.
I'm still in the process of learning vagrant so I can't really explain what actually happened in my machine but I hope this can somehow be of help to you or to someone who have the same issue.
Step 1: open virtual box then right click on installation machine then ->close->power off.
Step 2: then run below command
vagrant halt
vagrant up
Finally got it working the following way (this related answer was of great help along with Paul_Z's answer in this same question).
Step 1:
Make sure VirtualBox Guest Additions Software is installed.
If this solved your Issue, then great! If not, continue on to step 2.
Step 2:
Read the VirtualBox Guest Additions installation output carefully.
(If no longer possible, you can rerun the setup by using cd to go to
/opt/VBoxGuestAdditions-*your-version-number-here*/init/
and then run:
sudo ./vboxadd setup)
Step 3:
Install the needed dependencies with the distribution's package manager that the error message shows. (In my particular case, it mentioned that the system couldn't perform kernel module builds because gcc make and perl were not present in the system).
Step 4:
Rerun the VirtualBox Guest Additions setup by going to
/opt/VBoxGuestAdditions-*your-version-number-here*/init/
and then run:
sudo ./vboxadd setup
(If more dependencies are requested, go back to step 3)
Step 5: Reboot
Step 6 (Optional):
Add user to vboxsf group so that it is able to access the shared folder if needed. (As explained in this answer).
sudo usermod -G vboxsf -a your_user_name
I have the issue i Ubuntu 20.04 and simply download a more recent version of VirtualBox, then extract the GuestAditions ISO and installed it
I ran just
vagrant plugin install vagrant-vbguest
and after this the box came up.

How to create Virtualbox shared folder between Windows host and Ubuntu18.04 guest machine [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 months ago.
The community reviewed whether to reopen this question 3 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I've read docs and all questions about sharing folder from host machine to Virtualbox's guest machine and still can't get it working. In my case the host is Windows machine and guest is Ubuntu18.04 server machine.
What is advised and what I've already tried:
1) In the VM's menu I found 'devices' submenu and clicked 'Insert Guest Additions CD image' option after which the CD icon in the status bar was lit and shows that the CD is inserted and the path to iso is C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso (I checked that file really exists there).
2) In the same 'devices' VM's settings submenu I opened 'Shared Folder Settings' and added shared folder with name 'test' and path 'D:\test' which leads to the folder on my D: disk which contains test files.
3) I reboot my Ubuntu VM and look into /media directory expecting to find /media/cdrom directory or something like this with file VBoxLinuxAdditions.run in it, which should be run according to docs. But /media directory is empty so I have nothing to do with it. I looked for this file into other directories but had no success.
After that I tried to install Virtualbox-guest-additions from repository as was advised on ubuntu forum:
sudo apt-get update
sudo apt-get install virtualbox-guest-dkms
And checked that the package was installed with command:
lsmod | grep -io vboxguest
But when I rebooted and tried to mount the shared folder with:
mkdir -p /home/myusername/test
sudo mount -t vboxsf test /home/myusername/test
I've got error:
mount: /home/myusername/test: wrong fs type, bad option, bad superblock on /home/myusername/test, missing codepage or helper program or other error.
I see there is no /sbin/mount.vboxsf link present, I'm not sure if this is a problem, also I tried add my user to 'vboxsf' group with:
sudo usermod -a -G vboxsf myusername
but the group was not created too.
What am I missing, what is the way to make it work?
After a whole day of trying different solutions I finally found the missing ingredient. But I'm gonna repeat my topic content partially and put here step by step instruction for someone struggling with this task like me.
We suppose that we already have the Ubuntu 18.04 VM installed and the linux user "myusername" with sudo permissions on this machine.
So, to share folder D:\test (just as an example) on Windows host machine to Ubuntu 18.04 Virtualbox's guest machine (it's content should be available in /home/myusername/test directory) we make these steps:
1) Start Ubuntu VM from VirtualBox interface
2) Open "Shared Folder Settings" in the "devices" submenu of the started Ubuntu VM window's upper menu and set the shared folder name as "test" and the path as "/home/myusername/test" and fill the checkbox "Make Permanent"
3) Install virtualbox-guest-dkms and virtualbox-guest-utils packages to Ubuntu VM with the package manager.
sudo apt-get update
sudo apt-get install virtualbox-guest-dkms
sudo apt-get install virtualbox-guest-utils
4) Create a directory /home/myusername/test on your Ubuntu VM
mkdir /home/myusername/test
5) Restart Ubuntu VM
reboot
6) After rebooting mount shared folder in Ubuntu VM with command
mount -t vboxsf test /home/myusername/test
7) Check files in your /home/myusername/test directory, they should be the same files which are located in your Windows D:\test folder
ls /home/myusername/test
8) Additionally you can make this shared folder auto mounted after rebooting, to do so you need add the next line to your ubuntu user's /home/myusername/.profile file:
echo "sudo mount -t vboxsf test /home/myusername/test" >> /home/myusername/.profile
and give your user permission to mount without entering password with opening "sudo visudo" command (which is used to change the /etc/sudoers file) and add the next line:
myusername ALL = (ALL) NOPASSWD: /bin/mount
That's it, after these steps I've managed to share files from Windows host to Ubuntu guest machine. I'd like to mention that the shared directory itself and all files inside it belong to root but has 777 rights so there is no problem using them as any user can do whatever he wants with them.
personally the below commands helped me, it attaches a disk that you have to fill your credentials and boom...
sudo apt-get install virtualbox-guest-dkms
sudo apt-get install virtualbox-guest-utils

Sharing ubuntu 16.04 vm folder with mac os (with samba)

I followed million tutorials and guides on how to do it but no luck... Something is missing, hope you guys can help me out.
My OS: macOS Sierra
Virtualbox OS: Ubuntu 16.04
VM Network Adapter: Bridged Adapter
These are my steps:
Connect to vm via ssh
Install samba
$ sudo apt install samba
Create a directory to be shared
$ sudo mkdir /media/testshare
Add new share to smb.conf
$ sudo vim /etc/samba/smb.conf
[testshare]
comment = My Shared Folder
path = /media/testshare
browseable = yes
readonly = no
guest ok = yes
Restart samba
Add a samba password
$ sudo smbpasswd -a {username}
Try to connect from mac: In Finder, Command+K to open "Connect to Server" and in Server Address: smb://192.168.0.104
I'm getting this:
I tried smb://192.168.0.104/testshare, smb://192.168.0.104/media/testshare
I have no idea how to make it work. Help!
EDIT:
Might help, this is what I get when I run
$ sudo netstat -tulpn | egrep "samba|smbd|nmbd|winbind":
* I know that the ip is different now (192.168.0.104 => 192.168.0.109), its a new vm, don't pay attention to that.
Host OS: macOS El Capitan
VM (guest) OS: Ubuntu Server 16.04.5 LTS
VirtualBox v5.2.18
Both host OS and guest OS must have same user (further in the text: username).
Stage 1: Install VirtualBox Guest Additions:
1.1. Locate the VirtualBox Guest Additions,
$ cd /Applications/VirtualBox.app/Contents/MacOS/
$ cp VBoxGuestAdditions.iso ~/Downloads/
1.2. Start the VM
1.3. Click the CD icon in the bottom right task bar
1.4. Select "Choose disk image..."" and search for the VBoxGuestAdditions.iso
1.5. In the guest terminal type (you can also do this from the host terminal if you SSH into it):
$ sudo su
$ apt update
$ apt upgrade
$ apt-get install dkms build-essential linux-headers-generic gcc make
$ mount /dev/cdrom /mnt
$ cd /mnt
$ sh ./VBoxLinuxAdditions.run
$ reboot
Stage 2: Shared Folders Setup:
2.1. Create rules in VM:
Stop the VM
Go to Settings > Shared Folders
Click in the Add new port forwarding rule green button in the top right of the window.
Search and select the folder you would like to share (e.g.: /path/to/shared/host_folder)
Select the Auto-mount and Make Permanent options
Start the VM
2.2. To mount shared folder on /opt you must create shared_folder_dir subfolder and set appropriate permissions to it:
$ sudo mkdir -p /opt/shared_folder_dir
$ sudo chmod ug+w -Rv /opt/shared_folder_dir
$ sudo chown username:username -Rv /opt/shared_folder_dir
2.3. Add username to the vboxsf group:
$ sudo adduser username vboxsf
$ sudo usermod -a -G vboxsf username
2.4. Reboot VM to apply changes:
$ sudo reboot
Stage 3: Auto mounting host_folder into /opt/shared_folder_dir:
3.1. Change VM's /etc/rc.local:
$ sudo nano /etc/rc.local
and place following right above exit 0:
# 'folder_name' = given in the shared folders configuration
# 'path/to/shared/folders' = guest path to access the shared folders from
# 'id' = prints uid/gid
# sudo mount -t vboxsf -o uid={uid},gid={gid} {shared_folder_name} {path/to/shared/folder}
sleep 5
sudo mount -t vboxsf -o uid=1000,gid=1000 host_folder /opt/shared_folder_dir
exit 0
<<< EOF >>>
Note:
I've added sleep 5 to execute mount operation after VirtualBox Guest Additions has started. You can check that by journalctl -b command.
3.2. Reboot VM to apply changes:
$ sudo reboot
See also

Vagrant. The box you're attempting to add doesn't support the provider you requested

I created a vagrant box using vagrant package , uploaded it and released it.
Then I did vagrant init <username>/<box> which created a Vagrantfile. I even appended the box version to the Vagrantfile.
Next I did vagrant up --provider virtualbox. This tries to get the box locally and then when it can't find it, i get the error:
The box you're attempting to add doesn't support the provider
you requested. Please find an alternate box or use an alternate
provider. Double-check your requested provider to verify you didn't
simply misspell it.
If you're adding a box from HashiCorp's Atlas, make sure the box is
released.
I have given virtualbox as the provider and virtual box works fine with other boxes I use.
Make sure you have virtualbox installed if you are using ubuntu.
sudo apt install virtualbox-qt
What I figured was that due to some reason vagrant had got corrupted. So doing a fresh install of vagrant did the trick.
Upgrading vagrant version through installing .deb version worked for me (download through vagrant website: https://www.vagrantup.com/downloads - choose tab "Debian" and install the package)
I suffered for 2 hours but I don't want anyone to suffer ;)
1 - access the terminal (sudo) and, remove vagrant files
$ rm -rf /opt/vagrant
$ rm -f /usr/bin/vagrant
2 - then install it again as it has probably been corrupted.
$ curl -O https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.deb
3 - install vagrant
$ sudo apt install ./vagrant_2.2.9_x86_64.deb
4 - confirm by viewing the installed vagrant version
& vagrant --version
be happy

Unable to find the source of current linux Kernel

While trying to install guest additions on a Debian guest I get the error:
Unable to find the source of your current linux Kernel. Specify KERN_DIR= and run Make again.
Some said that this is because linux headers are missing. But when I try to run
sudo apt-get install linux-headers-3.16.0-4amd64
I get the error could not resolve ftp.debian.org.uk
My guest operating system was not connected to my host's wifi. So
apt-get update
apt-get install linux-headers-3.16.0-4amd64
Did not work, but when I edited my VirtualBox network settings to Bridged Adapter, both commands worked. Note that it is also important to run the command
sh /media/cdrom/VBoxLinuxAdditions.run
to complete the installation of guest editions.

Resources