WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How to mount VirtualBox shared folder?  (Read 25302 times)

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
How to mount VirtualBox shared folder?
« on: January 28, 2010, 04:27:20 AM »
How can I mount a VirtualBox shared folder? VBox-OSE-additions.tcz is installed. VirtualBox is running on WINDOWS XP, TC is 2.8 Folder is C:\111 it is named 111 in VB, destination folder exists.

Tried

Quote
sudo mount -t vboxsf 111 /mnt/111
sudo mount -t vboxsf c:\111 /mnt/111

with no success. Error message:

Quote
unknown mount option `'


Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline libretto

  • Jr. Member
  • **
  • Posts: 64
Re: How to mount VirtualBox shared folder?
« Reply #1 on: January 28, 2010, 04:48:47 AM »
Hi bmarkus,

Don't know if this works in your case, this works for me on a Linux Machine running VB XP:
Quote
Add share folder in Virtualbox
==============================
1. installed VirtualBox Guest Additions
2. Under Windows XP, my shared_folder(in this case in fedora is A4G's "Documents") is simply mapped to a drive letter using the following command:
   C:\> net use s: \\vboxsvr\Documents
Please let us know if it works.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: How to mount VirtualBox shared folder?
« Reply #2 on: January 28, 2010, 05:12:10 AM »
Thanks, but unfortunately it is the opposit direction. You are running WINDOWS on LINUX while I'm running LINUX on WINDOWS host.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline libretto

  • Jr. Member
  • **
  • Posts: 64
Re: How to mount VirtualBox shared folder?
« Reply #3 on: January 28, 2010, 05:22:03 AM »
try this
Quote
1. Install Guest Additions… from the Devices menu, then run mount /media/cdrom.
2. Run # sh /cdrom/VBoxLinuxAdditions.run mount -t vboxsf
reboot
# mount.vboxsf [the_name_of_the_shared_folder] /media/[name_of_mount_point]

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: How to mount VirtualBox shared folder?
« Reply #4 on: January 28, 2010, 05:28:47 AM »
Thanks it works:

Quote
sudo mount.vboxsf 111 /mnt/111

Regards... Béla
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: How to mount VirtualBox shared folder?
« Reply #5 on: February 06, 2010, 05:08:59 PM »
Even though I use VirtualBox frequently to run TC, I never wanted to install VBox-OSE-additions.tcz just to be able to use vboxfs. This is due to the amount of dependencies (incl. Xorg) for which I typically have no need or use.

I therefore had a bit a poke around and found the following minimalistic way just to use the VirtualBox shared folders feature:

(1) Install the VBox-OSE-additions-modules-... extension (containing just the kernel modules), e.g.
    tce-load -wi VBox-OSE-additions-modules-$(uname -r)

(2) Extract /usr/local/sbin/mount.vboxsf from VBox-OSE-additions.tcz. This file will have to be copied to /usr/local/sbin with the suitable ownership (i.e. root:root) and permission (i.e. 755)

(3) Ensure that the 'vboxvfs' module (for TC 2.x) or 'vboxsf' module (for TC 3.x) is loaded, e.g.
for TC 2.x:    lsmod | grep -q vboxvfs || sudo modprobe vboxvfs
for TC 3.x:    lsmod | grep -q vboxsf || sudo modprobe vboxsf

After this you can mount VirtualBox shared folders with a command like
    sudo mount -t vboxsf -o nodev d-drive-rw /mnt/d-drive-rw
or
    sudo mount.vboxsf d-drive-ro /mnt/d-drive-ro

Please note that these steps do not use the additional user (i.e. vboxadd) and group (i.e. daemon) that the VBox-OSE-additions extension creates. But according to my (limited) testing this does not appear to be a requirement.

I guess this could be put into an additional extension. Or the current extension could be split into a vboxsf and a video driver related extension. But I don't consider this to be my call. I was just curious to find a different way and thought I share the information here so that others might benefit from it.


EDIT: Made corrections for the fact that according to the changelog for VBox v3.1.8 "... renamed the guest kernel module from vboxvfs to vboxsf ...". Therefore for TC 2.x (where the additions were based on VBox v3.0.12) the module name is 'vboxvfs' whilst for TC 3.x it is now 'vboxsf'. Plus another minor adjustment to avoid a "hard-coded" kernel version.
« Last Edit: June 07, 2011, 09:42:56 PM by maro »

Offline Robert

  • Newbie
  • *
  • Posts: 2
Re: How to mount VirtualBox shared folder?
« Reply #6 on: March 13, 2011, 01:01:12 PM »
(2) Extract /usr/local/sbin/mount.vboxsf from VBox-OSE-additions.tcz. This file will have to be copied to /usr/local/sbin with the suitable ownership (i.e. root:root) and permission (i.e. 755)

Hi

Sorry for digging up this old thread, but I'm a Linux beginner and am having problems following these instructions. Could you explain exactly how I extract this specific file from this extension?

I'm running Micro Core 3.5.1 and have so far downloaded and installed the required virtualbox-ose-additions-modules-2.6.33.3-tinycore.tcz successfully. I'm only looking to be able to read and write a few files in the shared folder on my host, nothing advanced.

Any help is appreciated. Thanks.

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: How to mount VirtualBox shared folder?
« Reply #7 on: March 16, 2011, 10:44:09 PM »
Well, it has been while since I wrote that so I just wanted to make sure that it's still working. Hence I did a fairly quick (and superficial) test to confirm that.

To extract a file from an extension I know of two ways: (1) use the 'unsquashfs' tool from the 'squashfs-tools-4.x.tcz' extension or (2) via a temporary loop-mounting of the extension. As an example for the latter you could do the following:
Code: [Select]
tc@box:~$ tce-fetch.sh virtualbox-ose-additions.tcz
tc@box:~$ mkdir extr
tc@box:~$ sudo mount virtualbox-ose-additions.tcz extr
tc@box:~$ sudo cp -p extr/usr/local/sbin/mount.vboxsf /usr/local/sbin
tc@box:~$ umount -d extr
tc@box:~$ rm -rf virtualbox-ose-additions.tcz extr
tc@box:~$ ls -l /usr/local/sbin/mount.vboxsf
-rwsr-xr-x    1 root     root         11260 Feb 19 21:39 /usr/local/sbin/mount.vboxsf

Furthermore I've found that for TC 3.x the command used in (3) needed a little "tweak": lsmod | grep -q vboxsf || sudo modprobe vboxsf (and have now amended the other post), but the rest seems to still work.

Obviously you'll need to ensure that the '/usr/local/sbin/mount.vboxsf ' file "survives" the next re-boot. So by adding it to the backup "white-list" (e.g. via echo usr/local/sbin/mount.vboxsf >> /opt/.filetool.lst) and ensuring that a backup is performed (e.g. via filetool.sh -b) this should be taken care of.


EDIT: Minor correction in light of the small change to reply #5.
« Last Edit: June 07, 2011, 09:36:01 PM by maro »

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: How to mount VirtualBox shared folder?
« Reply #8 on: March 16, 2011, 11:16:20 PM »
Code: [Select]
tc@box:~$ umount extr

Preferably
umount -d extr
to prevent leaking of loop device   ;)
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Robert

  • Newbie
  • *
  • Posts: 2
Re: How to mount VirtualBox shared folder?
« Reply #9 on: March 18, 2011, 05:30:19 PM »
I've got the folder sharing working perfectly now. Thanks a lot for your help maro, and for your advice as well tinypoodle.

Offline andrewb

  • Full Member
  • ***
  • Posts: 121
Re: How to mount VirtualBox shared folder?
« Reply #10 on: June 07, 2011, 02:57:13 AM »
Just to clarify the above posts:

All references to vboxfs should be vboxsf (why are the 's' & 'f' this way round - surely fs means filesystem?)

 /usr/local/sbin doesn't exist in the base system so you might want to use /usr/local/bin instead.

My simple setup has:
1.   virtualbox-ose-additions-modules-2.6.33.3-tinycore.tcz (or current from repository) as an on-boot extension

2.   mount.vboxsf is stored in /home/tc (this way it is backed up or persistently available)

3. bootlocal.sh has the lines:
         
Code: [Select]
ln -s /home/tc/mount.vboxsf /usr/local/bin/mount.vboxsf
modprobe vboxsf
mkdir /mnt/win
mount.vboxsf win-share /mnt/win
win-share is the name of the shared folder on the windows machine as set from the shared folders menu option in VirtualBox


Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: How to mount VirtualBox shared folder?
« Reply #11 on: June 07, 2011, 09:35:36 PM »
@andrewb: Thanks for noting that the spelling in reply #7 was incorrect. I've now updated reply #5 (and #7) to ensure that the information is valid for TC 2.x as well as TC 3.x.