Mount QNAP encrypted volume

So, something went wrong and you need to manually mount encrypted volume which was used in your QNAP NAS (example QNAP TS-231+).

In my case there was everything ok with QNAP TS-231+ on Friday, but during the weekend something happened, I don’t know what. Maybe some automatic update or something like that. No explanation. The NAS booted, was pingable, could ssh to it, but no web interface or share access.

SSH revealed that share users and groups were present, /share folder was populated, but encrypted partition cachedev1 wasn’t mounted.

This is how I got to mount the encrypted QNAP partition, rsynced all the data to external USB 3.0 disk, then I’ve cleaned the QNAP disks with dd and started all over again.

You need to remember the encryption string (password) you’ve used when setting up encryption!

Do this with only half of the disks in NAS (if something goes wrong, you still have one set handy).

1. ssh to QNAP (get QNAP IP from your DHCP server if needed)

2. create mountpoints

[~] # mkdir /mnt/usbdisk /mnt/myencrypteddisk

3. with blkid find your crypt_LUKS encrypted QNAP partition (mine was: /dev/mapper/cachedev1)

[~] # blkid

4. convert your encryption string (password) into QNAP encryption key:

[~] # storage_util --encrypt_pwd pwd=<your encryption string (password)>

5. decrypt partition, passphrase is the Encrypted passwd returned from previous command (storage_util)

[~] # cryptsetup luksOpen /dev/mapper/cachedev1 myencrypteddisk
Enter passphrase for /dev/mapper/cachedev1:

6. mount your encrypted disk with ext4 filesystem readonly

[~] # mount -t ext4 -o ro /dev/mapper/myencrypteddidsk /mnt/myencrypteddisk

7. attach your external USB disk (format it ext4 before doing this)

8. find and mount your external USB disk (dmesg or fdisk -l)

[~] # dmesg
[~]# mount -t ext4 /dev/sdb1 /mnt/usbdisk

9. rsync all the data from your encrypted QNAP disk to external USB disk

[~] # rsync -av --numeric-ids --progress /mnt/myencrypteddisk/ /mnt/usbdisk/

10. when finished, unmount partitions

[~] # umount /mnt/usbdisk ; umount /mnt/myencrypteddisk

11. lock your encrypted QNAP disk

[~] # cryptsetup luksClose myencrypteddisk

That’s it! You have duplicated your QNAP NAS share data onto your external USB disk.

Now you can reinstall QNAP from scratch and afterwards copy the data back to NAS shares.