Results 1 to 8 of 8

Thread: Virtualbox Shared Folder Fstab Automount on boot Ubuntu 10.04 and/or 12.04

  1. #1
    Join Date
    Mar 2011
    Location
    United States
    Beans
    114
    Distro
    Ubuntu

    Angry Virtualbox Shared Folder Fstab Automount on boot Ubuntu 10.04 and/or 12.04

    PROBLEM:

    My shared folders won't automount at startup. Please help.

    Host: Windows 7
    Virtualbox Guest 1: Ubuntu Server 12.04
    Virtualbox Guest 2: Ubuntu Desktop 10.04

    I'm trying to integrate the Documents folders on all my machines. (Or, at the very least, set up a shared folder to automount on startup.)

    Step 1:
    I used the Virtualbox interface to setup a shared folder, selecting the correct host path
    Code:
    C:/users/username/Documents
    and checking "Make Permenant."

    Step 2:
    On my UbuntuServer12.04 guest, I created a mountpoint directory,
    Code:
    /home/username/Documents
    . On the other guest, there is already a Documents folder which I will use as the mountpoint.

    Step 3:
    I entered this into /etc/fstab on both guest systems:
    Code:
    Documents	/home/username/Documents	vboxsf	uid=username,gid=groupname	0	0
    Step 4:
    I even tested /etc/rc.local (made sure it was executable) by adding one of these three lines (tested one line, rebooted, replaced it with the next line, rebooted, tested the third...):

    Code:
    mount /home/username/Documents
    Code:
    mount Documents
    Code:
    mount -t vboxsf Documents /home/username/Documents
    Code:
    mount -a
    I'm pulling my hair out faster than it's already thinning and I'm going to go balled in no-time if I don't get some help (know what I mean?)

    SOLUTIONS:

    Shared folders are automatically mounted in /media/sf_sharename. There are 2 ways to make your shared folder appear where you actually want them to go.

    Solution 1:
    Bind them to another folder.

    1: Check if you are in the vboxsf group with
    Code:
    groups username
    2: If you don't see vboxsf, join the group by doing this, otherwise skip to step 3:
    Code:
    sudo usermod -a -G vboxsf username
    3: Bind the automatically generated shared folder to your mountpoint by putting this line into /etc/rc.local:
    Code:
    mount --bind /media/sf_sharename /path/to/mountpoint
    Solution 2:
    Just make a symbolic link:
    Code:
    ln -s /media/sf_sharename /wherever/you/want
    Last edited by deckerry; October 21st, 2012 at 01:53 AM. Reason: Found a solution (Thank you: Morbius1)

  2. #2
    Join Date
    Dec 2009
    Beans
    5,741

    Re: Virtualbox Shared Folder Fstab Automount on boot Ubuntu 10.04 and/or 12.04

    Since Version 4 of Virtual Box a Linux guest will automatically mount all host shared folders to:
    /media/sf_name-of-vbox-host-shared-folder
    Does that by itself without any interventions on the users part.

  3. #3
    Join Date
    Mar 2011
    Location
    United States
    Beans
    114
    Distro
    Ubuntu

    Re: Virtualbox Shared Folder Fstab Automount on boot Ubuntu 10.04 and/or 12.04

    Quote Originally Posted by Morbius1 View Post
    Since Version 4 of Virtual Box a Linux guest will automatically mount all host shared folders to:

    Does that by itself without any interventions on the users part.
    Oh my freakin' goodness. I didn't see that one coming. THANK YOU!!!!!!!!

    But Damn. I don't like that at all. How would you make content from
    Code:
    /mount/sf_Documents
    show up in
    Code:
    /home/username/Documents
    at startup then? By editing /etc/fstab or /etc/rc.local somehow?

  4. #4
    Join Date
    Dec 2009
    Beans
    5,741

    Re: Virtualbox Shared Folder Fstab Automount on boot Ubuntu 10.04 and/or 12.04

    You could create a symlink from one to the other.

    You could also bind it from one to the other:

    For a temporary bind mount try this:
    Code:
    sudo mount --bind /media/sf_Documents /home/username/Documents
    If that does what you want then stick that in rc.local - without the sudo.

    I prefer binds to symlinks but that's just me.

  5. #5
    Join Date
    Mar 2011
    Location
    United States
    Beans
    114
    Distro
    Ubuntu

    Re: Virtualbox Shared Folder Fstab Automount on boot Ubuntu 10.04 and/or 12.04

    Well, on my UbuntuServer12.04 guest, I just made a symbolic link and it works:

    Code:
    ln -s /media/sf_Documents /home/username/Documents
    But on my UbuntuDesktop, the changes to either /etc/fstab or /etc/rc.local were enough (even though there were directories in /media produced by Virtualbox.) Then I'm left with both the /media/sf_Documents folder AND folders mounted by /etc/fstab.

    Weird... and messy...

    NOTE: I posted this before reading the one by Morbis1, which is basically makes the thread solved. Thank you Morbis1!!!!!!!!!!!!
    Last edited by deckerry; October 21st, 2012 at 01:03 AM.

  6. #6
    Join Date
    Mar 2011
    Location
    United States
    Beans
    114
    Distro
    Ubuntu

    Re: Virtualbox Shared Folder Fstab Automount on boot Ubuntu 10.04 and/or 12.04

    Quote Originally Posted by Morbius1 View Post
    You could create a symlink from one to the other.

    You could also bind it from one to the other:

    For a temporary bind mount try this:
    Code:
    sudo mount --bind /media/sf_Documents /home/username/Documents
    If that does what you want then stick that in rc.local - without the sudo.

    I prefer binds to symlinks but that's just me.
    My only problem with symbolic links is this: If you are using Ubuntu Desktop with GNOME, you'll have to delete the original Documents folder which has cool little folder icons different from regular folder icons.

  7. #7
    Join Date
    Mar 2011
    Location
    United States
    Beans
    114
    Distro
    Ubuntu

    Re: Virtualbox Shared Folder Fstab Automount on boot Ubuntu 10.04 and/or 12.04

    Quote Originally Posted by Morbius1 View Post
    You could create a symlink from one to the other.

    You could also bind it from one to the other:

    For a temporary bind mount try this:
    Code:
    sudo mount --bind /media/sf_Documents /home/username/Documents
    If that does what you want then stick that in rc.local - without the sudo.

    I prefer binds to symlinks but that's just me.
    I absolutely love your --bind idea except there are permission issues. I tried this but it didn't work either:
    Code:
    sudo mount --bind -o uid=username,gid=groupname /media/sf_Documents /home/username/

  8. #8
    Join Date
    Mar 2011
    Location
    United States
    Beans
    114
    Distro
    Ubuntu

    Re: Virtualbox Shared Folder Fstab Automount on boot Ubuntu 10.04 and/or 12.04

    Quote Originally Posted by deckerry View Post
    I absolutely love your --bind idea except there are permission issues. I tried this but it didn't work either:
    Code:
    sudo mount --bind -o uid=username,gid=groupname /media/sf_Documents /home/username/
    I figured it out. The only reason binding wouldn't work is because I wasn't part of the vboxsf group. Here's how I joined the group:

    Code:
    sudo usermod -a -G vboxsf username

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •