[SOLVED] Correct fstab entry to mount my NAS

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
LegacyMJR

[SOLVED] Correct fstab entry to mount my NAS

Post by LegacyMJR »

I have finally dumped all of my Windows systems and moved them all onto Linux Mint. Having solved the nonsense that is getting a modern all-in-one printer scanner to function I have now moved onto connecting my NAS. My problem is the age-old one of not mounting at boot time. If I issue a sudo mount -a once the system is up it mounts fine but never at boot. My fstab entry is shown below. What is wrong with it please.

# mount my Nas
//192.168.0.12/Public /home/mike/Nas cifs rw,guest,vers=1.0,iocharset=utf8,_netdev,noperm 0 0
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
AndyMH
Level 21
Level 21
Posts: 13575
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Correct fstab entry to mount my NAS

Post by AndyMH »

Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
LegacyMJR

Re: Correct fstab entry to mount my NAS

Post by LegacyMJR »

Why would I do that it does not answer my question?
User avatar
AndyMH
Level 21
Level 21
Posts: 13575
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Correct fstab entry to mount my NAS

Post by AndyMH »

If you want to auto mount your NAS you will have to supply username and password, the link gives you the syntax. My NAS is mounted in fstab as

Code: Select all

# mount point for synology NAS used in rsync backups
192.168.0.5:/volume1/homes/andy/backups /media/andy/diskstation nfs rw,noauto,user,nofail 0 0
but with NOAUTO so it doesn't mount automatically.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
LegacyMJR

Re: Correct fstab entry to mount my NAS

Post by LegacyMJR »

It does not have/need a username or password and the whole point is that it is not auto mounting.

That is the whole problem - the sheer amount of questions and answers on this topic show its a can of worms.
altair4
Level 20
Level 20
Posts: 11427
Joined: Tue Feb 03, 2009 10:27 am

Re: Correct fstab entry to mount my NAS

Post by altair4 »

This issue is fstab is executed before the network stack it up in Mint. I'll give you some possible options:

[1] Change the way you mount it.

This depends on how you use your share. What I am suggesting is not mounting at boot but mounting it when you need it. If you change your fstab statement to this:
//192.168.0.12/Public /home/mike/Nas cifs rw,guest,vers=1.0,iocharset=utf8,_netdev,noperm,noauto,user 0 0
A mount icon will show up on the side panel of your file manager. Click on it and it will look to fstab to find out how to mount it. You can use the same icon to unmount it if desired.

[2] Mount it via /etc/rc.local by adding a line to it above the exit 0 line:

[2a] Keep your line in fstab as you originally had it then add mount -a to rc.local

[OR 2b] Remove the line in fstab and add a mount in rc.local:

Code: Select all

mount -t cifs //192.168.0.12/Public /home/mike/Nas -o rw,guest,vers=1.0,iocharset=utf8,_netdev,noperm
[3] Add a file to /etc/network/if-up.d/

** Create a script:

Code: Select all

gksu xed /etc/network/if-up.d/fstab
** With this content:

Code: Select all

#!/bin/sh
mount -a
** Make it executable:

Code: Select all

sudo chmod +x /etc/network/if-up.d/fstab
Anything added to if-up.d will execute only after the network stack is operational.

EDIT FOR MINT19 USERS
: If you want to use the rc.local method you need to enable it first:

The rc-local service already exists ( systemctl cat rc-local.service ) all it needs is an rc.local file:

Code: Select all

sudo touch /etc/rc.local
That is executable:

Code: Select all

sudo chmod +x /etc/rc.local
And has at least this contents:

Code: Select all

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

### Add terminal commands below this line and before "exit 0":

exit 0
Then reboot. When you log in again make sure the rc-local service is running:

Code: Select all

sudo systemctl status rc-local
Last edited by altair4 on Fri Aug 03, 2018 2:24 pm, edited 6 times in total.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Correct fstab entry to mount my NAS

Post by smurphos »

altair4 wrote: Fri Apr 27, 2018 6:53 am This issue is fstab is executed before the network stack it up in Mint.
Does the _netdev option not cover this anymore? I used to mount a samba share on boot with the fstab line below and it worked flawlessly - this was 18.x Cinnamon with a share on 18.x XFCE. I stopped using Samba when all of the 'Eternal Blue' SMBv1 stuff was going on.

//192.168.1.3/shared_storage /mnt/plex_server_drive cifs uid=steve,credentials=/home/steve/.smbcredentials,iocharset=utf8,sec=ntlm,_netdev,nofail 0 0
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
altair4
Level 20
Level 20
Posts: 11427
Joined: Tue Feb 03, 2009 10:27 am

Re: Correct fstab entry to mount my NAS

Post by altair4 »

I just realized you asked this same question before and I gave you the same response. You even got the systemd option that member rene posted:
rene wrote: Tue Mar 20, 2018 7:09 am So as to avoid such issues it is advised to "automount" network file systems; this is to say that they mount only when in fact accessed (and can automatically unmount after laying idle for some specified time again). If you're on Mint 18 you can do this directly from /etc/fstab:

Code: Select all

//192.168.0.12/Public /home/mike/Nas cifs noauto,rw,guest,vers=1.0,iocharset=utf8,noperm,x-systemd.automount,x-systemd.device-timeout=10s,x-systemd.idle-timeout=10m
Also see man systemd.mount. If you do not in fact need the NAS mounted immediately when booting this'll work nicely.
Oh well ....
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
LegacyMJR

Re: Correct fstab entry to mount my NAS

Post by LegacyMJR »

Quote "
Re: Correct fstab entry to mount my NAS
Post by altair4 » Fri Apr 27, 2018 9:53 am

This issue is fstab is executed before the network stack it up in Mint. I'll give you some possible options:

[1] Change the way you mount it.

This depends on how you use your share. What I am suggesting is not mounting at boot but mounting it when you need it. If you change your fstab statement to this:
//192.168.0.12/Public /home/mike/Nas cifs rw,guest,vers=1.0,iocharset=utf8,_netdev,noperm,noauto,user 0 0
A mount icon will show up on the side panel of your file manager. Click on it and it will look to fstab to find out how to mount it. You can use the same icon to unmount it if desired.
"

Thanks tried your option 1 - this means when I double click on my Nas directory it mounts. For me this is a good solution.

So THANKS VERY MUCH!!
LegacyMJR

Re: Correct fstab entry to mount my NAS [SOLVED]

Post by LegacyMJR »

SORRY FORGOT TO POST SOLVED
User avatar
catweazel
Level 19
Level 19
Posts: 9763
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Correct fstab entry to mount my NAS

Post by catweazel »

AndyMH wrote: Fri Apr 27, 2018 6:36 am If you want to auto mount your NAS you will have to supply username and password
Nonsense.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
User avatar
catweazel
Level 19
Level 19
Posts: 9763
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Correct fstab entry to mount my NAS [SOLVED]

Post by catweazel »

LegacyMJR wrote: Fri Apr 27, 2018 7:44 am SORRY FORGOT TO POST SOLVED
To mark the thread solved, please edit the subject line of your first post in the thread.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
Locked

Return to “Storage”