Last week I got a qnap from a friend where multiple hard drives failed and he was not able to see the volumes with Qnap disk manager. Having exhausted all the other options, we were willing to take up recovery.
The Tool that came to my mind first was photorec. Its open source, runs on Linux ( so I can run it directly on Qnap), and mounts your hard drive in read only mode so you are not making the situation any worse by using this.
Step 1 : Get Putty and Photorec
You will need to get to the Qnap command prompt. Download Putty if you are on windows and connect to your Qnap using putty.
if you run
uname -a on your qnap it will tell you that you are running kernel 4.2 so you can use photorec which needs kernel 2.6 or later
You will also need Photorec . Download and save it on an external hard drive/flash or on a network share that you can mount from Qnap you are recovery data on.
Step 2 : Prepare your media where the recovered files are to be saved
If you have a large External Hard drive, you can save your Photorec on this and save the recovered files on this too.
If not, you can mount any network drive in your Qnap and save files on that. This is what I did for my friends Qnap as his HDD size was 6TB and I couldn’t find an external hard drive large enough to fit all the data.
You can mount any other qnap or windows share by first creating a directory and then mounting your share to this directory. You need ato save data on a drive other than the one you are recovering from.
mount -t cifs -o username= <yourusername> <ipaddress/path_to_sharedfolder> /mnt/recovery
Step 3 : Run photorec recovery and wait for it to finish.
Insert your External Storage into the USB slot of Qnap and check if this is detected and the device name this is given.
here you will see some device with
DEVXXXXX , this is your external drive.
cd to this directory, your photorec directory and run photorec_static
If you get permission denied, you would have to change it to executable first.
chmod 777 photorec_static
run it by running
Rest is all wizard based, you will have to select your hard drive , or your raid and select where to save the files.
your single hard drives will be named sda, sdb, sdc etc
Raids will be md0,md1 etc
Thin Volumes will be cachedev1, cachedev2 etc
What is important is to select your external drive (
/share/ext/DEVXXX) or your mounted network drive ( which we mounted to
/mnt/recovery) when it asks you where you want to store the recovered files to. DO NOT STORE THEM ON YOUR EXISTING VOLUME
Optional : Use Screen Command to Run the Wizard so you can close your putty session and let is run in the background
Screen is preinstalled on Qnap and I like to use it for running commands that take long time.
screen it takes you to a new terminal where you can run all your commands. Run all the commands of step 3 in this terminal.
To return to your original terminal, press
Control +A , then press
D ( as in Detach). This will detetch the screen and you will be back to the main prompt
Though you deteched from that screen, you didn’t kill it, so your process is running in that screen. To go back to the screen, type
It will either show you a list of all the screens that are available to attach to , or reattach you to the screen if there is only 1. It showed me the following output
There are several suitable screens on:
You can now to go your screen by typing screen -r 16993 ( the number before the dot) and it takes you to your screen.
Limitations of Data Recovery this way
It doesn’t restore your directory structure.
It doesn’t restore your file names
Some files Meta data ( exif data in pictures for exmaple) may not be recovered
Your data will be spread in several directories. I had 12,000 directories called recup_dir.xxxx
There will be several possible duplicates. you can use
findimagedupes on linux or a tool like Visipics on windows to elimiate duplicates