By Marcel van der Veer
March 2022

Published in Tech Tips

More on Debian, Server

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 image from a net-install. This homebrew NAS works just fine reaching best possible transfer speeds over wifi, more than enough for us at home. No need for SSDs in the NAS, since wifi 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 /etc/samba/smb.conf, 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!

Sometimes a shared drive does not show up. In that case, you first check all connections. If that is in order, you check whether the server can be reached, and that port 445 is open since a firewall might block it. However, you may find that the error is not in networking at all, but that protocol versions on client and server side do not match. To comply with modern Windows versions, protocol should be SMB3. Add the following line in the global section of samba's configuration file, and restart.

   min protocol = SMB3

Older NAS devices may use protocols back to SMB1. The use of ancient SMB1 is nowadays advised against for security reasons. When disabling SMB1, some file managers may not readily show your Windows shares in a workgroup. For instance in Nautilus, you need to enter the server address in the indicated field and click the connect button.

All blog posts