In the previous article, I talked about setting up a shareable drive in Linux with NFS. Although while researching, I did check out setting up a shareable drive with SMB using Samba.
While I am sticking with NFS for my use case since I am communicating between Linux servers, It might be useful to know how to setup drive with SMB which can be accessed from a Windows system as well.
SMB stands for Server Message Block. It is a network protocol that allows users to share files, printers, and other information between computers. It is also known as Common Internet File System (CIFS).
If you want to have a shareable drive which communicates with Windows systems, you will need to setup a shareable drive with SMB.
Samba ↗️ is an open-source implementation of the SMB protocol. It allows Linux systems to communicate with Windows systems using SMB protocol.
We will learn how to set it up correctly and make a drive network shareable.
Once again we need at least two machines to setup a shareable drive. One will be the server and the other will be the client.
First, let’s setup the server machine. I am using Debian 12 but the commands should be similar for Ubuntu and other Debian based distros (or replace some installation commands with your distro’s package manager).
Let’s install Samba on the server machine.
Once samba is installed, we will add ourself as a user to samba.
<username> with your username.
Now we will create a directory which we will share with the client machine.
Next, we will edit the samba configuration file.
Go to the very bottom of the file and add the following lines.
What this is doing is creating a shareable directory called
/media directory. It is also allowing the user
<username> to access it.
We have also marked this as
read only = no, which means that the user can read and write to this directory which is most likely your use case as well but feel free to update any values as per your need.
You can read more about the configurations on the available man page ↗️
Once you are done, save and exit the file.
Next, we will restart the samba service.
That’s it from the server configuration point of view, let’s move to the client setup now.
Now, we would pretty much do the same thing as we did in the previous blog with few additional steps.
First, we will save our samba credentials in a file. This is required because when we try to connect to the server, it will ask for the password and we don’t want to enter it every time.
<password> with your username and password that you added during the samba setup on the server.
Next, we will create a directory where we will mount the shareable drive.
Now, we will mount the shareable drive.
192.168.0.100 with your samba server IP address.
This will mount the shareable drive on the client machine. You can now access it from the
If you want to mount the drive automatically on boot, you can add the following line to your
Once again, replace
192.168.0.100 with your IP address.
mount -a command to check if the drive is mounted correctly.
In this section, I will just list down few things that I encountered while setting up the shareable drive.
If you are using a firewall, you will need to allow the samba port. The default port for samba is
If you are using
ufw firewall, you can directly use the
samba rule and add it to the allow list.
If for some reason you are not able to mount the drive, you can use the
dmesg command to debug the issue.
I have found this very helpful in debugging the mounting issues. Looking for the messages related to the mount operation and in case of any errors it will most likely tell you what is wrong along with the error code.
Use that to find the relevant solution to your problem.
In this article, we learned how to setup a shareable drive with SMB using Samba. We also learned how to mount the drive on the client machine and how to auto mount it on boot.
While I am sticking with NFS for my use case, I hope this article was helpful to you in setting up a shareable drive with SMB.
I hope you found this article useful. If you have any questions or feedback, please feel free to reach out to me on X / Twitter ↗️.
Until next time 👋.