GNU/Linux Projects

To Home Page

NAS device using a thin client and a USB hard drive

Last modifications: 29 August 2017

What is NAS?

Network attached storage (NAS) is data storage connected to a network, providing data access to a all the computers in this network. A NAS device actually is a computer as well but without monitor, keyboard and mouse. It operates as a file server and normally runs 24/7. The image below shows how a NAS device and multiple computers are connected to a home network (LAN).

NAS in home network

With NAS there is no need to have copies of the same files on different computers. At home for example, everybody can view the same holiday pictures stored on the NAS device, using their own computer. Most NAS devices can do more, for example function as a music player or a print server. With a print server, every computer at home can print to the printer connected to the NAS device.

Why making my own NAS?

Many NAS home consumer devices run a customized version of GNU/Linux. That may sound great if you are a GNU/Linux fan (like me) but...

  • Controlling the device is often limited to some configurable preferences.
  • Usually it is not possible to run programs other than the preinstalled ones.
  • Connecting to a NAS device using SSH or Telnet is not always possible.
  • If it is, chances are you can not use all the shell commands you are used to.

It made me think: why not install the GNU/Linux flavour I want, install the software I want and configure the NAS device the way I want?

Unfortunately most NAS devices do not allow the installation of other operating systems or can not run my favorite GNU/Linux distribution (Debian) because of performance issues.

So I decided to make my own NAS. Just to be in control. Just for fun. And during this project I learned some more about GNU/Linux as well.

The hardware

To make your own NAS, you need a computer with a network adapter and some free disk space. Of course you also need an operating system and programs to run on it. But first let's focus on the hardware.

Why using a thin client?

I could have used that old Pentium PC that was only collecting dust. But the energy consumption of a PC is quite high (70 W in my case) and I found that undesirable for a device that would be running day and night. Two other things I did not like about the PC option where noise and size.

Computers that do not have these disadvantages are thin clients. They are small, do not make any noise (no fans) and energy consumption is low. Yet they can be very powerfull. Thin clients do not have an internal hard drive but USB hard drives can easily be connected.

My hardware requirements

VXL Itona TC4331 Thin client Packard Bell Go USB hard drive

So I needed a thin client and a USB hard drive. First I made a small list of requirements for this hardware:

  • CPU speed: 1 GHz or more
  • RAM size: 128 MB or more
  • USB speed: 480 Mb/s (USB 2.0)
  • Ethernet speed: 100 Mb/s
  • Hard drive size: enough for all of my data...

These requirements are based on the system requirements for the GNU/Linux distribution of my choice (Debian) and some of my own ideas about performance.

The hardware I use

I found the following hardware for my NAS device:

  • Thin client: VXL Itona TC4331
  • USB hard drive: Packard Bell Go

To save money I bought the thin client second hand. The Itona TC4331 met my requirements well. Here some specifications:

  • VIA C7 1 GHz processor (x86 architecture)
  • 32 MB flash
  • 256 MB DDR 2 RAM
  • 4 USB 2.0 ports
  • Ethernet 10/100 Mb/s (RJ-45)

The hard drive I chose is a power saving 2.5-inch drive, the Packard Bell Go. This hard drive gets its power via USB, so no external power supply is needed. Nowadays many affordable USB hard drives are available.

Preparations for installation

Before I could install Debian on my thin client, I had to do some preparations first.

Hooking up the thin client

The installation of a (new) operating system on a headless server like a NAS device - no monitor, keyboard and mouse - can be stricky. To make things easier, I connected a monitor and a keyboard to my thin client for use during installation.

I wanted to do a Debian network installation: a minimum base system is installed from a minimal installer and the rest is installed via Internet. Therefore the thin client had to be connected to the Internet.

Preparing install from USB stick

Normally Debian is installed from one or more installation CDs or DVDs. But the Itona thin client does not have a CD-ROM drive and I did not have an external one. So I had to install Debian from a USB memory stick.

Fortunately putting the Debian installer on a USB stick is very easy if you have a GNU/Linux computer.

How to put the Debian network installer on a USB stick

  • Download the Debian CD image for a network installation
    (will fit on most USB sticks - size is only about 200 MB)
  • Open a terminal and log in as root
  • Copy the CD image to the USB stick by typing:
    # cat debian.iso > /dev/sdX
    # sync
    Replace debian.iso with the real name of the CD image. And replace X with the letter corresponding with the USB stick (type df in a terminal to find out).

Note: be sure to use the right drive letter X, otherwise you may lose data or lose your complete operating system!

Booting from USB stick

In order to run the installer, the thin client had to boot from the USB stick. This can be set in the BIOS.

The Itona thin client has a standard Phoenix Award BIOS. To enter the BIOS setup you hit the DEL key on power-up. The BIOS of my Itona thin client appeared to be password protected. On the internet I found out that the standard password is "drupad".

Installing Debian

The idea was to install Debian GNU/Linux (version Wheezy) on the USB hard drive connected to the thin client. Installation on the internal flash drive of the thin client was not an option because of its small size (32 MB).

