automount and shared folders

Discussions about using Linux guests in VirtualBox.
Post Reply
mikeybikey
Posts: 31
Joined: 10. Dec 2012, 20:19

automount and shared folders

Post by mikeybikey »

Hi

I'm running 64 bit Fedora 16 on a 64 bit Windows 7 machine. I am trying to get shared folders to work. In the "HOWTO: Use Shared Folders" (viewtopic.php?f=29&t=15868) is says that if you do nothing special mounted shared folders will all be owned by root which is what I get. It suggests using the following command where share is set as the name of the Windows folder I want to share in Settings > Shared Folders:

Code: Select all

sudo mount -t vboxsf -o uid=1000,gid=1000 share ~/host
which indeed works.

The HOWTO then says:
If you want to have it mount automatically upon each boot, put the mount command in /etc/rc.local (Debian based distro's), or whatever script is run at the end of the boot process. The Shared Folders service should mount them automatically, but that doesn't always happen.
In my case /etc/rc.local is /etc/init.d.

It then says that if you add the command in my case to /etc/init.d so that it automounts at boot time as above you have to use the fully qualified path to the shared folder on the guest:

Code: Select all

mount -t vboxsf share /home/<username>/host
So I did that along with the options "-o uid=1000,gid=1000" from above and what happens is that the Windows folder doesn't get mounted at /home/mike/host but rather at /media/sf_share and everything is still owned by root.

Could somebody please tell me what I'm doing wrong. I've looked at the foums, Googled and read the HOWTO and I can't find a consistent answer.

Thanks very much in advance.

Best,
Mike
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: automount and shared folders

Post by Perryg »

/media/sf_share and everything is still owned by root.
This only happens if you have select to auto-mount the shared folder in the shared folder setup. You can use auto-mount but you must add your user name to the vboxsf group on the guest.
mikeybikey
Posts: 31
Joined: 10. Dec 2012, 20:19

Re: automount and shared folders

Post by mikeybikey »

Hi

I was already in the vboxsf group. (I just double-checked.) I put the script in init.d like I said and disabled automount in Settings > Shared Folders and now it neither mounts at /media or at /home/mike/host. I turned off automount in Settings > Shared Folders because "share", the name for the Windows folder, always got mounted as /media/sf_share with everything owned by root so I thought the other way was the way to go. This is the script I added to /etc/init.d:

Code: Select all

#!/bin/sh
sudo mount -t vboxsf -o uid=1000,gid=1000 share /home/mike/host
I'm completely out of ideas now. Help!

Thanks very much in advance.

Best regards,
Mike
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: automount and shared folders

Post by Perryg »

Give me a bit (I'm in the middle of something) and I'll load up my F16 and see what is going on.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: automount and shared folders

Post by Perryg »

OK sorry but I was deep in it with another project.

Your init script is not correct and you need to set run levels and then run /sbin/chkconfig to have it in the proper rc.d

I did a quick search for you http://unix.stackexchange.com/questions ... rt-at-boot
mikeybikey
Posts: 31
Joined: 10. Dec 2012, 20:19

Re: automount and shared folders

Post by mikeybikey »

Hi Perry

Thanks very much for that. I kind of got part of the way to what you suggested. My previous init.d script was clearly inadequate. I've done about what I can do for today but I'll try to put a proper script together tomorrow and get back to you.

Just one question though. From what I've read you are supposed to use various commands to establish the Knn and Snn symlinks in the rcX.d directories or will the init script mechanism take care of that itself?

Thanks very much for your continuing help.

Best,
Mike
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: automount and shared folders

Post by Perryg »

You know I don't hold too much with standards, never believed in them.

The main thing you need is a proper header and the command. Use what ever you want in the run levels and it will work.
Keep in mind these scripts run at run level so you don't need the sudo and I usually use bash myself.

I'll send you a pm with some generic things but this in no way a VirtualBox issue so not going to post to public.
mikeybikey
Posts: 31
Joined: 10. Dec 2012, 20:19

Re: automount and shared folders

Post by mikeybikey »

Thanks Perry

That would be great and thanks for the answer about chkconfig setting the run levels.

Best regards,
Mike
Post Reply