LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-06-2020, 12:59 PM   #31
michaelk
Moderator
 
Registered: Aug 2002
Posts: 20,878

Rep: Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775Reputation: 3775

To elaborate on computersavvy's post what is your current /etc/fstab line for the nfs share?

As stated if you use noauto as shown in your #1 post using mount -a will not try to mount the nfs share so it has been changed. I suspect there is still an error which is the reason your script does not work. In addition typically in the boot order the init process will mount the filesystems in /etc/fstab prior to network being up so network shares tend to fail which is why rebooting does not work. Using _netdev option will delay the mounting of your nfs share until the network is up.

I like to use autofs or x-systemd.automount which will only mount the share when I access the nfs mount point. Using timeout options prevent hangups...
 
Old 11-07-2020, 05:58 AM   #32
globalsarge
LQ Newbie
 
Registered: Oct 2020
Location: Florida Panhandle
Distribution: Kubuntu x86_64, currently running 20.04.1LTS on 1 SSD; maintaining 18.04.5LTS on another SSD.
Posts: 12

Original Poster
Rep: Reputation: Disabled
Thank you sgosnell. I ran the commands (exportfs and the nfs-kernel-server restart as root from the NAS.

Back into my computer, I removed the "//" in front of the NAS IP address and ran:

Code:
$ sudo mount -av
/                        : ignored
/media/Data              : already mounted
mount.nfs: timeout set for Sat Nov  7 04:39:36 2020
mount.nfs: trying text-based options 'vers=4.2,addr=192.168.1.105,clientaddr=192.168.1.235'
/media/NAS               : successfully mounted
/media/tmpdisk           : already mounted
...and it works! was the problem with fstab the "//" in front of the NAS mount line?

Okay, so here is my updated fstab:
Code:
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=9cb44c29-b632-4035-ab0c-26bab80761c3 /   ext4    errors=remount-ro 0    1
# /boot/efi was on /dev/sda1 during installation
#
# Data drive mount to /media/Data 
UUID=9d3f1ff1-99b4-418c-8dca-84916431f9d5 /media/Data  ext4  auto,exec,rw,noatime         0   2
#
# NAS server mount to /media/NAS. Script added to System Settings>Autostart to mount NAS if online.
192.168.1.105:/nas     /media/NAS    nfs    defaults,nofail,exec          0   0
#
# This line mounts a RAM disk for temp files storage to prevent unnecessary SSD writes.
tmpfs                 /media/tmpdisk  tmpfs   nodev,nosuid,noexec,nodiratime,size=1024M             0   0
So I rebooted my computer to see if fstab would automatically mount the NAS and it did!

So now, the mount script fstab-mount-nas. I unmounted the NAS then run the script. No joy! NAS is not mounted. Here is the file for review:
Code:
!/bin/bash
#fstab_Mount NAS
# script to mount NAS if it's powered on
if [ ping -c1 -w3 192.168.1.105 >/dev/null 2>&1 ]
  then
    mount 192.168.1.105:/nas /media/NAS
    echo "NAS is mounted to /media/NAS"
  else
    echo "NAS is not mounted"
fi
2 down and 1 to go.
 
Old 11-07-2020, 06:18 AM   #33
globalsarge
LQ Newbie
 
Registered: Oct 2020
Location: Florida Panhandle
Distribution: Kubuntu x86_64, currently running 20.04.1LTS on 1 SSD; maintaining 18.04.5LTS on another SSD.
Posts: 12

Original Poster
Rep: Reputation: Disabled
Okay, so I realized I needed to mount my NAS after the script failed and since the fstab works, I entered:
Code:
sudo mount /media/NAS
...and it works! Then I unmounted the NAS and rebooted the NAS. When it was back up, I ran the command again, sudo mount /media/NAS and it works! I really don't have any need for the script since I can sudo mount and umount commands to mount and unmount the NAS.

Unless anyone has any other concerns or issues, I'll mark this thread SOLVED later today.
 
Old 11-07-2020, 09:53 AM   #34
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,945

Rep: Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536
Use bg in the options in fstab, and it will continue to try to mount the NFS shares in the background if it can't mount them initially. You really don't need the script. My devices automatically remount the share if the server goes down and comes back up.

I didn't see a // in your fstab, but yes, that is a problem. I saw it in the error messages but couldn't figure out where it was coming from. I coudn't keep up with the changes you made as time went on.
 
Old 11-07-2020, 10:38 AM   #35
computersavvy
Member
 
Registered: Aug 2016
Posts: 728

Rep: Reputation: 226Reputation: 226Reputation: 226
Quote:
Originally Posted by globalsarge View Post
Okay, so I realized I needed to mount my NAS after the script failed and since the fstab works, I entered:
Code:
sudo mount /media/NAS
...and it works! Then I unmounted the NAS and rebooted the NAS. When it was back up, I ran the command again, sudo mount /media/NAS and it works! I really don't have any need for the script since I can sudo mount and umount commands to mount and unmount the NAS.

Unless anyone has any other concerns or issues, I'll mark this thread SOLVED later today.
In addition to what sgosnell has said, if you want to be able to mount it without using sudo then add in the "user" option in fstab after which your regular user will be able to mount and unmount it. Without that your regular user could not run the script and successfully mount the NAS.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Ubuntu 18.04.5 LTS Released with Linux Kernel 5.4 LTS from Ubuntu 20.04 LTS LXer Syndicated Linux News 0 08-14-2020 09:28 AM
LXer: Kubuntu Devs Need Your Help to Test KDE Plasma 5.8.8 LTS on Kubuntu 16.04 LTS LXer Syndicated Linux News 0 10-29-2017 08:51 AM
LXer: Canonical Patches OpenSSL Regression in Ubuntu 16.04 LTS, 14.04 LTS and 12.04 LTS LXer Syndicated Linux News 0 09-27-2016 01:32 PM
[SOLVED] Unable to install Kubuntu 14.04.1 LTS on UEFI system. americast Linux - Laptop and Netbook 25 04-20-2015 03:43 PM
Why unable to mount my nas in fstab get "mount error(5) Input/output error fi5ban Linux - Networking 0 04-01-2009 11:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration