Virtualbox shared folder permissions [closed] - virtualbox

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 1 year ago.
Improve this question
I'm using Windows and Virtualbox with RedHat, putting it simple: I've created a shared folder so I can use Eclipse on my Windows OS and do some testing in Linux.
However, I can't access the shared folder with my user, I've logged in with root and used chmod 777 and even moved my user to the folder's group.
Whatever I do the result is the same:
/media/sf_sharedFolder/: Permission denied
What can I do? How can I access the shared folder with my user?

Add yourself to the vboxsf group within the guest VM.
Solution 1
Run sudo adduser $USER vboxsf from terminal.
(On Suse it's sudo usermod --append --groups vboxsf $USER)
To take effect you should log out and then log in, or you may need to reboot.
Solution 2
Edit the file /etc/group (you will need root privileges). Look for the line vboxsf:x:999 and add at the end :yourusername -- use this solution if you don't have sudo.
To take effect you should log out and then log in, or you may need to reboot.

Try this (on the guest machine. i.e. the OS running in the Virtual box):
sudo adduser your-user vboxsf
Now reboot the OS running in the virtual box.

This also works
sudo usermod -aG <group> <user>
Then restart vm

For the truly lazy (no typing, only totally easy copy and paste):
sudo usermod -aG vboxsf $USER
Log out and back in to make the change active.
I know it's a "me too" solution, but I am truly lazy and didn't find any other solution to appeal my innate apathy... :)

For VirtualBox(5.0.24) Host=Mac(El Capitan) and Guest=RHEL(7.2)
Start up your RHEL Guest VM and open up a Terminal. Make sure you have the Developer Tools installed.
sudo yum groupinstall 'Developer Tools'
And the Kernel headers package so that the Guest Additions script can update your kernel.
sudo yum install kernel-devel*
Once you have the prereqs in place its time to install the Guest Additions. With your running VM selected go to the VirtualBox menu and select Devices --> Insert Guest Additions CD image...
Allow a few seconds for the mount to occur and the install script to kick off. Once they have click the "Run" button in the dialog that popped up in your Guest VM.
After the script finishes right click the CD Icon on the Desktop and choose Eject. Then Shutdown the Guest VM.
Create the Shared folder in you Host system using Terminal, I usually put it in my Documents folder, and make sure that your user can access it.
sudo mkdir ~/Documents/RhelShared
sudo chmod 755 <user> ~/Documents/RhelShared
In the Oracle VM Virtual Box Manager select your VM and then click on the "Shared folders" configuration element. In the next dialog click on the Add Folder icon to the right of the Folders List.
Then in the popup window select the Host Folder you just created as the Folder Path and give it a Folder Name that will be used by the Guest VM, also tick the "Auto Mount" check-box.
After rebooting the Guest VM launch a terminal on the Host and check the user that is associated with the running VirtualBox Guest process is either your user, very likely, or in a group with access to the Shared folder.
ps aux | grep VirtualBoxVM
Then as per several of the previous answers in a Terminal on the Guest VM add your user to the vboxsf group.
sudo usermod -a -G vboxsf <user>
Log out and in again to pickup the change.
The shared folder should now be available and accessible as sf_rhelshared assuming you used the same names as I did in the popup window above.

To clarify the last post:
The VBoxManage command is:
VBoxManage setextradata <VM_NAME> VBoxInternal2/SharedFoldersEnableSymlinksCreate/<SHARE_NAME> 1

In my case the following was necessary:
sudo chgrp vboxsf /media/sf_sharedFolder

sudo adduser xxxxxxx vboxsf
where xxxxxx is your user account name. Log out and log back in to Ubuntu.

The issue is that the shared folder's permissions are set to not allow symbolic links by default. You can enable them in a few easy steps.
Shut down the virtual machine.
Note your machine name at Machine > Settings > General > Name
Note your shared folder name at 'Machine > Settings > Shared Folders`
Find your VirtualBox root directory and execute the following command.
VBoxManage setextradata "[vm name]" VBoxInternal2/SharedFoldersEnableSymlinksCreate/[shared folder] 1
Start up the virtual machine and the shared folder will now allow symbolic links.

