I’m a happy owner of a QNAP TS-251 2-bay NAS. As is the case with pretty much every consumer NAS out there, the TS-251 too runs a customized operating system based on the Linux kernel. This means that it shares data with Windows computers using Samba, an open source implementation of the SMB protocol. Unfortunately, Samba is a frail specimen that breaks all too often and troubleshooting it can be a tremendous pain, so the easiest course of action when one is having issues with it is to restart from scratch.
I searched far and wide, but apparently, there isn’t much information about how to restore QNAP NAS devices to their factory defaults available on the Internet. So I rolled up my sleeves and started digging to see if I could uncover a way to achieve exactly that. Long-pressing the reset button for 10 seconds didn’t seem to do that: it merely reset a few settings but kept everything else intact. I then decided to try my luck with the command line and voilà, there was a way.
This process is destructive and you will lose all data present on your NAS. If you have valuable data, back it up before attempting a factory restore. You’ve been warned.
Connect to the NAS through SSH
Since NAS devices are meant to be used as headless computers, i.e., without a monitor attached to them, the only way to use the command line is by connecting to them through SSH. Here’s how to do that:
Windows does not come with SSH support out of the box. There is, however, a very nifty application called Putty that, among other things, lets the user connect to their Linux or UNIX boxes from their Windows PC. There’s no need to install it: just download the executable file and double-click to open it.
We’ll need to type the host name or IP address for our NAS. The host name is the same as that that appears in the Network window. If you don’t remember it, don’t worry: you can still use the local IP address assigned to the NAS. Most consumer routers will assign an IP address to any device that requests one. While it’s possible to create a DHCP reservation to tell the router to always assign the same IP address to a device, most users won’t probably bother doing it. Joke’s on them. Thankfully, QNAP devices have a sticker on the rear that tells the MAC addresses of their Ethernet ports. They’re surely identical except for the ending number (or letter). Note them down and write the following command in the Command Prompt
arp -a | find "xy"
where xy are the last two letters of one of the MAC addresses.
Bingo! The IP address of my NAS is 192.168.0.150. Let’s type it into the Putty window and click Open.
You’re likely to be shown this prompt. Click Yes to confirm that you want to connect. Disregard the warning about a security breach.
Once you’ve clicked Yes, you’ll be presented with this window:
You must enter the username you want to use to connect to the NAS. As with every Linux computer, only administrators can perform advanced operations. The default administrator account login credentials are
Press Enter and you’re connected to the NAS.
Linux and MacOS
As a Windows guy, I sometimes envy Linux and Mac guys because they have some stuff that we Microsoft folks do not get out of the box. SSH is one of those. To connect to your NAS using SSH, you just need to open a Terminal window and type in
and type the password for the user admin. Remember to replace nas_hostname with the actual host name of your NAS or its IP address.
Finding out the IP address of your NAS is akin to what you would do on Windows, with a slight difference:
arp -a | grep xy
Restoring the NAS
Once our SSH connection is up and running, it’s time to start messing around with the command line. The first thing we want to do is to go to the /etc/init.d folder with the command
If you’ve used Linux in the past, this path may ring a bell or two with you: it contains the executables for background daemons and allows the user to start, stop, restart or get status information about background processes. Oddly enough, the files stored in QNAP NASes are shell scripts (with a .sh extension) and aren’t necessarily daemons.
We will need to run the killnas.sh command. Don’t be scared, your NAS will raise from the ashes like the Arabian phoenix. Type
bash killnas.sh reset_all_nas_disk_and_reboot --yes-i-know-what-i-am-doing
No, I’m not kidding you. This is the actual command you have to type. Press Enter to confirm.
The device will start deleting the partitions on your hard drives. Once done, close the SSH connection by typing
Perform the initial setup
Open your browser of choice and connect to your NAS using its IP address (it doesn’t have an host name anymore because we’ve reset it). You’ll be shown the initial setup screen.
Follow the on-screen instructions to configure your NAS.