Introduction
If you’ve read any of my Network Attached Storage (NAS) reviews over the last few years, you’ll see that I often try to find a way to break through the standard interface of the NAS in order to get access to the underlying operating system. Why would I want to do this? There are lots of reasons.
Sometimes it’s just curiosity. Once I get a command-line, I can really see what the manufacturer is doing to make the product work. Other times, I want to see if the NAS is really locked down from a security standpoint. Because ifyou deploy a NAS on your network, you need to know whether it is as secure as the manufacturer makes it out to be.
But most of the time, my real goal is to see if the box can be extended to give it additional features. Nearly all consumer-level NASes run Linux internally. This means these NASes have a general-purpose operating system that has been configured to expose only a small set of supported capabilities.
NASes are capable of a lot more than the standard features they come with. I’ve modded NASes to do weather monitoring, home automation and specialized data backup. The NSLU2 has been particularly popular with those wanting a tiny extendible NAS. My modifications have been fairly pedestrian, but others have modded the NSLU2 for more exotic uses such as a robotic submarine, a pollution monitor, or a “carputer”.
As these things go, the NSLU2 is a bit of an exception with a large development community behind it supplying installable packages and alternate firmwares. But most of the time when I get into a NAS device, I’m on my own. If I really want to extend the box, it means figuring out the custom Linux distribution used by the manufacturer, building a cross-compilation tool-chain and doing my own installs.
But hopefully, that’s now changing. Many NASes on the market are based on a Marvell “Orion” chipset and earlier this year, standardized support for this architecture was added to the mainline Linux source tree. Soon thereafter, Debian support came along. This means that instead of using a custom Linux distribution, manufacturers using the Orion architecture will be able to start with an off-the-shelf Linux distribution. And even if the manufacturer chooses to roll their own distribution, adventurous users will be able to more easily go their own way and install Debian themselves.
In this article, that’s what I’ll do. I’ll install a recent version of Debian on a QNAP TS-209 Pro , using the Release Candidate 1 installer for 5.0, (Lenny), which has recently added support for installing to Marvell Orion-based NASes. I’ll be using the TS-209 Pro in this article, but the process will be similar for other Orion-based NASes.
To see if your favorite NAS is officially supported, check out Martin Michlmayr’s page for a list of devices. Martin has been a driving force behind getting Debian support for these NASes and he has extensive documentation on the installation process.
So how does one go about loading a new operating system on a NAS that doesn’t have a CD or DVD drive for installation media and no way to boot off an external device? It’s actually pretty straightforward. The basic process is to replace the standard flash image on the NAS with a special Debian installer and then reboot to start the installation. The installation process itself then fetches everything it needs across the Internet, unpacks it to the internal disk and then burns a new kernel image to the internal flash.
Of course, there are a lot of things that can go wrong along the way, so you need to be prepared. One of the difficulties with a box like the TS-209 is that it has no direct-connect console, meaning that the only way to interact with it is across the network. So if your installation fails and the network doesn’t come up, you can be in trouble. The same issue can arise with flash. You’ll note in this process that there are flash burns going on, which can also fail with disastrous results.
This process involves replacing all of QNAP’s code, including the web configuration interface, with Debian code. So you stand the chance of “bricking” your NAS.
Your hard drive(s) will also be erased and re-formatted. So back up any data on your disks before you start.
So if you’re uncomfortable with that possibility and you’re not up for command-line administration of Linux, this is not for you.
Finally, SmallNetBuilder, Pudai LLC and I are not responsible for any damage that the information in this article may cause to your NAS or any data it manages.
But there are a couple of different ways to protect yourself against issues like this. The more difficult way is to solder on a TTL-to-RS232 level shifter, which will allow connection of a serial cable so you can log into the box without a network. This will also allow you to interact with the boot loader to load a new flash.
Of course, if you’re like me, handling a soldering iron always means there’s a very real danger of destroying the solderee and setting your house on fire, which can often result in severe spousal disapproval. The safer way to deal with potential problems is to take advantage of a recovery mechanism that recent QNAP firmware has built in. This is the route I’ll take in this article.
Preparation
For QNAP, the recovery-mode feature is relatively new, so before you do a Debian install, make sure you’re up-to-date with QNAP’s latest firmware. You need to check that your QNAP NAS has at least v2.1.2 build 081114 firmware and you need to install the QPKG file that enables System Recovery Mode.
I’ll try this out later in this article, but the Recovery process basically involves putting the NAS into a recovery state where very early in the boot process it stops and automatically uploads a new firmware image across the network from a TFTP server. So as long as you haven’t somehow overwritten the boot-loader, this will allow you to revert back to QNAP’s firmware, to a flash backup or to a fresh Debian installer image.
My guideline during this installation process was Martin’s instructions here. The first step was to update to QNAP’s latest firmware. Once I was up-to-date, I shut down, put a fresh hard drive in and reinitialized my system using the standard QNAP procedure. Since the Debian install process will make use of the network TCP/IP parameters, I made sure all were completely specified. Next, using the QNAP configuration pages, I turned on secure shell support for remote login.
Installing
The first step in the Debian install process is to log in via command-line in order to kick off the process. Installation is documented in Martin’s instructions, which I won’t duplicate here. But to get the install going, you’re going to use a command-line on the TS-209 Pro to download three different components: a shell script; a Linux kernel; and a Linux disk image.
After the download, you’ll execute the script to burn the other two parts to flash. When the burn completes, you’ll be told to reboot the box. After the reboot is done, the installer will be running on the NAS, and you’ll use ssh to log in and start the install.
Note that, for me at least, ssh complained about the identification of the TS-209. So I had to reset my secure shell “known hosts” file before I could continue. Once I had done this and logged in, the install was pretty much like any other standard Debian installation using a text-based menu (Figure 1)
Figure 1: Debian Install
To make life easier, the installer recognizes that you’re on a TS-209 and will include all of the required components for this NAS. Since you’re downloading all required components across the network, the faster your network, the quicker the install will be. For me, using a cable-modem, the whole process took a couple of hours and was mostly hands-off, except for a few prompts to set the root password, time zone, disk partitioning, type of usage, etc.
In Use
So, now that the installation is done, let’s take stock. First of all what’s missing as compared to the stock QNAP firmware? The first and most obvious omission is the web interface. If you want to administer this NAS now, you’ll be using a command line.
But if you prefer configuration via a web-interface, you can easily install something like Webmin. Figure 2 shows Webmin running on my TS-209 after I used standard Debian commands to install it. (You can find the basic commands here if you need them and the Webmin Debian installation instructions here.)
Figure 2: Webmin on Debian
You can see in the network configuration screenshot in Figure 2 above that Debian brought up an IPV6 interface in addition to a standard IPV4 interface. You can also see a column of options off to the left that is quite extensive and that’s a general theme here. It may be a bit more work, but when you’re not relying on a vendor to narrow down your options, you have a lot more flexibility to do what you really need, with the downside being additional complexity.
With this distribution, you’re a bit on the bleeding edge with respect to some features that were present in the QNAP firmware. First there is currently no support for DMA mode in the disk drivers, although a Marvell engineer is apparently working it on. This means your disk performance will be a bit less than under QNAP’s firmware.
Second, while there is fan control via the qcontrol command, you can’t yet set it up so that the speed is temperature-based. That means a bit more noise than you may have had before. And you’re on your own for setting up the system so that your disks will spin down when not in use. I’ve seen a procedure for setting this up. But it’s nowhere as easy as the menu-based configuration in the QNAP firmware (for example, you get to decide what it means for the system to be idle).
QNAP included Twonkyvision, a commercial UPnP AV media server, in their firmware. But that won’t be in your new Debian system. If you need a media server, you can install MediaTomb as an open source replacement. Figure 3 shows the web interface of MediaTomb running on my TS-209 Pro after I installed it using apt-get install mediatomb from the command line.
Figure 3: MediaTomb on Debian
There are also little things missing that you might be used to under the standard QNAP firmware. For example, when you plug in a USB drive, don’t expect it to be automatically mounted. If that’s the behavior you want, you’ll need something like autofs, (installed via apt-get install autofs). Then once it’s installed, you’ll have to set up the particular behavior you want by editing the configuration files.
The LED and buzzer behavior may also not be what you expect. But you can change those via the qcontrol command. Execute man qcontrol for options on how to use it.
But enough about what’s missing, what’s available? Lots. Estimates vary, but there may be over 20,000 installable packages available for loading on a Debian system. Want to do some development? I issued an apt-get install build-essential command and a few minutes later I had a complete native tool-chain on the box, which I verified by writing a little “Hello world” program in C (Figure 4 ).
Figure 4: Debian development via the command-line
Interested in python, php or postgresql? They’re all a simple install command away. Want to use some exotic USB peripheral? I counted 69 USB drivers available on my stock Debian system. And of course, since this is Linux, you can always install the kernel source tree, hack away and install your own kernel and drivers. That’s what it’s all about. The freedom to tinker and make the box do what you want instead of what the manufacturer decided was needed.
Recovery
Okay, now you’ve tried it out and maybe decided that it’s not for you. Or maybe you were experimenting a bit and somehow you’ve broken the boot so that the network doesn’t come any more and you can no longer reach the box (trust me, it happens). Now what?
Hopefully, you upgraded to the latest QNAP firmware and installed the QPKG files before you started the process, as you will need it to do a recovery. To verify QNAP’s procedure worked, I stepped through the process mentioned earlier and described by QNAP here. QNAP’s instructions are very good, so I won’t duplicate them here. But I’ll offer a few tips.
If you don’t have one, you’ll first need to have a TFTP server somewhere on your network. Then you’ll configure that server to transfer new firmware for the TS-209.
Since this is low-level, no-frills recovery, the TS-209 makes hard-coded assumptions about your network. The QNAP itself sets an IP address of 192.168.0.10 and assumes the TFTP server is 192.168.0.11.
In my case, I temporarily changed my IP address and fired up a TFTP server on my MacBook with a directly-connected Ethernet cable plugged into the TS-209 (a crossover cable wasn’t necessary, since the TS-209 Pro’s port is auto MDI/X). To start the process, you’ll push and hold the Reset button (Figure 5) on the back of the unit until you hear two beeps.
Figure 5: TS-209 Back Panel
Before you do the transfer, read through the QNAP instructions and take particular note of the description of beeps and LED flashes. That’s all you have to go on to tell you whether the transfer is working. I initially wasn’t paying enough attention to what the LED blinks were telling me and didn’t notice that the TFTP transfer wasn’t happening (while setting up, I had fat-fingered my IP address).
When the process doesn’t appear to complete, you’re in a bit of a quandary. You don’t want to reset the box just in case the flash burn is still occurring. But you can’t wait forever, either. After I waited a long while, I looked closer at the LEDs and saw an unexpected pattern. So I investigated and found my IP address error.
When I fixed it, the TFTP transfer automatically started up and I got the proper sequence of LEDs, beeps and reboots. Now the NAS was back to the standard QNAP firmware that I had transferred via TFTP. Note that the flash recovery image may not be the same version as the currently-released version. So you may need to do a normal firmware update using the QNAP’s firmware update feature in its web admin interface.
Closing Thoughts
I found that the Debian installation worked well and delivered everything it promised: Full control of the TS-209 Pro with thousands of installable packages using an up-to-date Linux kernel. I now have everything I need to turn the NAS into a general-purpose computer for things like development, web serving, home monitoring and of course, file serving.
But as mentioned, there are downsides such as the lack of temperature-controlled cooling fan and DMA support for the disk. Hopefully these items will come with time and when they do, a Debian update will be just an apt-get upgrade away.
And what does standardized Orion support mean for the NAS market? It could mean it will be easier and cheaper for manufacturers to get to market with new Orion-based NASes and further cement Linux as the operating system of choice for these devices. It’s also a selling-point for Marvell, which could put pressure on Marvell’s competitors to do the same.
In the end, only you can decide if putting Debian on your NAS is right for you by weighing the trade-offs and looking at your intended usage. If you’re going to use the box just as a NAS, you’d probably be better off sticking with standard QNAP firmware. But if you think you might like to branch out a bit, and you’re comfortable with Linux administration, I don’t think you can go too far wrong giving Debian a try.