Page 1 of 1

Can't mount shared folders on Ubuntu 10.10

Posted: 12. Dec 2010, 08:25
by MoustafaEid
Host OS: Windows 7
Guest OS: Ubuntu 10.10

After spending many hours trying to fix this, i'm still not able to mount shared folder on Ubuntu 10.10, both 64 and 32 bit systems, clean install.

all required packages (dkms, build-essential, linux-headers-generic) are installed, guest additions are installed as well and verified as working.

After trying couple of times to mount using fstab with no luck, i found out that sometimes fstab doesn't work due to the guest additions not being loaded when fstab is being executed, so i created a shell script to auto mount the share folder. Here are the contents of the shell script:

Code: Select all

#!/bin/bash
echo "Running Script"
mount -t vboxsf -o uid=1000,gid=1000 Share /home/brain/dd >& /home/brain/aerr.txt
echo "test" > /home/brain/test.txt
the shell script is in /etc/init.d, i used sudo update-rc.d vboxmount defaults 40 to add a link in each rc.d folder, and the 40 to make sure it gets executed after the virtual box addition scripts has been started ( they're S30 and S35 ).
So my script runs ( test.txt gets created along with aerr.text ), when the script tries to mount the shared folder, it produces this error: /sbin/mount.vboxsf: mounting failed with the error: Invalid argument
i get the same error if i execute the shell script manually (sudo bash /etc/init.d/vboxmount) or try to mount it directly ( mount -t .... ) it gives the same error.

I can mount the shared folder if i disable the script from executing upon startup, or change the share name and mount after the guest has already booted. For some strange reason, it doesn't mount correctly if the auto mount script tried to mount during boot.

after booting up the guest OS, the shared folder appears to be mounted:

Code: Select all

Share on /home/brain/dd type vboxsf (uid=1000,gid=1000,rw)
but the destination folder (/home/brain/dd) is empty (it shouldn't if its mounted, shared folder has some files in it on the host OS). doing a umount Share gives umount: /home/brain/dd: not mounted

I have tried using mount.vboxsf and mount -t defaults and they're both giving me the same results

At this point, i'm out of ideas. Any help is appreciated.

P.S: Just to show that my script is being executed after guest additions are loaded, here is my boot.log:

Code: Select all

brain@brain-linux:~/dd$ cat /var/log/boot.log 
fsck from util-linux-ng 2.17.2
/dev/sda1: clean, 161232/1884160 files, 911804/7528448 blocks (check in 4 

mounts)
 * Starting AppArmor profiles                                               

    Skipping profile in /etc/apparmor.d/disable: usr.bin.firefox
                                                                         [ 

OK ]
 * Setting sensors limits                                                [ 

OK ] 
speech-dispatcher disabled; edit /etc/default/speech-dispatcher
Starting the VirtualBox Guest Additions ...done.
Starting VirtualBox Guest Addition service  ...done.
Running Script
 * PulseAudio configured for per-user sessions
saned disabled; edit /etc/default/saned
 * Enabling additional executable binary formats binfmt-support          [ 

OK ] 
 * Checking battery state... 

Re: Can't mount shared folders on Ubuntu 10.10

Posted: 12. Dec 2010, 16:29
by Perryg
Shared Folders in VirtualBox
The first thing that you should do is get the mount to work manually first to make sure that you understand what you are doing and that it is correct.
Once you have this working add the same statement to the /etc/rc.local file and it will auto-mount for you. (you will not need the sudo statement in the rc.local file)

There are only a few things needed.
(1) share name can not contain spaced or special characters.
(2) mount point must exist
(2) Linux is case sensitive.
(4) mount syntax must be correct.

Code: Select all

sudo mount -t vboxsf o rw,uid=1000,gid=1000 <share name> /<mount point>
So if the share name = share and the mount point = /mnt/share

Code: Select all

sudo mount -t vboxsf o rw,uid=1000,gid=1000 share /mnt/share

Re: Can't mount shared folders on Ubuntu 10.10

Posted: 12. Dec 2010, 17:53
by MoustafaEid
Thank you for replying Perryg. I can assure you that the syntax is correct, and that the mount point exists. I have tried to mount manually before moving it to the auto mount script.

Code: Select all

sudo mount -t vboxsf -o rw,uid=1000,gid=1000 Share /home/brain/dd
/sbin/mount.vboxsf: mounting failed with the error: Invalid argument
To successfully mount the share, i have to disable the auto mount script. After doing so and rebooting, i can easily mount the share manually. Adding the mount statement to the /etc/rc.local file doesn't mount the share folder.

This is aside from the point, but i think the /etc/rc.local doesn't execute during boot. I have been experimenting with it for a long time till i just moved on to creating my own script and using update-rc.d to create links in each rc.d folder.

I'd appreciate any other suggestions.

Re: Can't mount shared folders on Ubuntu 10.10

Posted: 12. Dec 2010, 18:02
by Perryg
/etc/rc.local doesn't execute
Did you read the top of the file?

Code: Select all

rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0
Make the file executable and add the mount statement just above the exit 0

Re: Can't mount shared folders on Ubuntu 10.10

Posted: 12. Dec 2010, 19:58
by MoustafaEid
The mount statement is in fact before exit 0, and rc.local is executable

Code: Select all

-rwxr-xr-x   1 root    root      402 2010-12-12 12:50 rc.local
To prove this, i commented out the mount statement and added a statement that creates a txt file in my home directory.

Code: Select all

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
#mount -t vboxsf o rw,uid=1000,gid=1000 edenyz /home/brain/dd
echo "Testing Script" > /home/brain/test2.txt

exit 0
test2.txt is not created during boot.

Re: Can't mount shared folders on Ubuntu 10.10

Posted: 12. Dec 2010, 20:59
by Perryg
I don't know what your problem is it works for me.
rc-local.jpg
rc-local.jpg (77.33 KiB) Viewed 11078 times

Re: Can't mount shared folders on Ubuntu 10.10

Posted: 16. Dec 2010, 05:00
by MoustafaEid
I got the shared folder to mount, the problem was that it doesn't like creating file or mounting any thing on my user folder /home/brain. I created a folder called share in /media and mounted it in rc.local and it works fine. fstab works fine also.

It's weird though, I thought rc.local does anything with root privileges, not sure why it doesn't like to use /home/user folder.

Thanks everybody.

Re: Can't mount shared folders on Ubuntu 10.10

Posted: 16. Dec 2010, 23:17
by Sasquatch
Rc.local is executed as root, but it also respects user locations. If it doesn't run a command as a user, it will not write files to the user home on boot.

Re: Can't mount shared folders on Ubuntu 10.10

Posted: 17. Dec 2010, 16:38
by mschwartz
What Unix/Linux is this?

I use Ubuntu 10.10 (and earlier) as guests and they all have no problem mounting on /home/whatever from fstab.

Re: Can't mount shared folders on Ubuntu 10.10

Posted: 17. Dec 2010, 17:02
by Perryg
mschwartz wrote:What Unix/Linux is this?
I use Ubuntu 10.10 (and earlier) as guests and they all have no problem mounting on /home/whatever from fstab.
Using fstab will work for most. The reason to use rc.local is because fstab runs before the VirtualBox drivers are loaded and and it "CAN" cause some systems to freeze. If you look you will see that happen in your guest and it picks up on the second run. Using rc.local you do not have this issue as it runs last.

Re: Can't mount shared folders on Ubuntu 10.10

Posted: 18. Dec 2010, 07:20
by MoustafaEid
mschwartz wrote:What Unix/Linux is this?

I use Ubuntu 10.10 (and earlier) as guests and they all have no problem mounting on /home/whatever from fstab.
This problem is on vanilla installation of Ubuntu 10.10 and 10.04. Although rc.local run as root, it is not able to mount any thing in the home folder, neither can fstab, which doesn't make sense.

It mounts fine in other places (/media, /tmp), I event tried reinstalling virtual box but still, cannot mount on /home/user.

I guess since it is working anyway for me now i'll be happy. it's just doesn't make sense to me.

Re: Can't mount shared folders on Ubuntu 10.10

Posted: 20. Dec 2010, 16:09
by mschwartz
I've never seen fstab fail, using Ubuntu from 7.x up through 10.x.

This is the fstab line that works for me every time (see note below):

workspace /home/pwp3 vboxsf defaults 0 0

I have a shared folder called workspace that I made (permanent type).

Note: the only time I've seen this fail is after a vbox update to new version and the mount fails until I update the guest additions.

Re: Can't mount shared folders on Ubuntu 10.10

Posted: 20. Dec 2010, 16:12
by mschwartz
On a related note...

Windows 7 X64 host, Ubuntu guest. The vboxsf mounted partition does not support softlinks created from the guest. Seems like it wouldn't be that hard to implement

Re: Can't mount shared folders on Ubuntu 10.10

Posted: 24. Dec 2010, 00:37
by Sasquatch
Check v4.0.0, it has support. Didn't it already in 3.2.12?

Re: Can't mount shared folders on Ubuntu 10.10

Posted: 27. Dec 2010, 18:32
by mschwartz
Sasquatch wrote:Check v4.0.0, it has support. Didn't it already in 3.2.12?
Nope.

I found this out by installing ringojs on a mounted shared folder partition. The installer tried to make softlinks that failed to be created.

Permissions don't work, either.