Virtualbox shared folder mount from fstab fails; works once bootup is complete

49,635

Solution 1

I ran afoul of this problem too. I mount /var/www using VBox shared folders functionality, so this was quite annoying.

The solution I found was to force the vboxsf module to be loaded early, before the mounting of file systems. Just add vboxsf on a line of its own in /etc/modules.

Another solution is to set noauto in /etc/fstab and manually mount drives in /etc/rc.local, but this wasn't such a good solution for me because by that time Apache has already started and been unable to find anything in /var/www.

Solution 2

In addition to Richard Turner's suggestion of adding vboxsf on a line of its own to /etc/modules, I suggest adding the _netdev mount option to /etc/fstab. I tested on Ubuntu 12.04 LTS and this seems to add just the right amount of delay for the mount to succeed.

My /etc/fstab entry:

dev /media/dev vboxsf defaults,_netdev 0 0

Solution 3

Richard's fix stopped working for me after the last update (VirtualBox 4.3.18, Ubuntu 14.04). Luckily I was able to fix it, by loading vboxsf right with the kernel:

# echo "vboxsf" >> /etc/initramfs-tools/modules
# update-initramfs -u

The first command adds a parameter to load the module to the kernel and the second updates the init file system. After a reboot I was able to use my fstab-mounts again :)

Warning: The boot process might freeze, if a shared folder cannot be mounted. So test your configuration, before you add the module to initramfs. If your system hangs anyway, you can boot in recovery mode to fix the problem.

Solution 4

With the shared folder listed in fstab I find that the boot will hang when it tries to mount it using VirtualBox 5 and Ubuntu 14.04. The solution seems to be to delay mounting until the GuestAddition service is available (Richard Turner's /etc/modules solution didn't seem enough for me).

To do this make sure you have noauto as the options for the shared folder in /etc/fstab. For example for a shared folder called vmshare:

vmshare    /home/user/share    vboxsf    defaults,noauto    0    0

Then add a line to /etc/rc.local to mount the share after booting:

mount vmshare

Solution 5

I just wanted to say that forcing the vboxsf module to load early helped me (as in Richard Turner's answer), but the fstab line still didn't work for me.

What I ended up doing was putting the mount command (which did work) into /etc/rc.local. A bit of a hack but it worked.

Share:
49,635

Related videos on Youtube

Ben
Author by

Ben

Updated on September 18, 2022

Comments

  • Ben
    Ben over 1 year

    I've got Ubuntu 13.10 installed in Virtualbox 4.3. The host machine is Windows.

    I have a couple of Virtualbox shared folders being mounted by /etc/fstab. Until recently this setup worked just fine, but after upgrading from Ubuntu 13.04 and Virtualbox 4.2 (at essentially the same time) the fstab mounting stopped working. I get the following error during boot:

    An error occurred while mounting /home/benme/Documents.
    keys:Press S to skip mounting or M for manual recovery
    

    Pressing M for manual recovery and then trying to mount manually also fails:

    root@benme-vb:~# cd /home/benme
    root@benme-vb:/home/benme# mount Documents
    /sbin/mount.vboxsf: mounting failed with the error: No such device
    

    But if I instead skip mounting during boot, wait for Unity to start and then mount manually in a shell, everything works fine:

    benme-vb ~ % ls Documents
    benme-vb ~ % sudo mount Documents
    [sudo] password for benme: 
    benme-vb ~ % ls Documents
        # actual file list omitted
    

    Note that when I mount manually I'm letting mount take all the options from /etc/fstab, and it works. This suggests to me that it's some sort of timing issue, where Virtualbox isn't "ready" to provide the shared file mounts at the point /etc/fstab mounts are run during bootup.

    Here's the fstab line, just for completeness:

    Documents       /home/benme/Documents   vboxsf  uid=benme,gid=benme,dmode=774,fmode=664     0   0
    

    Is there something I can do about this from the Ubuntu side? Or does anyone happen to know more about this from the Virtualbox angle?

    I've found an old report on the Virtualbox bug-tracker with identical symptoms, but in that case the user had updated Virtualbox without updating their guest additions and resolving that fixed the problem; this isn't happening here, I've definitely got the 4.3 guest additions installed.

  • ThePosey
    ThePosey over 10 years
    awesome! adding to /etc/modules worked perfectly. thanks Richard!
  • Richard Turner
    Richard Turner over 10 years
    @ThePosey Glad to have helped!
  • Reinis
    Reinis almost 10 years
    This was issue for me on Ubuntu Server 14.04 guest. And this answer (the /etc/modules solution) solved it for me. Thanks! P.S Btw, if you by chance, trying to figure out / fix things, enabled Auto-mount in Virtualbox settings, disable it again ;)
  • Rerito
    Rerito over 9 years
    I tried this solution to load the vboxsf module earlier ... It just froze my boot sequence so I had to remove it.
  • Torben
    Torben over 9 years
    Yeah, including the module that early might freeze the boot process, if your shared folder configuration is broken. However, I never experienced any boot freezes with a correct configuration...
  • Torben
    Torben over 9 years
    I've added a warning to the answer to make things clearer.
  • David Foerster
    David Foerster over 9 years
    Are you sure it was two space characters (ASCII code 32)? Because one or more of those should be just as fine as a tab character. Sometimes I accidentally type non-breaking space characters when I press my shift key to early or release it too late while pressing the space bar. They look the same but confuse many applications.
  • svenyonson
    svenyonson over 9 years
    All I know is that I backspaced over all of the white space and inserted a single tab and it then it worked.
  • mafrax
    mafrax about 9 years
    What is actual line of code/text that is used with this solution? @Reinis
  • Richard Turner
    Richard Turner about 9 years
    @qodeninja As I said in my second paragraph: "Just add vboxsf on a line of its own in /etc/modules.
  • jcaruso
    jcaruso over 8 years
    Switching my spaces for tabs worked for me. My existing /etc/fstab had spaces in it (as far as I could tell) and I replicated them exactly. The existing lines had a single space. But re-writing mine with tabs got everything working.
  • Mark Mikofski
    Mark Mikofski about 8 years
    This didn't work for me, but following Kevin Sadler's recommendation of using noauto to delay mounting then adding mount <sharename> to rc.local did the trick. I did not try Turner's solution.
  • Mark Mikofski
    Mark Mikofski about 8 years
    This didn't work for me, but Keven Sadlier's answer did.
  • Mark Mikofski
    Mark Mikofski about 8 years
    This works for me, even without using Turner's solution. Make a lot of sense too, since the Ubuntu Community Help page for fstab options says, "_netdev - this is a network device, mount it after bringing up the network." I did not have to load vboxsf in /etc/modules, just adding _netdev worked!
  • T.J. Compton
    T.J. Compton about 8 years
    This was the only solution that worked for me, using VBox 5.0.16 and Ubuntu 14.04
  • mattanja
    mattanja almost 8 years
    I had to add vboxguest and vboxsf to /etc/modules on a Ubuntu 14.04 guest system for this to work.
  • Zhenya
    Zhenya about 7 years
    This works for me too on Ubuntu 16.04, even without Turner's solution.
  • j_random_hacker
    j_random_hacker about 7 years
    I don't understand how Richard Turner's suggestion "helped you", but at the same time, the fstab line "still didn't work for you"...?
  • j_random_hacker
    j_random_hacker about 7 years
    Haven't tried this myself, but it looks promising.