QNAP NAS Cannot unmount disk

Whilst setting up my new QNAP NAS, I received a warning:

[Volume DataVol1] The file system is not clean. It is suggested that you go to [Storage Manager] to run "Check File System".

So, wishing to ensure my new HDD was healthy, I did as I was told and ran the ‘File System Check’ tool.

After a couple of minutes, I received another message, this time an error:

[Volume DataVol1] Examination failed (Cannot unmount disk).

Not a great sign. A swift Google for the error message (which you have no doubt done to get to this page!) revealed that SSH and the command line was the way to go, thanks to Maciej Mensfeld:

/etc/init.d/services.sh stop
/etc/init.d/opentftp.sh stop
/etc/init.d/Qthttpd.sh stop
umount /dev/md0
e2fsck -f -v -C 0 /dev/md0
mount /dev/md0
reboot

/dev/md0 did not exist for me, however md9 was available. You can check your /dev/mdN by using the following commands:

cat /etc/mtab
# This revealed /dev/md9 /mnt/HDA_ROOT ext3 rw,data=ordered 0 0 for me.
# or you can try...
cat /etc/fstab

Unfortunately, umount still failed here, suggesting something was still accessing the HDD. Running lsof /dev/md9 reveals the processes accessing our HDD(s), so that we can then promptly end them and run our file system check.

You could use kill -9 PID for each of the processes, however I found the dd instance writing to /mnt/HDA_ROOT/.logs/kmsg would respawn, so to help combat this, we can combine our commands:

pkill -9 PID1 PID2 ... PIDN && umount /dev/md9

Success hopefully! If so, we can now go ahead and e2fsck -f -v -C 0 /dev/md9. Once completed, we could remount the HDD, but we may as well reboot the NAS and start back at the beginning!