After adding the user to the vboxsf group, you might need to completely log out of the gnome/xfce/??? session, because someone long ago decided that group affiliation should be cached at first login to the window system.
Or go old school:
% newgrp vboxsf
in any shell you want to use to access the folder. Luckily, newgrp looks up the group list for itself and doesn't used the cached values. You'll still need to log out and back in to access the folder from something other than a shell.

In my personal experience, it's difficult to enable shared folders in VirtualBox but it Is posible. I have a debian Buster guest virtual machine installed in my Windows 10 host.
I don't recognize exactly what did it, but I remember I went to Windows defender, my antivirus to see if they recognize VirtualBox as a program and not as a virus. After that, I press right click on the document file and allowed to share the folder and I gave click to some buttons there and accepted to share with groups and with muy user in Windows 10.
Also, I found a webpage of Windows about something like virtual machines that I don't remember well, but it took me to a panel and I had to change three things double clicking so when I update Windows, it recognizes my virtual machine. Also, in muy debian, in the terminal, using some command lines, muy VirtualBox recognized my user giving permissions, I based on some info in the Ubuntu forums. I put all what I remember.

Related

How does one configure shared folders to automount for arch/manjaro linux VM in virtualbox?

I have a manjaro/arch virtual machine running in virtualbox with a windows 10 host. I have configured the shared folder I want to share in virtualbox as c:\tfs with the name tfs but it doesn't show up in the linux vm anywhere. I am able to mount it manually, but it won't auto-mount. I created the /media and /media/tfs folder in the VM, since it did not exist, and now the following command successfully manually mounts my folder sudo mount -t vboxsf tfs /media/tfs. How do I get the automount to work as intended without resorting to editing /etc/fstab?
It turns out that a few more steps are needed to configure the automount for shared folders of virtualbox. This tiny forum post was the key. You need to enable and start the virtualbox service vboxservice.service installed with the guest utils.
First ensure you have a folder /media, this is where it will try to mount your shared folders
Ensure that the guest utils are installed with sudo pacman -Q virtualbox-guest-utils
Enable service with sudo systemctl enable vboxservice.service
Start service with sudo systemctl start vboxservice.service
Reboot, I tried just logging out but reboot was necessary for me to start the service
Verify that your folder is now automounted in /media with sf_ prefix, mine is /media/sf_tfs
p.s. I also ran this command based on another post to add my username to the vboxsf group, although I'm not sure whether this one was necessary or not. sudo usermod -aG vboxsf brandon

Hyperledger: get "/bin/bash: ./scripts/script.sh: No such file or directory" when running "./byfn -m up"

I'm a newer for the hyperledger and just studying it by following the tutorials on http://hyperledger-fabric.readthedocs.io. I am trying to build the first network using "first-network" in the fabric-samples. The ./byfn -m generate is OK. But after typing ./byfn -m up, I meet
/bin/bash: ./scripts/script.sh: No such file or directory
error and the process hangs.
What is going wrong?
PS: The OS is Windows 10.
Check to see if you have a local firewall enabled. Depending on your docker configuration, a firewall may prohibit the docker daemon from accessing share drives as specified in docker setup (windows).
Restart the Docker daemon after applying local firewall changes.
I was facing the same issue and could resolve it.
The shared network drive needs to be working for any directory on the local machine to be identified from the container.
Docker for example has the "Shared drive" usually c:\ under which all your byfn.sh paths shall be present. Second condition is you need to be running the byfn.sh script with the same user who was authenticated to share the drives on the container. Your password change on the windows environment could break the already existing shared drives with the containers, hence creating problems in starting them.
Follow these steps :
In your docker terminal check the path $HOME. Type the command echo $HOME.
Make sure that your fabric-samples folder is the same path as of the variable $HOME.
Follow the steps for generating your first network.
or try the below solution.
Follow these steps :
Go to settings of docker.
Click on reset credentials.
Now check if the shared drives include the required drives or not.
If not, then include them apply your changes and restart your docker and your bash where you were trying to start your network.
I know the question is old but i have faced the similar issue so i did the following
./byfn.sh -m generate
./byfn.sh -m up
i was missing .sh in both commands.

