Saturday, February 11, 2017

Old Netbook NAS

Much has changed since I first started my experiment, I have since decided to not treat it as a netbook, but an actual NAS. From the operating system to the configuration, we’ll dub this as Old Netbook NAS Part 2, the boring guide.

Control Panel

Since I have PHP and NGINX installed already on this NAS, I decided to go with the phpSysInfo project. It provides all I need with monitoring and has many options and features.

Though I might completely switch to Monit instead, if I decide to remove PHP and NGINX in the future.


This is a long guide and entails editing of configuration files. If you’re not comfortable or unsure of any of the details, then I recommend that you not do it. However, if for the sake of knowledge and risky adventure, then go right ahead, enjoy this geeky ride.


I decided to switch to Debian, it’s the base of many Linux distributions out there, including Ubuntu and its flavors. I had a few options when downloading it. Debian Stable, Testing or Unstable. The release names explain themselves, the stable is tested heavily but the down side is that it’s not bleeding edge.

That’s more than enough for this setup, since it is an old netbook, I won’t have any hardware detection problems and if any, I was sure I’d be able to fix it easily.

My geeky side disagreed with that though, for an hour it kept convincing me “Come on, you coward, use Unstable, live on the edge”. The thought was intriguing, having to tinker with the latest updates and methods. I decided to go half way to make my geeky and cautious side happy, so I picked Debian Testing (Currently code named Stretch). For more details about the difference in releases, visit this page.

I downloaded a Debian ISO (netinstall) without any desktop environments, added it on a USB thumb drive then started the setup. However, this time I wanted to experiment even further, I got an 8GB memory card from Kingston, I wanted to see if I’ll be able to install the operating system on it and have the HDD fully empty for my scratch storage daily needs.

I got my USB Debian drive and inserted the Kingston memory card, started the graphical install and honestly, the process couldn’t have been any easier. Very straight forward, basic information entry, if you’ve installed an operating system before, you’ll definitely be comfortable installing Debian.

During installation you’re basically entering user name, password, root password, location and keyboard layout. I used the entire disk since it’s just a memory card and from there it went on installing perfectly.

Configuration and NAS Setup

I did a few things differently from my first attempt, since I wanted to try and make this my permanent configuration. The idea is that I wanted to never look at my netbook ever again, unless I wanted to clean all the dust you see in the pictures.


The first thing I did was install sudo, unlike Ubuntu, it doesn’t come pre-installed. This is essential in my opinion, it allows you to run root commands for specific users without actually exposing the root system, it’s almost like a sandbox, but not really.

There are many guides on how to install sudo, it’s very basic and you can find it easily with a simple Google search. To give you an idea of what I’ve done though, I installed sudo, then added my user to the sudoers list.


In this guide I’ll be using apt, not apt-get. As I mentioned above, I went with a Debian Stretch install. If you’re using Jessie or an older version, apt-get would be the way to go.

Installing Updates:

After that I installed all the updates by running sudo apt update to update the package list then sudo apt upgrade to install the updates.

Installing SSH and Samba

The installation process for SSH and Samba are exactly the same as Ubuntu, however this time I changed some of the configuration.

To install SSH: sudo apt install openssh-server

Then I configured SSH, even though this netbook will only be accessed on my local network, it doesn’t hurt to have some extra security measures.

To change the configuration use this command sudo nano /etc/ssh/sshd_config it will open the Nano text editor to change some values, here are some basic things I did:
  • By default, SSH will listen to Port 22, changing that port isn’t really a strong security measure, but basically you’re just changing the obvious entrance.
  • I disabled root login by changing the PermitRootLogin value to no
  • Only allowed one user to use SSH by adding something like AllowUsers sam at the bottom of the file
After that I restarted SSH by using the sudo systemctl restart sshd command and all my initial configurations were up and running.

Now that I was done with SSH, it was time to get ready to install Samba, this time I had a different approach. I wanted to create a Samba share with two users, the second user would basically have “read only” access, meaning they can view the content but they can’t add, edit or delete any of it.

That way my family can access my vacation photos, without deleting one they thought they made a face in or didn’t like. I’m so evil.

To Install Samba: sudo apt install samba

After it’s installed, I added a new user without having any home folder made for them by using the useradd -M family command, “family” being the user name. Then I used usermod -L family command to lock the account, no one will be able to login with it or use it in the system, it’s just a user. Arguably there are others that would recommend adjusting that user even further with no shell access, but to me that was enough.

Then I created a Samba password for each user by running the sudo smbpasswd -a <username> command, “<username>” being the users you added earlier, for example sam, then run the command again for family. Each with their own password, they’ll be able to access the NAS from any device within the local network with those credentials.

HDD Auto Mount:

After I created the Samba users, now it was the time to prepare the hard drive to be accessed and auto mounted in case the netbook rebooted at any point.

First I created a directory to use as a mounting point, I named it nas. sudo mkdir /media/nas
Then I ran the sudo blkid command to get the UUID of the hard drive to uniquely identify it for the mounting point. After I copied the UUID I edited the configuration to auto mount the HDD to the directory I created earlier, first I used the sudo nano /etc/fstab command to open the configuration in Nano editor, then at the bottom of the file I added the following:

#MyStation drive
UUID=[MY_HDD_UUID] /media/nas ext4 defaults,noatime 0 0

Replacing “[MY_HDD_UUID]” with the actual one, of course. What that basically does is tell the system to mount my HDD to /media/nas on start up, which is using the Ext4 filesystem and using the default options with noatime to prevent updating the hard drive with access times, that way I’ll be able to make it go on standby if it wasn’t used for a while. For more details please read this guide on fstab.

