Note: This post is merely a note of instructions for merely testing. If the instructions work out for you as-is, then great! If not, stay tuned for an update for a fix in case you follow these instructions and you still cannot access your file-share directory from Windows.

Hardware

You will need for this lab the following

  • A computer with a GNU/Linux distro that makes use of apt and systemd (Debian, Ubuntu, Linux Mint, et al).
  • An external HDD formatted in the NTFS filesystem (any store bought Western Digital or Seagate 2.5” HDD external will do).
  • And of course monitor, mouse, keyboard, and so forth (speakers optional unless you want to listen to music while doing this lab).

Instructions

A. Making a folder

First, let’s do a simple command to create a folder of which we’ll point later for our external HDD to mount to every time after boot. So assuming you have the command line terminal ready type the following into the command prompt:

User@MyLinuxComputer:~$ sudo mkdir -p /home/<YourUserName>/MExHDD/

For <YourUserName>, it’s your user name that you have chosen for your system user account.

A.1 Checking if the folder was made

Using the ls command you’ll see the folder MExHDD showing up in the command prompt

User@MyLinuxComputer:~$: ls
Desktop
Documents
Downloads
Music
Pictures
Public
Templates
Videos
MExHDD

B. Setting up the external HDD for automatic mounting upon cold-boot startups in Linux.

To make sure that your external HDD will always be mounted upon cold-boot. The reason for this is that when you attach the external HDD, the mounting is temporary and so there is inconsistency at times when you need to use them for particular applications, such as usage for SAMBA, wherein you need permanent mounted storage devices - like that of the very storage device of which the GNU/Linux OS is running from.

Note If you’re not familiar with using vi or vim, two popular text editors, then use nano, gedit, or any other GUI text editor to make your life easier. But I’ll be using vi in this tutorial.

B.1 Checking out the fstab config file

