44

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.

Ben
  • 542

9 Answers9

49

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.

23

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

deoren
  • 373
  • 2
  • 9
5

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.

Torben
  • 271
  • 5
  • 6
  • I tried this solution to load the vboxsf module earlier ... It just froze my boot sequence so I had to remove it. – Rerito Nov 27 '14 at 09:05
  • 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 Nov 27 '14 at 12:46
  • I've added a warning to the answer to make things clearer. – Torben Nov 27 '14 at 12:51
4

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.

ezuk
  • 141
  • 1
    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 Apr 12 '17 at 12:44
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
3

As per 2020, the only (and clean) working solution for me is the one described in the Arch Wiki as posted by ultracrepidarian. In the meanwhile the entry in the fstab looks slightly different:

desktop  /media/desktop  vboxsf  uid=<user-id>,gid=<group-id>,rw,dmode=700,fmode=600  0  0
igiona
  • 31
3

It looks like the vboxsf lacks the fs-vboxsf alias (which is how kernel modules get autoloaded when mounting that filesystem type for the first time), so adding the alias in /etc/modprobe.d should do the trick:

$ echo "alias fs-vboxsf vboxsf" | sudo tee /etc/modprobe.d/vboxsf.conf
hyperair
  • 251
  • 2
  • 4
2

I had the same problem, and was working through the suggested solutions, but without success. Torben's solution froze the boot, so had to undo it. Then I thought I should troubleshoot /etc/fstab using sudo mount -a. The syntax of my entry looked perfect, but it still failed. I was also able to manually mount the filesysten using the mount command in the terminal window.

What I found is that I had spaces between the first two parameters (device and mount point). I replaced them with a tab and it works. Really?!!!!

svenyonson
  • 121
  • 1
  • 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. – David Foerster Feb 03 '15 at 01:10
  • All I know is that I backspaced over all of the white space and inserted a single tab and it then it worked. – svenyonson Feb 04 '15 at 03:52
  • 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. – jcaruso Nov 28 '15 at 17:53
  • 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 Feb 23 '16 at 19:15
1

I believe I've found the right way to deal with this in Arch Wiki. Use comment=systemd.automount option.

The above option goes in the /etc/fstab file with the other options. For example:

Fedora /var/ftp/pub/Fedora vboxsf uid=1001,gid=1001,comment=systemd.automount 0 0
guntbert
  • 13,134