# How to share a disk from XP host to FreeBSD guest



## rden (May 14, 2010)

Situation:
Host OS: Win XP (SP 3 ect)
Guest OS: FreeBSD x86 8.0 (release)
VirtualBox 3.1.8 r61349

Despite occasional comments currently the Virtual Box sharing is not available.

Best solution: samba (which in most cases auto loads when invoked on FBSD 8).

But even there some people have posted some amazingly complicated mixed with often unnecessary additional instructions.

Here is the steps:

1. On XP make sure File & Printer sharing is enabled.
Simplest way is right click on the folder you wish to share,
- tick the box that says "Share this folder on the network."
- if File & Printer sharing is not already enabled it will guide you through setting this up.
- Remember the name you gave for the share (defaults to the directory name).
If you want to write from the FreeBSD guest you will need to tick the next box: Allow network users to change my files.
_(Any half decent firewall, even the standard one included on a home router will keep outside people off your shares - but the best protection is to force users to login to the XP host with a password (even if only for your own private use) - it actually makes XP more secure from net based sniffers/attacks and even viruses.  I also [still] use ZoneAlarm Free - I also like to know what's trying to go out from my machine._

-- for my example I've shared D: \tmp on my drive as dtmp

2. (If not already running) start VirtualBox
- In the settings I have the network interface set to NAT (the default)
_--(some posters suggested Bridged interface must be used for Samba to work- not so)_
- Start the guest

3. Drop back to XP and open a cmd shell
a. type the command: 
	
	



```
hostname
```
    record the answer (mine is called box)

b. type the command: 
	
	



```
ipconfig
```
    look for the "Ethernet adapter VirtualBox Host-Only Network"
    record the IP Address (probably same as mine: 192.168.56.1)

4. Back to the FBSD guest, log in as root
- type the command:

```
mount_smbfs -I <answer-from-3.a> //<answer from 3.b>/XP-share-name/ FBSD-mount-point

when it asks for a password, just hit enter - that's right, [B]just hit enter*[/B]

[I]in my example:[/I]
    mount_smbfs -I 192.168.56.1 //box/dtmp/ /mnt
```

check if it is mounted.

* on my XP I do have user accounts enabled and must login with a password to use it, and have no user accounts defined without a password, and user guest is disabled_ (mostly to stop me kids getting onto and trashing my pc)_ 

------

5. Making things even easier for next time

edit the file /etc/nsmb.conf

skip to the end of the file and add the lines:


```
[default]
[BOX]              [I]<--use your hostname from 3.b, [B]must be in caps!!![/B][/I] 
addr=192.168.56.1  [I]<--use your IP num from 3.a[/I]
[BOX]            [I]<--again your hostname from 3.b, [B]must be in caps[/B] (including the X)[/I]
password=x
```

Here some might suggest: 'oh so we have to add a user "X" to Win Xp.'
*you do NOT have to add the user X to Win-XP!! (or FreeBSD)*
let me repeat that: *you do NOT have to add the user X to Win-XP!!*

Lets test this:
umount the drive from freebsd,
try the command

```
mount -t smbfs //x@<host>/<xp-share>/ <fbsd-mountpoint>

[I]in my example:[/I]
    mount -t smbfs //x@box/dtmp /mnt
```

Making it even easier:
edit your /etc/fstab
add the line

```
//x@<host>/<xp-share>   <FBSD-mountpoint>  smbfs  rw,noauto  0 0
[I]    If you wish change the noauto to auto.[/I]

[I]for my example I add:[/I]
    //x@box/dtmp  /mnt  smbfs  rw,noauto 0 0
```
save it and issue the command

```
mount <FBSD-mountpoint>

[I]for my example:[/I] mount /mnt
```

And that is it.
(BTW: I did not add my host "box" into my /etc/hosts - also not needed.)
-------
Will it work on Win 7?  Dunno - perhaps somebody who "_upgraded_" (<-- pronounced ROTFLMAO) to W7 may want to try it, personally I trashed my Win 7 partition (now my VirtualBox play area) coz
- never used W7 for anything XP couldn't do,
- on my Q8400 actually measured as running slower than XP (just has a lot more "noise" so looks faster but it's not)
- It's an annoying system, far too soon got sick of pop-ups asking 'me to grant myself permission' to do even simple tasks (even what set options to stop that they still sometimes come back) - what is with that?, ugly menus, and childish cartoon style login.
For mine W7 treats even administrators like a 3 year old kid in a candy shop - i.e. won't trust you to do anything vaguely responsible, at all.


----------



## gvkv (Oct 8, 2010)

It works fine in Windows 7.  Just right-click on the folder you want to share, select sharing, choose who you want to share with and you're done.  

What doesn't seem to work is using a bridged NIC adapter but it's easy enough to just enable a second NIC emulator.


----------