On a NAS device you do not need a graphical desktop environment, so I only installed the standard system utilities.

Installation went well, except for the very last part. At the end of a Debian installation, the GRUB boot loader is installed. I chose to install GRUB on the first hard drive (the default). This went wrong because the first hard drive of the Itona thin client is the internal flash drive and the drive turned out to be read-only.

Installing GRUB manually

I ended up with a thin client that did not boot because of a missing boot loader. So I had to install GRUB "manually".

How to install GRUB manually with Debian

  • Boot from the medium containing the Debian installer
  • Choose Advanced options from the installer menu
  • Choose Rescue mode
  • Enter the information needed by the installer
    (this info is only needed to run in rescue mode - nothing will be installed)
  • Choose the partition to be used as the root file system - this should be the partition where you installed Debian
  • Choose Reinstall GRUB boot loader
  • Follow the instructions of the installer

Spinning down the hard drive

The USB hard drive I use, has a built in time out feature that spins down the disk when there has been no disk access for about 3 minutes. But my disk kept spinning continously.

I found out that some processes are writing to disk quite often:

  • rsyslogd
  • kjournald
  • cron
  • exim4
  • nmbd

How to monitor disk activity

  • Install the Debian package iotop
  • Open a terminal and log in as root
  • Start iotop by typing:
    # iotop -o -qqq -t
    With the options above, iotop will show the names of processes at the moment they write to disk, including a timestamp.

Using laptop mode

From the Debian website: laptop mode is a Linux kernel feature that allows your laptop to save considerable power, by allowing the hard drive to spin down for longer periods of time. This feature is also suitable for spinning down the hard disks of a server (read the note below). If you want to use laptop mode, you need to install the package Laptop Mode Tools.

How to spin down your disk using laptop mode

Edit the configuration file and set the values of the parameters below. In Debian the location and name of this file is /etc/laptop-mode/laptop-mode.conf.


MAX_LOST_WORK is the maximum time, in seconds, of work that you are prepared to lose when your system crashes or power runs out. This is the maximum time that Laptop Mode will keep unsaved data waiting in memory before spinning up your hard drive.

Note: Spinning down too many times may kill hard drives! Read more on the Laptop Mode Tools website.

The HD_IDLE_TIMEOUT parameter is ignored by my Packard Bell hard drive. The drive uses its own built in time out feature, which is fine for me.

Solving the problem with nmbd

For some reason nmbd (a part of Samba) kept writing to disk to often, even in laptop mode. After a long search on the internet I found a solution for this problem: mount the directories nmbd writes to, as RAM disk. Then nmbd wil write to RAM in stead of the hard disk. Note that the information in RAM will be lost after a reboot but this seems to be no problem.

How to prevent nmbd from writing to disk

Add the blue lines below to the Samba startup script. In Debian the location and name of this script is /etc/init.d/samba.


   case "$1" in
                log_daemon_msg "Starting Samba daemons"

                # Prevent frequent writes to disk
                # Use tmpfs (ram disk)
                mount -t tmpfs tmpfs /var/run/samba
                mount -t tmpfs tmpfs /var/cache/samba


                log_end_msg 0

                # Unmount tmpfs (ram disk)
                umount /var/run/samba
                umount /var/cache/samba

                log_end_msg 0


Problems with readahead

In laptop mode (see previous section) readahead is enabled by default. Reading ahead means that whenever some data is read from disk, the data which is most likely to be accessed next is read as well, ahead of time.

In my case readahead caused two problems:

  • Video played from my NAS was distorted for a short while at certain moments (I think at the moments a new readahead was done).
  • My NAS responded slowly to simple terminal commands like "ls" (I think readahead reads more than only the command executable you need).

Disabling readahead solved these problems.

How to disable readahead

Edit the configuration file of Laptop Mode Tools and set the value of the CONTROL_READAHEAD parameter to 0. In Debian the location and name of this file is /etc/laptop-mode/laptop-mode.conf.

Software on my NAS device

Some of the software I run on my NAS device:

Laptop Mode
Power saving tools
(see: Spinning down the hard drive)
OpenSSH SSH/SFTP server
Apache HTTP server / web server
(see: World wide access)
ProFTPD FTP server
(see: World wide access)
Samba SMB/CIFS server (supports Windows clients)
CUPS Printing system that supports network printing
Transmission BitTorrent client
MPD Music Player Daemon
(see: My NAS as a music player)
Rsync Powerful tool for synchronizing directories
(see also my project: Srsync - a script using rsync)