HDD Standby:

For this task I used TLP. This tool helped me significantly, it spins down the HDD (standby) and it controls many aspects such  as CPU performance to save power consumption and resources. I also have it handle the power outage. Since this is a netbook and it has a battery, I have it monitor when the netbook switches to battery mode, if power is critically low (10%), then it would safely shutdown the netbook.

TLP utilizes HDParm to spindown HDDs, so consider TLP an advanced tool that handles power management.

Adding a Samba Share:

The users are set up and the hard drive is configured, now all we have to do is add a Samba share so the users can access it from the network.

First, we edit the configuration file: sudo nano /etc/samba/smb.conf

Then at the very bottom, I added the following:

    comment = Debian Netbook Share
    path = /media/nas
    browsable = yes
    valid users = sam family
    write list = sam

Let me explain what that list means.
  • [MyStation] defines how the share will be seen in the network, so for example when accessing it on Windows, you’ll see “MyStation” folder, you can change it to whatever you want.
  • The comment part is just to help you identify what this share was, since we’re only creating one share, this is optional, you can leave it blank if you want.
  • The path is to define what folder will be accessed on the netbook, in this case I added the mounting point for my HDD
  • Browsable means they can browse it, it’s that obvious.
  • Valid users lists the users that can actually access this share, in here I specifically defined both “sam” and “family” to be the only users allowed access.
  • Write list makes “sam” the only user that can add, edit or delete to that share, any other allowed user will only have “read only” access, meaning they can view the content, but not change it in any way.
After that I saved then closed the configuration file then I restarted the samba service to implement the changes by using the sudo systemctl restart smbd command.

Done. I tested everything and now I have a fully functional NAS that I use as my daily scratch disk in my local network.

Download Station & Weekly Reboot

At this stage, the NAS is working perfectly as a storage unit, but I wanted to expand its function a bit. I wanted to create a download station like I mentioned in Part 1, and I wanted to set up a cron job to have the netbook reboot weekly, just for good measure.


I’m a huge qBitTorrent fan, it’s rich with features, easy to set up and has an awesome Web-UI. They have a guide for Ubuntu Server which works perfectly fine for Debian as well, since after all Ubuntu is based on Debian.

You can find the guide here. It basically installs the non-GUI version of qBitTorrent and the guide helps you set up the auto start on boot.

Aria2 and Aria2-webui

This is really optional, I haven’t implemented it yet, but I am considering it. Since I wanted a download station, with qBitTorrent the torrents downloads are covered, but I wanted a solution for HTTP downloads as well, since it’s a scratch NAS drive, why not put it to work.

Update: I decided to go ahead and install aria2 with the Web UI.

Aria2 really seems like the perfect solution, combined with the web-UI, it basically gives you the same features qBitTorrent does, but for HTTP. It actually has torrent support, but I’d rather use it for HTTP only. Like I said though, very optional.

Installation was easy for aria2, since Debian includes the package already, so you won’t have to add any sources. However, configuration took me a while, for both aria2 and aria2-webi. You can find the full documentation for aria2 here.

I might write a guide on how to configure aria2, I’m still not sure, since like I said I consider this to be highly optional. I basically installed and configured it out of curiosity, but I have to say the result is awesome and I’m definitely going to use it as my HTTP downloader from now on.

Weekly Reboot:

This was really easy to implement, all I had to do was edit the crontab by using the sudo crontab -e command, if it’s your first time running it, it will ask you to pick an editor. I always pick Nano. At the bottom of the file, I added the following:

# Weekly reboot. Wed, 1:05 PM
05 13 * * 3 /sbin/reboot

Then I saved and closed the file. I picked that specific time because I know at that moment specifically I’ll never be home or using the NAS drive.

You can also use this @weekly /sbin/reboot instead of the specific hour, minute and day set up I had. There is a great guide on Cron provided by Ubuntu, you can find it here.

Impoartant: Netbook Lid Closed:

Since I’m going to keep this netbook running all the time, I wanted to keep the lid closed, but I immediately found out that if you close the lid it’ll suspend the netbook, making it inaccessible.
To change that, edit the configuration file by using the sudo nano /etc/systemd/logind.conf command, then uncomment and/or change the HandleLidSwitch value to ignore, which should look like this:


Then save and close the file.


I know it seems like a lot of work, this guide is long but only because as I said in the beginning, I dubbed it to be boring. I learned so much in the process and I’m sure I’ll learn more and more as I go. As a geek, it was definitely worth it.

Because I used a minimal Debian install, and after all the setup and configuration it only uses 75MB of memory, compared to the 125MB from Lubuntu (with GUI off) on my first attempt.

Once you get used to the process, it becomes a reflex, the next time I do this it’s going to be much faster and easier, and I’m sure by then I would have tinkered with even more configuration and ideas.
I’m really happy with the result so far, I didn’t throw the netbook or let it catch dust and my network has expanded ever so slightly.

Just a side note, I installed NTP to keep my netbook time synced and updated, Debian has a great guide on it here.

Things I’m considering to do later:
  • ddClient: To update Dynamic IP with OpenDNS [Done]
  • SSH key security instead of passphrase [Done]
  • Unattended upgrades (Automatic updates) [Hesitant]
  • NTP server. (Broadcast time within my network) [Done]
  • Experiment with ownCloud to be used later on a full PC set up. [Delayed. Saving it for my future NAS server project]
Stay geeky!


Post a Comment