So, to begin, open up a command line terminal and type the following sans (user@MyLinuxComputer:~$:

user@MyLinuxComputer:~$ sudo vi /etc/fstab

This will immediately show you something of the following:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
# 
# If `blkid` is not showing external HDDs connected to the server,
# use `sudo blkid -c /dev/null` clear the blkid's cache and see all attached
# storage devices!!
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=f40e6d53-c1b6-40da-b184-d847a7da669e /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=30FB-E03E  /boot/efi       vfat    umask=0077      0       1
/swapfile                                 none            swap    sw              0       0

Now I know that the entries are not so easy to read given that the values are not neatly under each of the labeled columns but if entered more neatly in a table, it’d read like the following

UUID <file system> <mount point> <type> <options> <dump> <pass>
UUID=f40e6d53-c1b6-40da-b184-d847a7da669e   / ext4 errors=remount-ro 0 1
UUID=30FB-E03E   /boot/efi vfat umask=0077 0 1
  /swapfile none swap sw 0 0

This is a file called the File System Table (or “fstab” for short). This configuration file is responsible in determining which devices (virtual or physical) are to be be used upon booting up the Linux OS installation.

The commentary (“Use ‘bilkid’ to print…”) is not found typically on default as it’s really courtesy note to let the user know, typically a desktop user and not a network administrator, of what the fstab configuration file does and what you can do with it along with a pointer of which section of the fstab manual (i.e. “man page” or “man”) to read up more on.

Okay so what do we do now with this configuration (“config” in lingo)?

Well, as you can note from the comments, you have a program called Block ID or blkid for short. The program is designed to extract information about any “block” unit that is used for storage (Computers will see storage devices as merely “blocks” of which you can contain information in - think here like something like a Chest Block in Minecraft).

In this case what information precisely are we looking for? For this instance, just one thing: the UUID. The Universally Unique Identifier, or UUID, is a number that is meant to be generated and applied to storage devices and are unique from that of another.

so let’s exit from the fstab with the command :q if you’re using vi or vim. If you are using another editor, simply exit the editor.

B.2 Using blkid to find information about our external HDD

Back at the terminal, we’ll enter the following:

user@MyLinuxComputer:~$ sudo blkid

/dev/sda1: UUID="5c842092-dfbd-450f-a664-11075f3a5e40" TYPE="ext4" PARTUUID="621afbba-8265-4228-9612-8fd2508ba9cf"
/dev/sdb1: UUID="30FB-E03E" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="b3b0d3b4-7c66-49e4-8814-6a8b15bc97c5"
/dev/sdb2: UUID="f40e6d53-c1b6-40da-b184-d847a7da669e" TYPE="ext4" PARTUUID="a53b45da-a9f0-4c5b-bcb4-53e006a54db3"
/dev/sdc1: UUID="3669536E4F7BC8E5" TYPE="ntfs" PARTLABEL="My Passport" PARTUUID="5ceb561b-b87b-4c54-83c4-64ef33d765c4"

As you can see here, we have the return of not ust the UUID number, but also the type of file system (fs) such as ext4 and vfat. We also see the UUID for the partition numbers for each storage block (i.e. PARTUUID). In addition, there is even extraction of the labels of each partition found in some of the storage blocks in each storage device.

To examine effectively the data to then use to incorporate into the fstab configuration file, let’s understand what we are seeing:

We see from the results from the blkid program that we have three listings of storage units (/dev/sda1, /dev/sdb1, /dev/sdb2/) but we have, in actuality, two hardware storage devices. How can we tell? well there are a few details with the acronynim laden results prompted to us by blkid and in order to do that, let’s look at one of the listings, /dev/sda1:

Here we are told that under the directory where the listing of devices (dev) there is a primary storage device (sda) and a single partition in that primary storage block of the storage device (the 1 in sda1).

NOTE: Before going further, to clairfy, sd stands for SCSI-device. But the definiton has been extended to also mean USB device, SATA device, and any other removable storage device, so today, sd means any storage device.

From this data (storage device sda at the primary, 1 partition) we find that the Universally Unique Identifier (UUID) of the storage block within the primary storage device, is of the value of 5c842092-dfbd-450f-a664-11075f3a5e40. We also see that the type of file system the storage block was formatted for was ext4 also known extended file system version 4, the partition UUID is of the numeric value of 621afbba-8265-4228-9612-8fd2508ba9cf

The only two pieces of information that we have to use for later are the UUID and the file system type that the block has been formatted to support, in this case ext4.

B.4 Adding the information gotten from blkid to the fstab file

With those two pieces of information we can then input an entry to fstab configuration file.

at the command prompt we bring back the fstab file by typing the following into the command prompt:

user@MyLinuxComputer:~$ sudo vi /etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=f40e6d53-c1b6-40da-b184-d847a7da669e /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=30FB-E03E  /boot/efi       vfat    umask=0077      0       1
/swapfile                                 none            swap    sw              0       0

Returning to the fstab configuration file, we see that there are several piecse of information already entered:

  1. The UUID of /dev/sdb2

  2. Mount Point : The location of the partition that is supposed to be mounted upon boot (/ or root),
  3. Type : The type of file system which is ext4
  4. Options: options of access to the device/partition - you can read up more information on this section by reading the manual page for mount program (link - search for “Filesystem Independent Mount Options”)
  5. Dump : The options for enabling backing of the device/partition in case you want to make periodic backups of the data (in this case speciically sdb2)
  6. Pass : Then finally order for which to have the program fsck, or File System Check/Repair program to run (although usually the value here is set to 0).

Every entry that has a hash symbol (“#”) is a comment.

So in this case, from the data that we have from blkid, we’ll enter the following to the fstab configuration file using vi:

User@MyLinuxComputer:~$: sudo vi /etc/fstab

and then adding the following after the very last entry

# My External HDD or MExHDD

UUID=d06a2090-d597-4175-97c3-ccf6cf49113c /home/<YourUserName>/MExHDD ntfs defaults 0 0

after this, we save the file and exit the text editor.

B.4 Restart the system

After this you’ll want to restart the system by entering the following command at the command prompt:

User@MyLinuxComputer:~$: shutdown -r 

This will make the system take about a minute exactly from the time you’ve entered this command to then shutdown and then reboot.

C. Setting up Webmin

Webmin is a web-based interface that for easy remote UNIX system administration that even allows for the use of using the command line as root and get away with just about anything, making Webmin a very convenient and powerful tool.

The reason we’re going to install Webmin for our SAMBA setup is because usually SAMBA consists on editing configuration files and running scripts to create users and setup file-sharing directories for the network but Webmin, with its provision of a GUI web-based interface, allows for this setup be seamless.

Since this tutorial assumes that you’re using a Debian-based GNU/Linux distribution (Debian, Ubuntu, Linux Mint, et al).

Note As of the time of this writing, I have personally have tested Webmin version 1.910 and have noticed that certain Webmin modules that involve APT do not actually work and attempts of using them for installing packages remotely have resulted in “404 file not found” errors to be prompted. So if in case you are using version 1.910 or newer, and the package install attempts result in being prompted with “404 file not found” errors, I’ll be leaving here a command line code snippet that you can simply copy and paste which includes all the packages that are going to be needed by the Webmin SAMBA module in order for it to operate correctly.

C.1 Prepare system for Webmin installation.

So that you don’t get a complaint by your operating system of missing dependencies (additional programs that Webmin will need to run), go ahead and type the following command string into the command prompt:

sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python

What this command simply does is install the following list of packages:

  1. Perl
  2. libnet-ssleay-perl
  3. openssl
  4. libauthen-pam-perl
  5. libpam-runtime
  6. libio-pty-perl
  7. apt-show-versions
  8. python

C.2 Setting up Webmin Repository for installation

After installing the pre-requisite packages, we then can now setup the system to be able to install Webmin through the APT package installation system.

C.2.1 adding the Webmin repository to the sources.list configuration file

You’re going to have to first add the address of the Webmin software repository (where you’ll be able to retrieve and install from).

To do this, you’ll need to edit a file called sources.list. This file contains all the repositories that are necessary to keep your GNU/Linux installation up and running and up to date.

So, with the help of a text editor, you type the following command to open sources.list.

user@MyLinuxComputer:~$: sudo vi /etc/apt/sources.list

and we get the sources list of the looking something like the following

#deb cdrom:[Sonix OS 13.1 _Porsche911_ - Release amd64 20181217]/ bionic contrib main non-free

It is in here, after the last entry (“contrib main…”) that we enter the following line

deb https://download.webmin.com/download/repository sarge contrib

after this you want to download the GPG key so as to secure the listing in your sources.list config file

As according to the Webmin website:

You should also fetch and install my GPG key with which the repository is signed, with the commands :

cd /root
wget http://www.webmin.com/jcameron-key.asc
apt-key add jcameron-key.asc 

C.3 Install Webmin

After this you should be able to install the very latest release with the following commands:

apt-get install apt-transport-https
apt-get update
apt-get install webmin

Install SAMBA

Note: Before this section begins note that as of the time of this writing (5.17.2019) Webmin ver. 19.10 has not been performing as expected when it comes to how some Webmin modules are able to automatically install from APT software such as SAMBA, Apache, and so on, so if in case the modules still do not work after version 19.10, then consider the given string of commands that will install the series of packages that will make it possible to administer the SAMBA server from within Webmin. Otherwise, follow the instructions as given

As root if in case Webmin keeps giving 404 errors (after which, select in the main menu option “Refresh Modules” to get the Webmin SAMBA module activated and ready to use):

apt-get install libsmbclient samba-libs libwbclient0 python-dnspython python-ldb python-tdb python-samba samba-common samba-common-bin tdb-tools samba attr libnl-route-3-200 libibverbs1 ibverbs-providers librados2 libcephfs2 samba-dsdb-modules samba-vfs-modules

To install you simply go to the option menu on the left side of the screen “Un-used Modules” and you will select the Samba Windows File Sharing module. There you will be taken to a page called “Install Packages” and then once the list of software is built and ready to install, select the button “Install Now”.

Webmin will do the installation automatically and will then refresh the page and have the Samba Windows File Sharing module ready to use.

D. Setting Up The File-Share

Let’s review for a second here to see what we managed to do:

  1. We made sure that for ever cold boot, you have the external HDD to be mounted along with all other storage that is registered in the /etc/fstab
  2. We Installed Webmin
  3. We Installed SAMBA and all necessary software for it to work with Webmin

Now we the rest of the guide involves Webmin alone. So there is, thankfully, no more need for a terminal as there is nothing but ease-of-use of using a Web based graphical user interface.

D.1 Convert Linux Users

We’re going to, before doing anything is having to convert the User(‘s) accounts in your Linux machine into Samba Users. This way, we can then set the rules for each SAMBA user such as access passwords for when you have to enter credentials in Windows when attempting access to a file-share directory (or “folder”).

To do this, you just go to the menu “Convert Users” in the main Samba Windows File Sharing menu page.

After this you select “Convert Users” and the system will do the rest.

D.2 Samba Users setup

Going back to the main administrative page for Samba Windows File Sharing, you select “Samba Users” and it’ll take you to another page that lists out the Samba Users that the Samba server knows of.

Select your User account that you have converted in the previous step and then select the radio button for “New Password” and then enter your password.

Note: If you wish to have Webmin to generate a new password for you, select the “key and plus” symbol button to have a new password randomly generated for you.

After this you select “Save” and then you’ll be returned to the Samba Users listing page and then you select “Return to share list”

Repeat the last three steps for any other accounts you want to setup a password with.

D.3 Setting up a file-share

Back at the Samba Windows File Sharing web page, select the tab that is labeled “Create a new file share”

Here. you will enter the following information in the form:

  • The Share name: here you will enter the name that you will then enter in Windows to access the directory that you will be uploading and downloading files. Call it “Samba-Share” for the sake of this tutorial.
  • In Directory to share, enter the directory address of the particular directory (“folder”) that’s within the external hard drive that you wish to share. In this case, it’s /home/<YourUserName>/MExHDD or /home/<YourUserName>/MExHDD/whatever-directory-you-want-to-share-specifically. After this, select “Create” and then Return to the share list main page.
  • Select the name of the file-share you just created, we’ll assume that you called it MExHDD. Once you are at the select the “Security and Access Control”. In the “Security and Access Control” panel, make sure to select the radio button “Yes” for the option Writable? - this option is going to enable you to upload and create files within the directory that has been chosen to be the file-sharing. After this select “Save” and then select the Retrun to share list button.
  • Restart the Samba server by selecting the “Restart Samba Servers”

D.4 Accessing the file-share directory from Windows

Here is the moment of truth!

Because if this doesn’t work, then I’ll have to ask you to come back and allow me to figure out where I did wrong in this lab. Otherwise enjoy!

Alright then, assuming that you know how to use the program ifconfig in order to check the local IP address of your Linux computer. For example let’s say that the LAN IP is 192.168.2.220 - keep that in mind because we’ll need it!

So, first thing is first: open up in Windows an instance of Windows Explorer and then on the address bar the following:

\\192.168.2.220\MExHDD

This will bring up immediately a prompt from Windows to enter the user name and password. Enter the username and password you had setup prior in the SAMBA Admin panel earlier and you should see immediately the directory that you had setup to do the file-sharing in!

Enjoy!…and there are some notes

The thing that I’ve come to find in some instances, from what I’ve been reading in forum posts online is that you have to sometimes check the permissions of the directory that you have set up for the particular folder that your external HDD - or any storage unit for that matter - to mount to. The reason being is that if the folder’s file permissions are restrictive, SAMBA will not be able to work and you’ll be getting a false warning that it may be a network problem for the reason why you can’t access the file-share directory when, in fact, it’s the file permissions for the folder that are causing the inability to access the directory.

But other wise, that’s about it. I hope this guide has been of help and if you