SAMBA + Webmin + External HDD Short Version
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>/<NameOfYourExternalHardDrive>/
B. Setting up the external HDD for automatic mounting upon cold-boot startups in Linux.
Get the UUID and filesystem type of the external hard drive
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"
and then add an entry to the /etc/fstab config file
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 now
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
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
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
add the repo address to the list
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:
- 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 - We Installed Webmin
- 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>/MExHDDor/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 optionWritable?- 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 theRetrun to share listbutton. - 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