VB file sharing with Ubuntu guest and Windows 7 host

VirtualBox 4.0 can now mount shared folders automatically! I tried it and can now see my full C drive on Windows 7 from the Ubuntu guest.

VirtualBox 4.0 can now mount shared folders automatically!

Yes, you could always do it with a few edits of some system config files, but this puts it at a non-geek average user level, a file sharing for idiots perhaps. The instructions on creating shares is in the VB manual section 4.3.2 Automatic Mounting.

I tried it and can now see my full C drive on Windows 7 from the Ubuntu guest running in VirtualBox (VB). But, at first, it did not work, and a previous manually mounted share also stopped working, both with access permission problem. The big detail I missed:

Access to auto-mounted shared folders is only granted to the user group vboxsf, which is created by the VirtualBox Guest Additions installer. Hence guest users have to be member of that group to have read/write access or to have read-only access in case the folder is not mapped writable.

So after you create the share you have to add users to the vboxsf group. Using the Ubuntu UI you navigate to System, Administration, Users and Groups, then Manage Groups. Now find vboxsf and show its properties, from there you can add users. Reboot.

From the Oracle VM VirtualBox manual:

4.3.2. Automatic mounting
Starting with version 4.0, VirtualBox can mount shared folders automatically, at your option. If automatic mounting is enabled for a specific shared folder, the Guest Additions will automatically mount that folder as soon as a user logs into the guest OS. The details depend on the guest OS type:

With Windows guests, any auto-mounted shared folder will receive its own drive letter (e.g. E:) depending on the free drive letters remaining in the guest.

If there no free drive letters left, auto-mounting will fail; as a result, the number of auto-mounted shared folders is typically limited to 22 or less with Windows guests.

With Linux guests, auto-mounted shared folders are mounted into the /media directory, along with the prefix sf_. For example, the shared folder myfiles would be mounted to /media/sf_myfiles on Linux and /mnt/sf_myfiles on Solaris.

The guest property /VirtualBox/GuestAdd/SharedFolders/MountPrefix determines the prefix that is used. Change that guest property to a value other than “sf” to change that prefix; see Section 4.6, “Guest properties” for details.

Note
Access to auto-mounted shared folders is only granted to the user group vboxsf, which is created by the VirtualBox Guest Additions installer. Hence guest users have to be member of that group to have read/write access or to have read-only access in case the folder is not mapped writable.

To change the mount directory to something other than /media, you can set the guest property /VirtualBox/GuestAdd/SharedFolders/MountDir.

Solaris guests behave like Linux guests except that /mnt is used as the default mount directory instead of /media.

To have any changes to auto-mounted shared folders applied while a VM is running, the guest OS needs to be rebooted. (This applies only to auto-mounted shared folders, not the ones which are mounted manually.)

System
VirtualBox: 4.0.0 r69151
Ubuntu: 10.10 (maverick)
Kernal Linux: 2.6.35-24-generic
Window 7:
PC: p6230

Further reading

VirtualBox Shared Folders in Ubuntu 10.10 Guest with Windows 7 Host
VirtualBox

 


Ratkje- Vox

8 thoughts on “VB file sharing with Ubuntu guest and Windows 7 host”

  1. Very helpful.. I notice this has changed in the recent updates of VirtualBox.

    You would think the folks at VirtualBox would do a better job of their documentation of such a critical step in the setup??

    Anyway your instructions were very useful. Although, I notice I couldn’t
    sudo usermod -a G vboxsf username. However when I used the GUI the user was added to the group.

  2. hi kindly help i can see the drive E and F the windows in ubuntu. i am using latest VB 4.1.8. i have given permission in windows for the drives. but i cant assess. when i click the drive it shows this error :- The folder contains could not displyed. You do not have the permissions necessary to view the contents of “sf_E_DRIVE”….

    then when i click the drive to see sharing option. it shows this error:-
    ” net usershare’ returned error 255: net usershare add: cannot share path /media/sf_E_DRIVE as we are restricted to only sharing directories we own.
    Ask the administrator to add the line “usershare owner only = false”
    to the [global] section of the smb.conf to allow this. ”

    Help me plz plz plz….

Leave a Reply

Your email address will not be published. Required fields are marked *