Skip to content

Instantly share code, notes, and snippets.

@blakerohde
Last active February 16, 2023 04:03
Show Gist options
  • Save blakerohde/18d7ee143b4cdf319a6ffc1d5e382007 to your computer and use it in GitHub Desktop.
Save blakerohde/18d7ee143b4cdf319a6ffc1d5e382007 to your computer and use it in GitHub Desktop.
Proper Fileshare for a Windows 10 Host and Ubuntu (Linux) VirtualBox Guest Using Samba

VirtualBox Samba Fileshare Quick-Start Notes by Blake Rohde, 2020

Environments

VirtualBox Host OS:Windows 10 Pro
VirtualBox Guest OS:Ubuntu 16.04 LTS

Windows 10 (Host) Setup

Enable SMB Windows features

  1. Click Start > Type Turn Windows features on or off
  2. Within Windows Features > Ensure both SMB 1.0/CIFS File Sharing Support and SMB Direct are enabled/checked
  3. Click OK
  4. Restart Windows if prompted

Enable insecure guest access

  1. Click Start > Type gpedit.msc to open the Local Group Policy Editor
  2. Within Local Group Policy Editor > Navigate to Computer Configuration > Administrative Templates > Network > Lanman Workstation > Double-click Enable insecure guest logons > Select Enabled > Click OK
  3. Close the Local Group Policy Editor.

Configure VirtualBox network settings

  1. Start Oracle VM Virtualbox Manager (VirtualBox GUI)
  2. Select the Guest Machine > Click Settings
  3. Select Network > Adapter 1 tab > Set Attached to: to be Bridged Adapter
  4. Click OK

Ubuntu (Guest) Setup

Create the fileshare directory

$ sudo mkdir /vm-files
$ sudo chown $USER:$USER /vm-files
$ sudo chmod 777 /vm-files

Install Samba and configure your user

$ sudo apt-get update -y
$ sudo apt-get install -y samba
$ sudo smbpasswd -a $USER

Configure Samba

$ sudo cp -pf /etc/samba/smb.conf /etc/samba/smb.conf.bak
$ sudo nano /etc/samba/smb.conf

Add the following to the bottom of the file:

[vm-files]
path = /vm-files
available = yes
valid users = <YOUR USERNAME HERE>
read only = no
browseable = yes
public = yes
writable = yes
map archive = no
create mask = 664
directory mask = 775

[global]
client min protocol = SMB3
client max protocol = SMB3
restrict anonymous = 2
encrypt passowrds = true

Restart and verify the configuration

$ testparm /etc/samba/samba.conf
$ sudo service smbd restart
$ sudo service smbd status

Find your Guest IP address

Since we configured the VirtualBox adapter as a Bridged Adapter, your Guest IP should be the same subnet as your Host IP. This is likely 192.168.x.x.

$ ipconfig

Windows 10 (Host) Connecting

  1. Open a Windows Explorer window > Select This PC
  2. Left/Alt-Click > Select Add a network location > Click Next > Click Choose a custom network location > Enter \\<YOUR GUEST IP ADDRESS>\vm-files > Click Next > Click OK

The Samba fileshare will now appear under the Network locations section on the This PC page within Windows Explorer.

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment