How to share files with Samba (SMB) from Ubuntu and mount on Windows

I am using a Windows 7 VM under KVM/QEMU, and there is no direct way – as far as I know – to make a shared drive between the host and guest, like the vboxsf that exists on VirtualBox hypervisor.

The best solution I found in order to share files between the host and the guest is to use Windows Sharing, or in other words: Samba (SMB).

We will do that with Nautilus.

You should follow these steps on the host (samba server) side:

  • Install samba: “sudo apt install samba nautilus-share”
  • Right-click on the folder you want to share and choose “Local Network Share”
  • Enable, give it a name, and allow read/write if you wish to
  • Click Create Share
  • Run “sudo smbpasswd -a any_username“, you could just use the same account in linux, but take care that the SMB password set is not the same password used in your system

On the guest (Windows VM), you need to apply the following (make sure that the samba ports are open in your firewall):

  • Right-click on “Network” and choose “Map network drive”
  • Choose a drive letter
  • Add the folder in this way: \\SERVER_IP\shared_folder_name
  • It should prompt you for a username and password
  • Type as the username “COMPUTER_NAME\user_name“, where user_name is the any_username used when you ran the command smbpasswd above
  • Type the password and there you go!
  • Enjoy!

Sources:

  1. https://help.ubuntu.com/community/How%20to%20Create%20a%20Network%20Share%20Via%20Samba%20Via%20CLI%20%28Command-line%20interface/Linux%20Terminal%29%20-%20Uncomplicated%2C%20Simple%20and%20Brief%20Way%21
  2. https://help.ubuntu.com/community/Samba/SambaClientGuide

About SoCRaT

Cybersecurity Master's Student, Systems Engineer, OSS & Linux Geek
This entry was posted in Linux, Uncategorized and tagged , , , . Bookmark the permalink.

2 Responses to How to share files with Samba (SMB) from Ubuntu and mount on Windows

  1. Gray says:

    “Add the folder in this way: \\SERVER_IP\shared_folder_name”
    How do I know the server ip?

    Like

  2. Pingback: Ubuntu HowTo: How to properly configure Virt-Manager (QEMU/KVM) with Windows guest - TECHPRPR

Leave a comment