Sharing folder from Windows Host to Freebsd Guest
Solution 1
VirtualBox shared folders are still not suppported on FreeBSD.
A FreeBSD ports committer has confirmed this on the FreeBSD mailing lists as of (2014-06-24):
Shared Folders for FreeBSD guests are not supported yet [...] There is some draft code and a kernel module for it but it's not working yet.
If you want to follow the state of the port, please search the mailing lists. There is also the #freebsd-vbox
IRC channel on Freenode. It was posted to the freebsd-hackers mailing list at the bottom of this post. You will find developers there.
Finally, here is what the virtualbox-ose-additions
port currently supports according to Chapter 22.2 of the FreeBSD Handbook as of today:
The VirtualBox™ guest additions provide support for:
- Clipboard sharing.
- Mouse pointer integration.
- Host time synchronization.
- Window scaling.
- Seamless mode.
As you can see, no shared folders support yet for FreeBSD.
Chapter 4.3 of the VirtualBox manual states:
Shared Folders are supported with Windows (2000 or newer), Linux and Solaris guests.
Yet again no FreeBSD. Use SMB shares for now, following the instructions that others have mentioned.
Solution 2
Ensure that you have configured sharing on the windows folder to the user you wish to use to share on freebsd.
I like to add the following to /etc/hosts for ease of use.
<ip address of server> vboxhost
eg.
192.168.56.1 vboxhost
First test mounting the folder:
mount_smbfs -I vboxhost //username@nameofwindowsbox/foldername /mnt
If this is correct you be prompted for the windows-user password.
To make it mount on boot add the following to /etc/fstab
//username@nameofwindowsbox/foldername /mnt smbfs rw,noauto 0 0
It should be mounted everytime you boot
If you don't want to be prompted for password add this in /etc/nsmb.conf:
[default]
[NAMEOFWINDOWSBOX]
addr=<ip address of host>
[NAMEOFWINDOWSBOX:USERNAME]
password=<myPassword>
Solution 3
I was fighting the same problem. A couple things on the Windows side allowed me to finally get mount_smbfs working in FreeBSD 9.0:
- Enable anonymous access for the system
Network and Sharing Center → Change Advanced Sharing Settings → Turn off password protected sharing
- Enable anonymous access on the folder via Simple Sharing
Properties → Sharing → Share... → Add 'Everyone'
In the Sharing properties there are two ways to create the share; Simple Sharing and Advanced Sharing. I was using Advanced Sharing, and for some reason I don't really care about at this point, that did not work; I re-added the share through Simple Sharing and then mount/smbclient finally worked.
Verifying that anonymous login works with smbclient:
[root@fileserv ~]# smbclient -N -I 192.168.56.1 '\\twblamer-pc\share'
Domain=[TWBLAMER-PC] OS=[Windows 7 Professional 7601 Service Pack 1] Server=[Windows 7 Professional 6.1]
smb: \> dir
. DR 0 Thu Dec 13 04:33:09 2012
.. DR 0 Thu Dec 13 04:33:09 2012
mydirectory D 0 Thu Dec 13 01:55:45 2012
Related videos on Youtube
Matthieu M.
Software Engineer at IMC since 2016. Avid follower of the Rust project, and still following Clang/LLVM (which I helped improved a bit with -Wdelete-non-virtual-dtor). Known to dabble in Python for scripting purposes. Interested in language design, and thus very interested in Rust (zero-cost memory safety, zero-cost data-race safety, concurrency) and interested in Haskell (type system, functional paradigm), which I unfortunately did not had time to explore yet... Interested in compiler design and low-level technics: Memory Allocation/Garbage Collection, Compiler Optimizations, Link-time Optimizations. Favorite answers of mine: Behold the PassKey Pattern Pick your Container in C++11 Favorite answers from others: to Can a local variable's memory be accessed outside its scope ? by Eric Lippert
Updated on September 18, 2022Comments
-
Matthieu M. over 1 year
What I am trying to accomplish:
- I have (at home) a PC with Windows 7 installed
- I would like to run a Unix in Virtual Box, because I am more used to developing / scripting on it
I settled on Freebsd at the moment, and I managed to install it and configure the network. The next step is sharing a folder from Windows to Freebsd so that I can easily edit files on Windows and on Freebsd both. Unfortunately it seems a though thing to do.
I rummaged on the net and found two different ways:
I installed the guest additions in freebsd using
pkg_add -r virtualbox-ose-additions
, the install proceeded switfly enough, and I edited/etc/rc.conf
to add the two suggested lines:vboxguest_enable="YES"
andvboxservice_enable="YES"
and rebooted.It did not work. The command to mount the system ends up in an error:
# mount -t vboxsf shared /home/myuser/shared mount: shared : Operation not supported by device
where
shared
is the name of the folder I setup in my virtual box settings for this VM.Is it actually possible to use a
vboxsf
filesystem type in freebsd ? Some comments seem to suggest it is not supported but finding up-to-date information is difficult.Next, I moved on to the samba approach. I basically followed the guide I linked it. Unfortunately it ends up with:
# mount_smbfs -N -I 192.168.56.1 //winuser@winmachinename/Shared /mnt/shared mount_smbfs: unable to open connection: syserr = RPC struct is bad
where
Shared
is the name of the shared folder I configured with windows, accessible to thewinuser
obviously. The ping works.I would like to note that I have no password on the windows guest account I am trying to connect at, it seemed easier, but perhaps that it's bothering samba somehow.
edit: working from PuTTY I had not seen that some messages were printed in the console:
smb_maperror: Unmapped error 3:31 smb_co_lock: recursive lock for object 1
both appear several times. /end of edit
If the direct filesytem sharing does not work, any idea how to get samba to do it ? The article suggest it's already be done by some at least.
Technical information:
- Host: Windows 7 Familial Edition (up-to-date)
- Guest: FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:15:25 UTC 2012 [email protected]:/usr/obj/usr/src/sys/GENERIC i386
- Virtual Box: 4.1.16 r78094
I am open to new suggestions to sharing as well. I would if possible prefer avoiding transferring files back and forth: it's not particularly efficient and always a source of confusing errors.
I am also open to changing systems. I like the philosophy of freebsd, but if it does not work, I have no qualms about moving to a linux.
EDIT:
This question is now purely of theoretical interest. I switch to using Ubuntu Server and managed to set it up without samba since vboxsf is well supported.
-
Matthieu M. almost 12 years@arved: no, I did not. Is it possible to configure an auto-mount through the smb client ? (Ideally I would prefer no samba, but hey, if it takes samba to work...)
-
arved almost 12 yearsI don't think it is possible to mount. But at least you can verify that there is no misconfiguration on the Windows Share
-
Matthieu M. over 11 yearsHi Pete. Thanks for your answer. Actually I changed arms and went with Ubuntu Server as I preferred a non-samba solution and FreeBSD does not support vboxfs yet.
-
Pete over 11 yearsYou don't need to install samba for the above solution it works from a default install of FreeBSD.
-
Pete over 11 yearsI would recommend giving freebsd another go if you have time as i've found its jail feature very useful for development purposes. At the moment i have 5 jails: www(apache22+php53), www(apache22+php54), MySQL, PostgreSQL, email-server. I have found this invaluable in terms of testing different versions of php and databases
-
Pete over 11 yearsAlso as FreeBSD has many terminals by default alt+f1 -> alt+f8 meaning if you go with jails you can build them in parallel saving you time when you use the ports system. Heck you could even setup a jail just to build software. I use qjail.
-
Matthieu M. over 11 yearswell, my purpose was to hack on Clang/LLVM, so it's quite fine with me.
-
Matthieu M. over 11 yearsThanks for the answer, I switched to Ubuntu in the end (which was easier as I had access to a friend that used it).
-
twblamer over 11 yearsYep, just wanted to try to help any future googlers.
-
Matthieu M. over 11 yearsAnd I thank you for doing so, had a very hard time finding any solution when I tried :)
-
Kristen Waite almost 10 yearsIf the OP was trying to get shares to mount on boot, they should omit the
noauto
on the fstab entry - the use ofnoauto
here prevents the mount on boot (i.e. you'd have to runmount -a
to get it to work after boot).