Home How-To, Linux Ultimate Home Server Part 4 – Setting up Network Shares

Ultimate Home Server Part 4 – Setting up Network Shares

Now that we have our RAID array setup and working it would be nice if we could actually STORE some data on our home server. In this part I’m going to show you how you can setup some folders on your array from the command line and then share those folders across your network.

Once this is setup you’ll be able to drag and drop your files from any other Windows, Mac or Linux machine.

The first step is to set up some folders on your server. To do this we need to use the MKDIR command (MaKe DIRectory).

I would recommend creating a single folder called “root” first:

sudo mkdir /mnt/md0/root

The reason for doing this is that it can be tricky to set up network shares for the root of a drive, they generally need to be setup for folders within that drive. By adding a folder called “root” into which we dump all of our data, we’ll be able to setup a single share that contains all of our data later on.

The next step is to navigate to our new directory within the command line interface:

cd /mnt/md0/root

Useful tip: The Linux command line works on the basis that you’re trying to accomplish something inside whichever directory it’s currently navigated to. When you open a terminal window it will default to your home directory. Changing to the directory we’re interested in (the root folder on our RAID array) allows us to truncate commands as Linux will fill in the blanks on the assumption that we intend for it to make the changes in the directory we’re currently in.

So, to create further directories we just need to run commands as above for the new directories, here are some examples:

sudo mkdir video
sudo mkdir music
sudo mkdir photos
sudo mkdir backups
sudo mkdir downloads
sudo mkdir documents

These are just examples. The point is from here you can create whatever folder structure you like, and it can be good practice getting to grips with Linux commands.

Next we’ll need to setup a method of actually accessing these folders from elsewhere on our network. To do this we’re going to use a piece of software called Samba.

The first step is to install Samba:

sudo apt-get update
sudo apt-get install samba

You’ll need to press “y” when prompted to continue, the Samba application will then download and install.

Once installed the next step is to setup a password for your user name to be used with Samba. This should be different from your account password for security reasons. Type:

sudo smbpasswd -a <your user name>

You’ll be prompted to enter a password and then repeat it. Make sure you record this password as you’ll need it when trying to connect to your shares from another device.

Next you’ll need to edit a configuration file. To open the file in the Terminal’s text editor type:

sudo nano /etc/samba/smb.conf

A large text file will open and you’ll find you can use the cursor keys on your keyboard to navigate it. Use the down arrow to go all the way to the bottom of the document and then add the following text:

path = /mnt/md0/root
valid users = <your user name>
read only = no

Next press ctrl+O, this is the shortcut to save the file, press enter on your keyboard to save, then press ctrl+X to close the text editor

Next you’ll need to restart the Samba service so that the changes take effect. To do this type the following command into the Terminal:

sudo service smbd restart

And we’re done! The only thing that remains to be done is to test whether we can access our network shares from another device. Within Windows we do this by mapping a network drive.

Mapping a Network Drive

From within the Windows File Explorer, right click the “This PC” entry in the left-hand navigation pane and select “Map Network Drive”

This will open the following window:

Type in the address of your folder in the format shown above, supplementing in your server’s IP address in place of the example above.

Make sure the “Reconnect at sign-in” and “Connect using different credentials” boxes are both selected and click Finish.

You’ll then be prompted to enter a username and password. Enter your servers username and the password you setup during the Samba installation and click ok. You should then find that a window opens showing all of the folders you setup on the server, as below:

You should now be able to add any feels you need to your server by dragging and dropping!

This is an important milestone for our server build; we now have information stored on it in relative safety through the use of a RAID 5 array.

It’s important to point out at this point that although RAID 5 does protect us against loss of one of our hard disks, it does nothing to protect out data in the event that the server itself is compromised. For that reason I always recommend that you keep a safe copy of your data somewhere else, particularly if the data is important or holds sentimental value (think photographs).

My recommendation would be to invest in a seperate USB hard disk to backup your data to, which can then be stored in a different location to your server. That way in the event of fire, burglary, flood or any other nasty things we wish never to happen, you still have a copy of all your data.

And that’s it for Part 4. In Part 5 we’ll be looking at setting up our server to index and stream media to other devices on our network, and beyond!



Leave a Reply