nfs automount at system startup
-
- New here
- Posts: 9
- Joined: Sun Dec 14, 2014 2:18 pm
nfs automount at system startup
Hello,
I just brought an ts-451 and want it mount shared folder in another nas through nfs. I added the mount entry in the /etc/fstab on qnap ts-451, but after reboot, the entry was removed from fstab and I need manually mount that share. How can I do so that the ts-451 can remember my changes and mount the remote nfs share automatically every time it reboot? Thanks!
I just brought an ts-451 and want it mount shared folder in another nas through nfs. I added the mount entry in the /etc/fstab on qnap ts-451, but after reboot, the entry was removed from fstab and I need manually mount that share. How can I do so that the ts-451 can remember my changes and mount the remote nfs share automatically every time it reboot? Thanks!
- pwilson
- Guru
- Posts: 22533
- Joined: Fri Mar 06, 2009 11:20 am
- Location: Victoria, BC, Canada (UTC-08:00)
Re: nfs automount at system startup
What command do you use to manually mount it?cxterm wrote:Hello,
I just brought an ts-451 and want it mount shared folder in another nas through nfs. I added the mount entry in the /etc/fstab on qnap ts-451, but after reboot, the entry was removed from fstab and I need manually mount that share. How can I do so that the ts-451 can remember my changes and mount the remote nfs share automatically every time it reboot? Thanks!
Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs
Please review: When you're asking a question, please include the following.
-
- New here
- Posts: 9
- Joined: Sun Dec 14, 2014 2:18 pm
Re: nfs automount at system startup
I edit the /etc/fstab and add a line:pwilson wrote:What command do you use to manually mount it?
192.168.1.106:/volume/share /share/backup nfs rw 0 0
then in the command line:
mount /share/backup
but after the reboot, the line I added in fstab was gone.
- pwilson
- Guru
- Posts: 22533
- Joined: Fri Mar 06, 2009 11:20 am
- Location: Victoria, BC, Canada (UTC-08:00)
Re: nfs automount at system startup
Figure out the "/sbin/mount.nfs" command needed, and I will provide the rest. (I can't help with the NFS mount part, as I abandoned NFS in 1992. All my Linux machines here use Samba rather than NFS to mount my NAS filesystems).cxterm wrote:I edit the /etc/fstab and add a line:pwilson wrote:What command do you use to manually mount it?
192.168.1.106:/volume/share /share/backup nfs rw 0 0
then in the command line:
mount /share/backup
but after the reboot, the line I added in fstab was gone.
The NAS doesn't really use the /etc/fstab at all. The /etc/fstab file on the NAS lives in a RAMdisk, and therefore does not survive a "reboot". Simply figure out the "/sbin/mount.nfs" or "/bin/mount -t nfs" command you need to use, and I will help you "script" it, so that it "autoruns" at NAS startup.
Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs
Please review: When you're asking a question, please include the following.
-
- New here
- Posts: 9
- Joined: Sun Dec 14, 2014 2:18 pm
Re: nfs automount at system startup
Thanks.pwilson wrote: Figure out the "/sbin/mount.nfs" command needed, and I will provide the rest. (I can't help with the NFS mount part, as I abandoned NFS in 1992. All my Linux machines here use Samba rather than NFS to mount my NAS filesystems).
The NAS doesn't really use the /etc/fstab at all. The /etc/fstab file on the NAS lives in a RAMdisk, and therefore does not survive a "reboot". Simply figure out the "/sbin/mount.nfs" or "/bin/mount -t nfs" command you need to use, and I will help you "script" it, so that it "autoruns" at NAS startup.
This is first time use the qnap nas. It looks like qnap does some modification to handle the startup.
I can use command line mount the nfs folder without problem. but how to make NAS save the change and auto applied it everytime it restart?
Currently I just found a solution is save the mount command to a script and append a section in /etc/qpkg.conf to let system run that script at startup.
- pwilson
- Guru
- Posts: 22533
- Joined: Fri Mar 06, 2009 11:20 am
- Location: Victoria, BC, Canada (UTC-08:00)
Re: nfs automount at system startup
If you will provide the "mount" command, I will provide the rest. You can review my "scripts" to see what they are doing, but I'm not willing to do my part until you do yours.cxterm wrote:Thanks.pwilson wrote: Figure out the "/sbin/mount.nfs" command needed, and I will provide the rest. (I can't help with the NFS mount part, as I abandoned NFS in 1992. All my Linux machines here use Samba rather than NFS to mount my NAS filesystems).
The NAS doesn't really use the /etc/fstab at all. The /etc/fstab file on the NAS lives in a RAMdisk, and therefore does not survive a "reboot". Simply figure out the "/sbin/mount.nfs" or "/bin/mount -t nfs" command you need to use, and I will help you "script" it, so that it "autoruns" at NAS startup.
This is first time use the qnap nas. It looks like qnap does some modification to handle the startup.
I can use command line mount the nfs folder without problem. but how to make NAS save the change and auto applied it everytime it restart?
Currently I just found a solution is save the mount command to a script and append a section in /etc/qpkg.conf to let system run that script at startup.
Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs
Please review: When you're asking a question, please include the following.
-
- New here
- Posts: 9
- Joined: Sun Dec 14, 2014 2:18 pm
Re: nfs automount at system startup
My mount command is pretty straightforward.pwilson wrote: If you will provide the "mount" command, I will provide the rest. You can review my "scripts" to see what they are doing, but I'm not willing to do my part until you do yours.
# mount -t nfs -o rw,intr 192.168.1.106:/volume/share /share/backup
Please show me your script to learn. Thanks.
Usually in linux machine, after modify the /etc/fstab will keep the system automout nfs share at startup. but as your said, qnap nas will rewrite the fstab at boot. Currently I can do the following way:
create a section on /etc/config/qpkg.conf:
Code: Select all
[remoteNFS]
Name = remoteNFS
Version = 1.0.0
Author = cxterm
Date = 2014-12-14
Shell = /share/CACHEDEV_DATA/.qpkg/remoteNFS/remoteNFS.sh
Install_Path = /share/CACHEDEV_DATA/.qpkg/remoteNFS
Enable = TRUE
Code: Select all
#!/bin/sh
CONF=/etc/config/qpkg.conf
QPKG_NAME="remoteNFS"
case "$1" in
start)
ENABLED=$(/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF)
if [ "$ENABLED" != "TRUE" ]; then
echo "$QPKG_NAME is disabled."
exit 1
fi
: ADD START ACTIONS HERE
mount -t nfs -o rw,intr 192.168.1.106:/volume/share /share/backup 1>> /tmp/remoteNFS.log &2>> /tmp/remoteNFS.log
;;
stop)
: ADD STOP ACTIONS HERE
umount /share/backup 1>> /tmp/remoteNFS.log &2>> /tmp/remoteNFS.log
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
by the way, could you tell me how to add a ip/hostname pair? Like the fstab, the /etc/hosts was also rewritten at each startup. so if I want to add my customized ip/hostname pair, how should i do? for example, I want the qnap nas know the short hostname "LinuxNAS" resolved to ip address 192.168.1.106,
if I add the line
Code: Select all
192.168.1.106 LinuxNAS
- pwilson
- Guru
- Posts: 22533
- Joined: Fri Mar 06, 2009 11:20 am
- Location: Victoria, BC, Canada (UTC-08:00)
Re: nfs automount at system startup
Don't beat on your Hosts file. Simply fix your DNS Server, so you don't need to do that nonsense.cxterm wrote:My mount command is pretty straightforward.pwilson wrote: If you will provide the "mount" command, I will provide the rest. You can review my "scripts" to see what they are doing, but I'm not willing to do my part until you do yours.
# mount -t nfs -o rw,intr 192.168.1.106:/volume/share /share/backup
Please show me your script to learn. Thanks.
Usually in linux machine, after modify the /etc/fstab will keep the system automout nfs share at startup. but as your said, qnap nas will rewrite the fstab at boot. Currently I can do the following way:
create a section on /etc/config/qpkg.conf:
then create a shell script call remoteNFS.sh in the folder /share/CACHEDEV_DATA/.qpkg/remoteNFSCode: Select all
[remoteNFS] Name = remoteNFS Version = 1.0.0 Author = cxterm Date = 2014-12-14 Shell = /share/CACHEDEV_DATA/.qpkg/remoteNFS/remoteNFS.sh Install_Path = /share/CACHEDEV_DATA/.qpkg/remoteNFS Enable = TRUE
It works. but I am interesting in any easier way to complete this job.Code: Select all
#!/bin/sh CONF=/etc/config/qpkg.conf QPKG_NAME="remoteNFS" case "$1" in start) ENABLED=$(/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF) if [ "$ENABLED" != "TRUE" ]; then echo "$QPKG_NAME is disabled." exit 1 fi : ADD START ACTIONS HERE mount -t nfs -o rw,intr 192.168.1.106:/volume/share /share/backup 1>> /tmp/remoteNFS.log &2>> /tmp/remoteNFS.log ;; stop) : ADD STOP ACTIONS HERE umount /share/backup 1>> /tmp/remoteNFS.log &2>> /tmp/remoteNFS.log ;; restart) $0 stop $0 start ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 esac exit 0
by the way, could you tell me how to add a ip/hostname pair? Like the fstab, the /etc/hosts was also rewritten at each startup. so if I want to add my customized ip/hostname pair, how should i do? for example, I want the qnap nas know the short hostname "LinuxNAS" resolved to ip address 192.168.1.106,
if I add the linein /etc/hosts. It works well. But, after reboot, the above line no longer in the /etc/hosts, then nas will not find the host by the name 'LinuxNAS'.Code: Select all
192.168.1.106 LinuxNAS
As for your NFS mount (original issue), try the following script on your NAS:
Please login to your NAS via SSH, login as "admin"and run the following commands.
Code: Select all
mount -t ext2 $(/sbin/hal_app --get_boot_pd port_id=0)6 /tmp/config
ln -f /tmp/config/autorun.sh /tmp/config/autorun.sh.OLD
rm -f /tmp/config/autorun.sh
touch /tmp/config/autorun.sh
chmod +x /tmp/config/autorun.sh
cat <<EOF >>/tmp/config/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
touch /tmp/autorun.ran
# done
EOF
echo "unmounting /tmp/config..."
umount /tmp/config
touch /etc/config/autorun.sh
chmod +x /etc/config/autorun.sh
cat <<EOF1 >>/etc/config/autorun.sh
#!/bin/sh
#
# /etc/config/autorun.sh - These commands run at every NAS Startup
#
mount -t nfs -o rw,intr 192.168.1.106:/volume/share /share/backup 1>> /tmp/remoteNFS.log &2>> /tmp/remoteNFS.log
#done
EOF1
echo "Edit /etc/config/autorun.sh for all further changes to the autostart procedure of the NAS.
#done
You can get your /etc/config/autorun.sh script to run your /share/CACHEDEV_DATA/.qpkg/remoteNFS script if you prefer.
Last edited by pwilson on Mon Dec 15, 2014 4:20 am, edited 1 time in total.
Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs
Please review: When you're asking a question, please include the following.
-
- New here
- Posts: 9
- Joined: Sun Dec 14, 2014 2:18 pm
Re: nfs automount at system startup
Thanks. but when I run your script, it report errors:pwilson wrote: Don't beat on your Hosts file. Simply fix your DNS Server, so you don't need to do that nonsense.
As for your NFS mount (original issue), try the following script on your NAS:
Please login to your NAS via SSH, login as "admin"and run the following commands.
Warning: This solution is specific to newer Intel-based QNAP NAS models. This solution is not correct for QNAP any ARM-based model, or older Intel-based NAS Models. You can modify the /etc/config/autorun.sh script to your requirements thereafter.Code: Select all
mount -t ext2 $(/sbin/hal_app --get_boot_pd port_id=0) /tmp/config ln -f /tmp/config/autorun.sh /tmp/config/autorun.sh.OLD rm -f /tmp/config/autorun.sh touch /tmp/config/autorun.sh chmod +x /tmp/config/autorun.sh cat <<EOF >>/tmp/config/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 touch /tmp/autorun.ran # done EOF echo "unmounting /tmp/config..." umount /tmp/config touch /etc/config/autorun.sh chmod +x /etc/config/autorun.sh cat <<EOF1 >>/etc/config/autorun.sh #!/bin/sh # # /etc/config/autorun.sh - These commands run at every NAS Startup # mount -t nfs -o rw,intr 192.168.1.106:/volume/share /share/backup 1>> /tmp/remoteNFS.log &2>> /tmp/remoteNFS.log #done EOF1 echo "Edit /etc/config/autorun.sh for all further changes to the autostart procedure of the NAS. #done
You can get your /etc/config/autorun.sh script to run your /share/CACHEDEV_DATA/.qpkg/remoteNFS script if you prefer.
Code: Select all
# mount -t ext2 $(/sbin/hal_app --get_boot_pd port_id=0) /tmp/config
mount: wrong fs type, bad option, bad superblock on /dev/sde,
missing codepage or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
# dmesg | tail -5
[ 198.004635] cfg80211: (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[ 198.012400] cfg80211: (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[ 200.586668] input: uinput-remotepad-rel_x_y as /devices/virtual/input/input7
[ 211.620407] input: uinput-QTV as /devices/virtual/input/input8
[ 1965.253961] EXT2-fs (sde): error: can't find an ext2 filesystem on dev sde.
- pwilson
- Guru
- Posts: 22533
- Joined: Fri Mar 06, 2009 11:20 am
- Location: Victoria, BC, Canada (UTC-08:00)
Re: nfs automount at system startup
Please furnish the output of:cxterm wrote:Thanks. but when I run your script, it report errors:pwilson wrote: Don't beat on your Hosts file. Simply fix your DNS Server, so you don't need to do that nonsense.
As for your NFS mount (original issue), try the following script on your NAS:
Please login to your NAS via SSH, login as "admin"and run the following commands.
Warning: This solution is specific to newer Intel-based QNAP NAS models. This solution is not correct for QNAP any ARM-based model, or older Intel-based NAS Models. You can modify the /etc/config/autorun.sh script to your requirements thereafter.Code: Select all
mount -t ext2 $(/sbin/hal_app --get_boot_pd port_id=0)6 /tmp/config ln -f /tmp/config/autorun.sh /tmp/config/autorun.sh.OLD rm -f /tmp/config/autorun.sh touch /tmp/config/autorun.sh chmod +x /tmp/config/autorun.sh cat <<EOF >>/tmp/config/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 touch /tmp/autorun.ran # done EOF echo "unmounting /tmp/config..." umount /tmp/config touch /etc/config/autorun.sh chmod +x /etc/config/autorun.sh cat <<EOF1 >>/etc/config/autorun.sh #!/bin/sh # # /etc/config/autorun.sh - These commands run at every NAS Startup # mount -t nfs -o rw,intr 192.168.1.106:/volume/share /share/backup 1>> /tmp/remoteNFS.log &2>> /tmp/remoteNFS.log #done EOF1 echo "Edit /etc/config/autorun.sh for all further changes to the autostart procedure of the NAS. #done
You can get your /etc/config/autorun.sh script to run your /share/CACHEDEV_DATA/.qpkg/remoteNFS script if you prefer.Code: Select all
# mount -t ext2 $(/sbin/hal_app --get_boot_pd port_id=0) /tmp/config mount: wrong fs type, bad option, bad superblock on /dev/sde, missing codepage or other error In some cases useful info is found in syslog - try dmesg | tail or so # dmesg | tail -5 [ 198.004635] cfg80211: (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) [ 198.012400] cfg80211: (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) [ 200.586668] input: uinput-remotepad-rel_x_y as /devices/virtual/input/input7 [ 211.620407] input: uinput-QTV as /devices/virtual/input/input8 [ 1965.253961] EXT2-fs (sde): error: can't find an ext2 filesystem on dev sde.
Code: Select all
parted /dev/sde print
Code: Select all
parted /dev/sde print
Model: USB DISK MODULE (scsi)
Disk /dev/sde: 516MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 16.4kB 2228kB 2212kB primary ext2
2 2228kB 250MB 248MB primary ext2
3 250MB 498MB 248MB primary ext2
4 498MB 516MB 17.4MB extended
5 498MB 507MB 8503kB logical ext2
6 507MB 516MB 8897kB logical ext2
Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs
Please review: When you're asking a question, please include the following.
-
- New here
- Posts: 9
- Joined: Sun Dec 14, 2014 2:18 pm
Re: nfs automount at system startup
Hm, this time works! I missed a 6 in the mount command.
Thank you so much! learns a lot.
Thank you so much! learns a lot.
- pwilson
- Guru
- Posts: 22533
- Joined: Fri Mar 06, 2009 11:20 am
- Location: Victoria, BC, Canada (UTC-08:00)
Re: nfs automount at system startup
Anytime.cxterm wrote:Hm, this time works! I missed a 6 in the mount command.
Thank you so much! learns a lot.
Some of the information I shared comes from the QNAPedia article: Running Your Own Application at Startup. Unfortunately this article has not been updated to provide instructions for newer Intel-based models like your TS-451 or my TS-470.
I absolutely hate the nasty/unsupported QPKG kluge technique (it isn't supported by QNAP at all), so I always provide instructions for the supported MTD/Flash method.
Please note that my instructions you just followed do not follow any of the techniques listed in that QNAPedia article. (It is not a good idea to keep modifying the MTD/Flash area constantly (Flash fatigue), so I use the MTD/Flash method to "bootstrap" a new "autorun.sh" file at /etc/config/autorun.sh file to actually do the "startup" commands, as you can easily modify this file as often as you want (without worrying about Flash fatigue).
I deliberately chose this directory, as it gets backed up automatically on the NAS, which helps protect your script from corruption, as you can "restore" a previous version of it, it it gets corrupted, or if you make changes that don't work, and you want to revert to a previous version. (The NAS automatically maintains 10 weekly backups your /etc/config directory without any effort on your part).
Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs
Please review: When you're asking a question, please include the following.
-
- New here
- Posts: 9
- Joined: Sun Dec 14, 2014 2:18 pm
Re: nfs automount at system startup
Agree.
I like the way you provided to use autorun.sh. I aslo noticed the article you mentioned. But it says the MTD/Flash method is old and unsupported in my ts-451. Thanks for let me know I can still use this method.
I like the way you provided to use autorun.sh. I aslo noticed the article you mentioned. But it says the MTD/Flash method is old and unsupported in my ts-451. Thanks for let me know I can still use this method.
- pwilson
- Guru
- Posts: 22533
- Joined: Fri Mar 06, 2009 11:20 am
- Location: Victoria, BC, Canada (UTC-08:00)
Re: nfs automount at system startup
I have Wiki access, but I have chosen not to modify that QNAPedia article. Some idiot vandalized it to claim that BS about the QPKG method being supported (it is not supported), and to claim that the MTD/Flash method isn't supported (it is supported).cxterm wrote:Agree.
I like the way you provided to use autorun.sh. I aslo noticed the article you mentioned. But it says the MTD/Flash method is old and unsupported in my ts-451. Thanks for let me know I can still use this method.
The only truth in that article as far as I'm concerned is that the MTD/Flash method is "old". It is "old" and it remains the only supported method, and has worked this way since the beginning of QNAP. Even my old TS-101 supported this method. That nasty QPKG method, requires a working QPKG subsystem, and is difficult to troubleshoot if the QPKG subsystem doesn't start properly for any reason.
Due to QNAPedia vandalism, I am not willing to "fix" any QNAPedia article.
Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs
Please review: When you're asking a question, please include the following.
- schumaku
- Guru
- Posts: 43578
- Joined: Mon Jan 21, 2008 4:41 pm
- Location: Kloten (Zurich), Switzerland -- Skype: schumaku
- Contact:
Re: nfs automount at system startup
Same here. Had to undo (not talking of Spam...) several edits.pwilson wrote:Due to QNAPedia vandalism, I am not willing to "fix" any QNAPedia article.