My printer is connected to my NAS, so I can print from any computer in my home network. To install and manage printers I use the CUPS web interface. By default you can use this web interface only on the computer where CUPS is installed (via: http://localhost:631). But it is possible to enable remote access to CUPS.

How to enable remote printer administration

On your NAS/server edit the CUPS configuration file: change the red line, add the blue lines. In Debian the location and name of this file is /etc/cups/cupsd.conf.

   # Only listen for connections from the local machine.
   Port 631 # was: Listen localhost:631
   Listen /var/run/cups/cups.sock

   # Web interface setting...
   WebInterface Yes

   # Restrict access to the server...
   <Location />
     Order allow,deny
     Allow all
   # Restrict access to the admin pages...
   <Location /admin>
     Order allow,deny
     Allow all

  # Restrict access to configuration files...
   <Location /admin/conf>
     AuthType Default
     Require user @SYSTEM
     Order allow,deny
     Allow all


After restarting CUPS (on Debian: /etc/init.d/cups restart) you can open the web interface from any computer. Open a web browser and go to: http://server:631 (replace server with the name of your NAS/server).


Transmission is a nice BitTorrent client for downloading and sharing large files, like software, movies and music. But it took me some time to find out which parts to use on my NAS device.

How to use Transmission on a server

On your NAS/server you need transmission-daemon and possibly transmission-remote. In Debian Wheezy the packages to install are transmission-daemon and transmission-cli (which contains transmission-remote).

  • transmission-daemon
    BitTorrent client designed for headless servers (servers without monitor, keyboard and mouse).
  • transmission-remote
    Command line tool for controlling the daemon (handy for scripting and scheduling).

To control the daemon from another computer you can use the web interface. Open a web browser and go to: http://server:9091 (replace server with the name of your NAS/server). Via the web interface you can for example add torrents and monitor your downloads.

When Transmission is up/downloading, this will slow down other internet traffic. Therefore on my NAS device Transmission is only active at night. I use transmission-remote and cron to schedule this.

World wide access

Sometimes it is practical to have world wide access to your data. Here some ideas.

World wide access using Apache (read only)

Normally Apache is used to serve web pages over the Internet. I use Apache to serve the data on my NAS, so I can easily access my data world wide using a web browser (see the image below).

Access to my NAS using a web browser

How to serve your data world wide using Apache

Security first!

Before you decide to serve your data world wide, think about security. Normally you do not want others to have access to your data. So I configured Apache to use authentication and SSL. There are many websites that explain how you can do this.

After configuring Apache with the desired security (the hardest part) the rest is relatively simple:

  • Make a symbolic link to your data in the Apache document root directory (in Debian the default is: /var/www/).
    Open a terminal, log in as root and type:
    # cd /var/www/
    # ln -s /your/data/directory/ data
  • Make sure the Apache option FollowSymLinks is enabled (see the Apache virtual host configuration file).
  • To allow access over the Internet, forward port 443 to your NAS/server (or port 80 if you do not use SSL). This can be set in your router.

To access your data start a web browser and go to: http(s)://router-ip-address/data. The router IP address is assigned by your Internet Service Provider. If your ISP provides a host name, you can use that instead (see the image above).

World wide access with FTP and WebDAV (read and write)

Write access to my NAS from the Internet is restricted to two specific directories (this restriction gives me some feeling of safety). One directory is accessible using FTP (on my NAS ProFTPD does the job). The other directory is accessible using the WebDAV protocol (supported by Apache and other web servers).

An FTP client and a WebDAV client are needed to access the directory shares. You may use a special client application or a file manager with built in support for FTP and WebDAV.

My NAS as a music player

My complete music collection is stored on my NAS. So I can listen to my music on every computer connected to the home network.

Another possibility is playing the music on the NAS itself. To do this I run Music Player Daemon on my NAS. A client on another computer or a smart phone is used to control the daemon. Of course the audio output of the NAS must be connected to some kind of music installation, in order to hear the music playing!

Music Player Daemon (server)

All information about the Music Player Daemon (MPD) can be found on the MPD website. You can download the daemon from there or install it using your package manager.

How to configure MPD

On your NAS/server edit the MPD configuration file. In Debian the location and name of this file is /etc/mpd.conf. Only change the information below.


   # Files and directories
   music_directory         "/your/music/directory/"

   # Audio Output
   audio_output {
           type            "alsa"
           name            "My ALSA Device"


After saving, restart MPD (on Debian: /etc/init.d/mpd restart) and you are ready to play your music. On the client side you need to configure the host (IP-address or name of your NAS/server), the port (default: 6600) and the audio output(s) you want to use (in the setup above there is only one).

GMPC (client)

To control MPD on my NAS from my PC or laptop, I use Gnome Music Player Client (GMPC). Below you can see a screen shot (click to enlarge). GMPC runs on Windows, Mac OsX and GNU/Linux (GMPC does not depend on Gnome anymore, although the name may suggest this).


MPDroid (client)

On my Android phone I use MPDroid to play the music on my NAS. See the screen shots below (click to enlarge). You can install it from Google Play but as a free software lover I prefer to install it from F-Droid.

MPDroid    MPDroid

More MPD clients

More clients you can find on the MPD website.



When I started my NAS project I had no idea what the result would be...

But after my NAS device was up and running, it really worked well! Data transfer speed from and to my other computers is about 50 Mb/s (not superb but not bad either over a 100 Mb/s network). Watching video from my NAS device works without hickups.

Since December 2011 my NAS is running day and night without any problems.