VAGRANT SHARED FOLDERS DO NOT MOUNT - Windows 7 - Vagrant 1.7.4 - Ubuntu 12.04 precise64 - VirtualBox 5.0.10 with Guest Additions

I'm following the old tutorials off of gettingstartedwithdjango.com.
This series is quite old and I'm new to Django which is why I hit that site in the first place. It became my first introduction to Vagrant. Because the series is old and there are now new versions of Django, Vagrant, etc, I've found just getting through the first tutorial was quite difficult. This was mainly just the gap between Django v1.4 and the current version 1.9 which is what I'm running, including some syntax differences in settings.py and also some discrepancies between the text errata and the video which I had to sort through. It's a pretty detailed exercise if you're completely new to all of this (which I am), so it was quite challenging, and I was thrilled when after probably 12 hours of solid effort I was able to get everything working as was being described in the video but using all new versions of software. Once I got it all set up and working, I halted my Vagrant VM for the night and when I turned it back up (vagrant up) the next morning, I found that the VM would no longer mount its shared folders, essentially rendering the Vagrant VM useless to me as I'm then unable to run code which resides on the host machine (I'm running Windows 7) from within the VM (which is accomplished via the VirtualBox shared folders feature).
Not knowing what was wrong, this prompted me to completely reinstall my Vagrant VM. I was able to get things redeployed successfully with about one hour worth of effort, backtracking through steps I had taken to successfully complete the first tutorial in the first place, in order to back to the same point where I started (before I did the previous vagrant halt). When reinstalling the Vagrant VM I noticed messages that my VirtualBox Guest Additions (4.2.0) did not match the version of VirtualBox I have installed (5.0.10), which I recalled seeing the first time but ignored because it also said this isn't usually a problem and should work (if it weren't for bad luck, I'd have no luck at all). Since for me it didn't work, this led me down a whole rabbit hole of posts from various websites including SO, which ultimately had me updating my Vagrant VM, downloading/mounting/building/installing a new version of VirtualBox Guest Additions, and reloading my Vagrant VM only to wind up in the same boat. Shared folders were still not working!
To be very specific, this is more or less what I tried based on information from many websites:
cd /home/vagrant
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install dkms build-essential linux-headers-generic
sudo apt-get install linux-headers-3.2.0-23-generic
# mounted VBoxGuestAdditions_5.0.10.iso to Vagrant VM
cd /media/cdrom
sudo sh ./VBoxLinuxAdditions.run
sudo reboot
sudo /etc/init.d/vboxadd setup
sudo reload
c:\VAGRANT\vagrant plugin install vagrant-vbguest
c:\VAGRANT\vagrant reload
I was utterly convinced this was going to resolve the issue but it didn't.
Then I found this gem:
http://ddelizia.blogspot.com/2011/02/how-to-share-folder-on-virtual-box-with.html
This shows how to, from within the Vagrant VM, mount the shared folders back to your Windows 7 host. To be specific, here's what I did when I found things were working again:
cd /vagrant
ls -la
<this yielded nothing>
sudo mount.vboxsf vagrant /vagrant # see your VirtualBox Shared Folders settings
cd ~ # /home/vagrant
cd - # /vagrant
ls -la
# this yielded the expected folders from my Win7 host
In the mount.vboxsf command above, the first vagrant (without the /) came from the Name column in my VirtualBox shared folders settings. This is essentially an alias which is used to refer to the actual path on the Win7 host, in my case: C:/VAGRANT. The second vagrant (with the /) in that command is the /vagrant folder on the Vagrant VM (linux).
Given that I spent most of today messing with this and I figure there are plenty of people who are going to run into this same or related problem, I thought I would try to help out and save you all a bunch of time. Good luck.

mkdir: cannot create directory : Protocol error : Virtualbox Shared folder

I am trying to create folders and file in Virtualbox shared folder from Host to guest.
But i get this error mkdir: cannot create directory : Protocol error.
Below are steps i performed to share folder
1:My host OS is Ubuntu and my guest is Ubuntu.
2:I attached a share folder to virtualBox VM
Folder Path:/DR/vault/config
Folder:config selected automount and make permanent.
3:In Guest OS i installed virtualbox guest additions
4:I am trying to mount folder on /mount/config path
I added entry in guest's /etc/fstab as
/config /mount/config vboxsf rw,uid=1000,gid=1000 0 0
Path gets successfully mounted after Guest reboot also i can see the files created in /DR/vault/config(Guest) to /mount/config(Guest) but i cant create folder or file in /mount/config (Guest)
Please suggest if anything is missing or if there is any other way.
In my case, I had the drive full, clearing some space on the drive solved the issue.
I have found this is a problem with filename lengths on DOS hosts.
I have been using VirtualBox VMs as a form of containerised environment for deploying to a JBoss server, having experienced far too many problems with Windows environments for said technology.
I was using a shared-directory with my host machine as I was trying to keep the virtual machine lightweight (i.e. keeping IDEs in the host machine), then checking code into the shared directory for deployment with Maven. However, maven was giving some odd errors when the directory length grew to over 255 characters. Try looking at your file absolute path (type "pwd") and seeing if it's longer than 255.
I've resolved this problem with the following:
On the guest machine, add your user to vboxsf group: sudo adduser username vboxsf
Restart the host machine.
My host OS is Windows, my guest OS Ubuntu.
This might be an indication that the folder does not have the correct permissions on the Virtualbox host.
E.g. my headless Virtualbox server is running as "vbox" user, so I had to give that user write permissions on the host folder.
I had a similar issue, turns out that for me it was the number of folders or length of path name involved in mkdir.
typically I had :
mkdir -p /projects/bot/node_modules/webpack/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/kind-of/node_modules/is-buffer
Manually I could create up to the last part of the path but not the 'is-buffer' folder
I am working in vagrant and my projects folder is a shared VM folder, maybe/probably windows' max path length is the reason.

Permanently mount shared folder in Mint Linux running on Virtual Box

I have installed mint Linux 8.0 on Virtual box.
I have created a shared folder in virtual box and i have mounted on linux using mount command.
The problem here is as soon as i shut down and restart linux the mounted folder will not available and (i need to re mount it again).
So how i can mount the shared folder permenently on linux so that i can access any time?
You can mount the shared folder on startup by adding it to fstab.
I am currently using:
Linux Mint 17.3
VirtualBox Version 5.0.16 with Guest Additions installed
The way that I auto mount the drives upon loading is by modifying the
rc.local file located in the /etc folder.
Instructions:
Create a folder on the host machine and create a folder on on the virtual machine
Note: I don't recall if the names need to be named same (including case). Also, I put all of my shared folders in my Documents folder.
Add the folder to the virtual machine's list of shared folders
Click on the virtual machine in VirtualBox
Click on Settings
Click on Shared Folders
Click on the add folder button (located on the right side of the window
Give the folder path, folder name, and click on the "Make Permanent" checkbox
Click the okay buttons
vim into rc.local by typing sudo vim /etc/rc.local in the virtual machine
Note: You will need super user privileges to modify the file which is why sudo is there.
Append the mount command.
Example:
mount -t vboxsf <Folder_Name> /home/< My_Name >/Documents/< Folder_Name >
Note: Be sure to check your syntax in the terminal before appending the command. You won't need a sudo here because it is implied. You will want to double check yourself here because a bad line will prevent further lines from being executed and it won't tell you that there was an error.
Save and exit. (I use wq)
The folder should be mounted when you restart your computer next time.