Samba network drive

2023/02/04


Go back

I installed Ubuntu Server 22.04 in an old tablet and I connected a USB solid-state drive that I want to share in my local network via SMB. These are the steps I followed:

  1. Installed samba. It will install all the required dependencies for you:
    sudo apt install samba
    
  2. I edited the samba configuration file as super user:
sudo nano /etc/samba/smb.conf
  1. The file has lots of comments, but it has a global section, and then you add your own section. Under the global section, I did two things that are optional for you:

    a) I set the workgroup to the one I use in my local network.

    b) I limited the drive share to only one internet interface. In my case, ethernet (eth0 in this example).

    Note: The interfaces item was originally preceded with a ; character. You need to remove it, then make sure to add the same indentation as the rest of the lines (3 spaces in my case).

[global]
   workgroup = MYWORKGROUPNAME
   interfaces = 127.0.0.0/8 eth0
  1. Next, at the very bottom, I added an entry with the name of the drive share as it will show up in other machines. Then I added the configuration options below, using the same indentation as above.
[MyShareName]
  comment = This is the friendly name of my share
  path = /path/to/my/shared/drive
  browsable = yes
  guest ok = yes
  read only = no
  create mask = 0777
  directory mask = 0777
  writeable = yes
  force user = myuser
  force group = myuser

Note that myuser is the user that owns the /path/to/my/shared/drive directory.

  1. Then, you need to restart the services:
sudo service smbd restart
sudo service nmbd restart
  1. Finally, go to another machine and verify that by visiting the IP address of your server sharing the drive, you can view the contents of that drive.

For example, in Windows, open a File Explorer window and, assuming the server IP address is 192.168.0.5 go to the location \\192.168.0.5\MyShareName.

You should be able to create, modify and delete files and folders.