Recently I purchased a qnap TS-251+ mostly for using its applications like photo sharing/QvPC/Qsirch and others. I already have my storage on a raidz array which is hosted on FreeNAS 9.10. FreeNAS then provides the storage through various ways to my pc’s/mac in my house using mostly CIFS and ISCSI. My TS-251+ currently hosts only 1 6TB disk (will purchase another one in the future for a raid mirroring volume) but I don’t care so much because all my storage is on the FreeNAS at the moment.
After purchasing the qnap I found out that there is no way that you can mount external shares automatically from the UI (you can only do it for ISCSI targets). And the worse thing is that if you mount them from command line when you reboot the machine they are not remounted because the /etc/fstab file on the NAS lives in RAM, and therefore does not survive the “reboot”
So after a bit of research here I found out how you can do it.
Mount the config ramblock /dev/sdb6
mount -t ext2 /dev/sdb6 /tmp/config
reading through the qnap forums I found out that writing to the flash all the time is not recommended so it is advisable to create a script in flash that will run your other script. This other script can reside in e.g /etc/config and you can edit it all the time without mounting the ramblock
touch /tmp/config/autorun.sh chmod +x /tmp/config/autorun.sh vi autorun.sh
#!/bin/sh # AUTORUN.SH - "Boot strap" # This script forces the NAS to run "/etc/config/autorun.sh" at every startup (if this file exists). # /etc/config/autorun.sh # done
unmount the ramblock
then I go and create my script in /etc/config/
touch /etc/config/autorun.sh chmod +x /etc/config/autorun.sh
and my script looks like that
#! /bin/sh # The script waits until the system has mounted the system shares # This script ends after the filesystem has been mounted. mount="CACHEDEV3" for i in 1 2 3 4 5 6 do grep -qs "$mount" /etc/mtab; if [ $? -eq 0 ]; then mount -t cifs //192.168.1.x/Repository /share/Public/Repository -o username=user,password=pass echo -e $(date) " - Mount successful" >> /tmp/autorun.log exit 0 fi sleep 30 done echo -e $(date) " - Mount not successful" >> /tmp/autorun.log exit 1
So the script checks if CACHEDEV3 is mounted and if not it waits for 30 sec for 6 times maximum. When it find the mount in the /etc/mtab then it mounts the cifs share from my FreeNAS. Finally it writes to a simple log file if it was successful or not.
Found out through the forums that the best location to save your scripts is in /etc/config/ because this location is backed up from qnap
So now all my files reside on the raidz on FreeNAS but indexed from QNAP.