By Marcel van der Veer
March 2022

Published in Tech Tips

More on Debian, NAS, Samba

There are many recipes around to convert an obsolete PC into a DIY NAS for use on a Windows-machine network. Here is mine, used to convert a workstation into a decent NAS for backup purposes. This saved a deprecated enterprise-quality machine from a premature end on the scrap heap.

I present my notes here since some of the recipes on the web gave me a read-only share under Windows; this procedure reproducibly gives me the read-write share that I need.

The machine sits upstairs and our LAN upstairs is wifi-bridged to the LAN downstairs where the Windows machine is. Note that using a workstation as a NAS is not a low-power option for 24/7 use. Since I use it as backup device, there is no need to have it running permanently.

FOSS solutions like FreeNAS require much minimum RAM to allow high workloads on the NAS. My workstation has less than the FreeNAS minimum requirement, but at least it is ECC which I consider an advantage for a NAS. The box runs a bare-bones Debian 11 image from a net-install. This homebrew NAS works just fine reaching transfer speeds up to 55 MB/s over wifi, which is almost best possible speed and more than enough for us at home. No need for SSDs in the NAS, since wifi clearly is the bottleneck.

In setting up the NAS, we work as superuser root on the Debian box. You can also execute all commands using sudo. First we make Debian up-to-date and install samba, our trusty FOSS SMB/CIFS solution.

# apt update
# apt upgrade
# apt install samba

Next I created a new user, share. Pick any name you fancy. Then we add share to the samba database, give it a samba password, and enable the samba user.

# /sbin/adduser share
  ... you are prompted for information here
# smbpasswd -a share
  ... you are prompted for information here
# smbpasswd -e share

Now we make a directory for share that Windows mounts as network drive later.

# mkdir /home/share/samba
# chmod ugo+rw /home/share/samba

I gave everyone rw permission otherwise Windows would not write to my network drive. Since our network is shielded from the outside world I can live with this.

Finally we tell samba that we have a fresh network drive on offer. Edit samba's configuration file, and make sure the Workgroup name matches that of your Windows box. Then add the new share at the end of the file.

# vi /etc/samba/smb.conf
   workgroup = WORKGROUP
   path = /home/share/samba
   browseable = yes 
   read only = no
   writeable = yes
   create mask = 0777
   directory mask = 0777
   valid users = share

Apparently one cannot give a share the same name as the directory that is hosted. Just to be sure, the share is named [share] while the hosted directory is named samba. Next we restart samba, so it reads the configuration file anew.

# systemctl restart samba

You will need to know the IP address of your hobby NAS; there are several ways to discover that. Here we use as an example. I told my router to always assign the same IP to the NAS.

Now, on Windows, open Explorer and click 'This PC'. On the now visible 'Computer' tab select 'Map Network Drive'. Fill out at least the following:

Folder: \\\share
Tick 'Reconnect at sign-in'
Tick 'Connect using different credentials'

You are now prompted for credentials, which are the samba user name and samba user password you entered on Debian. After Windows establishes a connection, the drive will appear under 'This PC' after a minute or so. Note that it shows up as NTFS, while the host filesystem is ext4. Don't worry. You now have your network drive at your disposal!

All blog posts