LJ Archive

Building an Ultra-Low-Power File Server with the Trim-Slice

Daniel Bartholomew

Issue #211, November 2011

How-to: replace a large, inefficient custom-built file server with the Trim-Slice.

For the past several years, I've used a custom-built file server at my house. I've upgraded it many times, but it began life, as near as I can recall, in April 2000. When I say “upgraded”, I mean the internals have been swapped completely on at least two occasions among other things. The most-recent major upgrade was in 2006 (or thereabouts) when I added a software RAID5 with three 500GB hard drives (later expanded to six). It has chugged along merrily for years, but lately it has begun showing its age. For starters, two terabytes of space isn't all that much anymore. Also, it's not as efficient power-wise as I would like (in my measurements, it draws between 1.8 and 2.0 amps continuously, depending on load). Finally, the case for this server takes up way too much space (it's a full tower).

As an experiment, and finally to get rid of that large, inefficient and ugly tower case, I decided to use the new Trim-Slice as the base for an ultra-low-power, ultra-small replacement file server. The Trim-Slice is built on the NVIDIA Tegra 2 platform, and the specific model I purchased features a 1GHz dual-core ARM Cortex A9 processor, 1GB of RAM and a 32GB SATA SSD. Did I mention that it's really small? You know, teeny—like, I-can't-believe-this-is-a-full-computer small. The dimensions are 130mm x 95mm x 15mm. For comparison purposes, a standard 3.5" hard drive has dimensions of approximately 146mm x 102mm x 25mm.

Figure 1. The Trim-Slice and Everything That Comes in the Box

Figure 2. Size Comparison: the Trim-Slice Next to a Nokia N900 and the Ben NanoNote

On the outside, it has an RS232 serial port, SD and microSD card slots (both SDHC-compatible), four USB ports, HDMI and DVI-D video out ports, 802.11n and a Gigabit Ethernet port. Inside, it comes with Ubuntu pre-installed on the SSD (10.10 “Maverick” was installed on the one I received, but there is now an update to 11.04 “Natty”, which I applied and which I expect is now shipping on newly ordered units).

The full Ubuntu Linux inside is what set this solution above alternatives like the Drobo FS, ReadyNAS and others, at least in my mind. The price is in the same ballpark too. The model I ordered, complete with shipping from Israel, came to $335.

The main downside for my purposes is that there is no place to connect internal hard drives. I have to make do with external USB drives instead. I don't like the thought of running a software RAID over USB, so I further decided simply to use multiple large external USB drives (each with at least one corresponding backup drive).

To start with, my goal was to replace the old tower server, which just requires the Trim-Slice and two 2TB external USB hard drives. Yes, a single hard drive, especially a USB drive, is not as reliable or nearly as fast as a RAID5 array, but it's a compromise I'm willing to make for the power, space and noise savings. USB is plenty fast for my needs, and besides, with two drives, I have a backup.

Anatomy of a File Server

The purpose of a file server is to serve files over a network. There are many ways to do this, but I focus on the most common ones here.

First, there is classic “file server” software: NFS and Samba. These systems don't care what your data is. All they see are files, and no file is any different from the next (apart from size and permissions).

The new kids are content-aware file servers like UPnP and DAAP. This type of file server software does care about content types, and it serves up metadata about your files along with the files themselves. It will refuse to serve files it doesn't recognize or support. But, it can do some tricks that NFS and Samba can't, like alter data on the fly for clients who can't read the original data. So, they're more fussy than classic file server software, both to set up and run, but they do have advantages.

UPnP and DAAP are designed specifically for serving audio, video and image files. DAAP is built-in, or available as a plugin, for many popular audio jukebox apps, such as Rythmbox, Amarok and Banshee, but there also are standalone server applications available. UPnP Media Server support is built in to various consumer devices, such as the PlayStation 3, Xbox 360 and various handheld and set-top media players.

NFS

NFS is the classic Network File System, and it is has been in use for decades on Linux and UNIX. The Popcorn Hour media player connected to my TV supports NFS, and I don't have any Windows computers, so NFS is really the only classic file-serving protocol I need (or want) on my network. NFS has very limited security, so it's not ideal for everyone, but it's lightweight and easy to configure. In my opinion, if you have a device that supports NFS and SMB, go with NFS.

On Ubuntu, the NFS server I use is called nfs-kernel-server, and you can install it with the following:

sudo apt-get install nfs-kernel-server

To create an nfs share, edit the /etc/exports file, and add the directory you want to export. Here is an example:

/mnt/disk01 popcorn(ro,sync,root_squash,no_subtree_check)

The above line exports the /mnt/disk01 directory to my Popcorn Hour, with the following flags:

  • ro — read only: in other words, don't allow anything that could change the filesystem. The Popcorn Hour has the ability to delete items, but I don't want to let my kids delete things arbitrarily or accidentally with the remote.

  • sync — reply to requests only after the changes have been committed to stable storage.

  • root_squash — map requests from uid/gid 0 to the anonymous uid/gid. This makes things a little more secure.

  • no_subtree_check — from the man page: “This option disables subtree checking, which has mild security implications, but can improve reliability in some circumstances.” See the man page for more information (man exports).

With the line in place, I run the sudo exportfs -ra command to refresh the exports. Then on the Popcorn Hour, I can mount the exported directory, and away I go. There are several other options you can use in the /etc/exports file. See the exports man page for details.

The example entry above can't be mounted on any other host, but to permit other hosts to do so, I either can change popcorn to the IP address and netmask of the network I want to share it with (for example, 192.168.10.0/24 for every host with an IP address starting with 192.168.10.), or I can add additional host definitions to the end of the line.

With the exports file updated and refreshed, I can mount the export with something like this:

sudo mount -t nfs trimslice:/mnt/trimslice/disk01 
 ↪/mnt/trimslice/disk01

Or, I could add an entry like the following to my /etc/fstab file:

trimslice:/mnt/trimslice/disk01  /mnt/trimslice/disk01  
 ↪nfs  defaults  0 0

and the NFS share always would be mounted at boot time.

Samba SMB/CIFS

Samba, aka SMB/CIFS, is how you go about sharing files with computers running Windows. If I had a Windows machine or two, using Samba would be a given. I don't, but I'll go ahead and describe the process here. For starters, Samba is installed on the Trim-Slice with the following:

sudo apt-get install samba

After installation, edit the /etc/samba/smb.conf file to set up your shares (add them to the end of the file). A read-only share equivalent to the NFS one described above is:

[disk01]
    comment = trimslice disk01
    path = /mnt/disk01
    browsable = yes
    guest ok = yes
    read only = yes

Add the above to the end of the smb.conf file, and the share will pop into existence on the network. With Samba, there is no need to restart the service or run a command after editing the smb.conf file; any changes are applied automatically as soon as the file is saved.

It's a good idea to uncomment the security = user line in the smb.conf file to add some security (and if you do want security, you should set guest ok in the above example to no). And, if you have a proper Windows network, you should change the workgroup name in the smb.conf file to the actual name of your Windows workgroup.

As with NFS, you can enter a lot more settings in the smb.conf file to tweak things just the way you want them. The default file is filled with examples, and the Samba documentation goes into even greater detail.

DAAP

DAAP, in case you are interested, stands for Digital Audio Access Protocol. An older, but serviceable, standalone DAAP server for Linux is mt-daapd, also known as the Firefly Media Server. Unfortunately, it is not under active development. Some forks are in the works (which aren't in the Ubuntu repositories yet), so maybe the situation will improve in the future. To install it, do the following:

sudo apt-get install mt-daapd

After installing mt-daapd, set the password for the admin account in the /etc/mt-daapd.conf file. Technically, the password already is set, but it's good practice to change it. You can tweak other settings in the file, but the GUI is easier.

Figure 3. mt-daapd, aka the Firefly Media Server

After changing the password, restart mt-daapd with:

sudo /etc/init.d/mt-daapd restart

Then, go to the Web interface to configure it: http://trimslice:3689 (replace “trimslice” in the URL with the correct IP address or name).

The configuration page is simple and self-explanatory. You can set the name, change the admin password and set a password for listening to the music (in case you don't want to share your collection of classic Dr. Who music with everyone on your network). You also set which folder or folders contain your music (multiple folders can be specified). Finally, you can configure how often to have mt-daapd rescan your music folder(s).

Once the changes are to your liking, pressing the Save button saves the settings to the /etc/mt-daapd.conf file. But, the GUI is there so you might as well use it.

All should be well and good at this point. Unfortunately, mt-daapd, as packaged in the repository the Trim-Slice uses, does not support FLAC files. If your collection is mostly MP3 files, that won't be an issue. If it is an issue, your options are to compile your own, live with the limitation or find an alternative.

UPnP

For serving up video files to my PS3, I use the MediaTomb UPnP media server. Or at least, I would, if I didn't have the Popcorn Hour. MediaTomb, like mt-daapd, is a nice piece of software and works just fine for what it does, but devices like the PS3 can be very picky about what file types they will support. On-the-fly transcoding (supported by both mt-daapd and MediaTomb) can eliminate some of these issues, especially with audio files (for example, by transcoding a FLAC file to WAV while it is being transferred, so that iTunes can play it). Transcoding isn't practical for video files though. It can be done, but the CPU requirements are hefty to say the least, especially when you start talking about 720p and larger video files.

Figure 4. The Media Tomb File Browser

Limitations aside, installing and configuring MediaTomb is similar to mt-daapd. First, enter the following:

sudo apt-get install mediatomb-daemon

After the install completes, edit the /etc/mediatomb/config.xml file to enable the graphical user interface (GUI) and set the default user and password. To do this, change enabled="no" in the following lines to enabled="yes" (both of them), and set the password to something more secure:


<ui enabled="no" show-tooltips="yes">
  <accounts enabled="no" session-timeout="30">
    <account user="mediatomb" password="mediatomb"/>

The above lines should be near the top of the file. Save the file, and restart the server with:

sudo /etc/init.d/mediatomb stop
sudo /etc/init.d/mediatomb start

Once restarted, connect to http://trimslice:49152/. Enter the user name and password, and you will be in the GUI. To add a folder, click the Filesystem link, and browse to the folder you want MediaTomb to index. With the correct folder selected in the left pane, click on the plus, or plus-with-a-circle icon, to have MediaTomb scan the contents of the folder. The plus-with-a-circle icon adds the folder as an autoscan folder, meaning it will rescan the folder periodically looking for new files.

For PS3 support, a couple lines need to be changed in the config.xml file; they are commented and easy to find if you search for “PS3”.

Backups

With this new file server, I lose the protection of RAID, so backups are more important. RAID, of course, does not eliminate the need for backups; it just makes the primary filesystem more reliable. Because I already needed backups with my old setup, I had a backup system in place.

The “system” itself is a custom rsync backup shell script. The backup drive contains several directories: one named current and then 14 others named 01, 02, 03 and so on, up to 14. The basic flow of the script is:

rm -rf '14'
mv '13' '14'
mv '12' '13'
...
mv '01' '02'
cp -al 'current' '01'
rsync drive-to-back-up to 'current'

The -al part of the copy command above is important. It tells the command to operate in archive mode, which preserves attributes and copies directories recursively, and to create hard links instead of actually copying the files. When rsync comes upon a changed file, it will de-link the file before updating it, so the combination of rsync and the cp command gives me 14 days of backups (assuming the script is run once a day).

The extra space required for these backups is low, so I can use the same size drive for the backups that I do for the primary. Once a backup drive starts nearing its limit, the primary drive likely will be close to its limit too, and it will be time to shop for an additional pair of drives.

I've used variations of this script for years, and if I had to start from scratch today, I might use it or something else. Lots of excellent backup programs are available for Linux. The point is to make backups, as many as necessary.

Conclusion

The Trim-Slice has worked out very well as a file server. The built-in serial port lets me operate it completely without a monitor, and the hardware has so far been more than adequate for my household's modest file-serving needs.

With dual 2TB external USB disk drives (and more to come), the Trim-Slice is even more energy-efficient than I thought it would be. My consumer-grade “Kill-a-Watt” power meter (which I admit is probably not very accurate) shows an average power draw of 0.28 amps, which, completely accurate or not, is much better than the 1.8 to 2.0 amps the old server was pulling. The power draw of the Trim-Slice by itself is an astounding 0.08 amps.

Power is just one benefit. I also like the smaller footprint. Noise is much better too. The old case needed several fans, but the Trim-Slice is passively cooled. There are fans in the external drive enclosures, but they don't come on very often, and when they do, I don't notice them at all. The Trim-Slice does get a bit hot to the touch, but I suppose that's what you get when you make the outer casing a heat sink.

The jury is still out on how long this new setup will last. I consider USB drives to be less reliable, and although the build quality of the Trim-Slice appears high, it's a new product with no history. To mitigate this, I am going to be very careful to make sure important stuff is copied across all future drives. Despite my worries, I must admit, I did replace a few of the drives in my RAID5 over the years, and I don't imagine the difference in reliability will be so great as to cause any huge problems.

Daniel Bartholomew works for Monty Program (montyprogram.com) as a technical writer and system administrator. He lives with his wife and children in North Carolina and often can be found hanging out in #maria on Freenode IRC (he occasionally pokes his head into #linuxjournal too).

LJ Archive