drhoeh
Posts: 8
Joined: Fri Jun 26, 2015 4:36 am

constantly have to mount -a

Fri Jun 26, 2015 4:49 am

I have a pi2 running raspbian and I have mapped it to a wd mycloud NAS. I entered the following in /etc/fstab

//myIP/public /home/pi/mynas/myshare cifs guest,workgroup=WORKGROUP, users,auto,user_xattr 0 0

I save and exit.
Then I enter sudo mount -a. Everything works just fine and all of my drives are mounted, however when I reboot the system nothing. I have to enter sudo mount -a every time I reboot the system.

Why do I have to remount the NAS after every reboot?
Any help would be greatly appreciated.
Thanks,

sprinkmeier
Posts: 410
Joined: Mon Feb 04, 2013 10:48 am
Contact: Website

Re: constantly have to mount -a

Fri Jun 26, 2015 3:08 pm

at a guess the network isn't up when the boot-process does its "mount -a"

try adding a mount script as a hook script in /etc/network/if-up.d/
it should run automagically when the ethernet interface comes up.

drhoeh
Posts: 8
Joined: Fri Jun 26, 2015 4:36 am

Re: constantly have to mount -a

Fri Jun 26, 2015 4:55 pm

Thanks for the help but I am not entirely sure how to do that. Do I just put "mount -a" in "sudo nano /etc/network/if-up.d/" or is there more to it? You will have to forgive me I am still very new at all of this.
thanks,

Tom_A
Posts: 272
Joined: Fri Dec 06, 2013 8:34 am

Re: constantly have to mount -a

Fri Jun 26, 2015 7:23 pm

drhoeh wrote:Thanks for the help but I am not entirely sure how to do that. Do I just put "mount -a" in "sudo nano /etc/network/if-up.d/" or is there more to it? You will have to forgive me I am still very new at all of this.
thanks,
Add _netdev to /etc/fstab like so...
//myIP/public /home/pi/mynas/myshare cifs guest,workgroup=WORKGROUP, users,auto,_netdev,user_xattr 0 0

The reason the drive is not mounting is that the network is not up in time. The "_netdev" option will make the mount occur as soon as the network is available so it doesn't fail.

drhoeh
Posts: 8
Joined: Fri Jun 26, 2015 4:36 am

Re: constantly have to mount -a

Fri Jun 26, 2015 7:39 pm

Thanks for the suggestion but when I tried _netdev but it did not auto mount at boot up. I still have to go in and type "sudo mount -a" to get the NAS on the PI.

Tom_A
Posts: 272
Joined: Fri Dec 06, 2013 8:34 am

Re: constantly have to mount -a

Fri Jun 26, 2015 9:36 pm

drhoeh wrote:Thanks for the suggestion but when I tried _netdev but it did not auto mount at boot up. I still have to go in and type "sudo mount -a" to get the NAS on the PI.
I think there's also a problem with some of the current network updates. I seem to remember having the same issue after a recent update. I switched to NetworkManager and that fixed the problem as well as some others for me.

User avatar
default_user8
Posts: 678
Joined: Mon Nov 18, 2013 3:11 am

Re: constantly have to mount -a

Fri Jun 26, 2015 9:44 pm

Look here and see if any of these solutions solve your problem.
https://discourse.osmc.tv/t/osmc-alpha- ... -fstab/134
Two heads are better than one, unless one's a goat head.

sprinkmeier
Posts: 410
Joined: Mon Feb 04, 2013 10:48 am
Contact: Website

Re: constantly have to mount -a

Fri Jun 26, 2015 11:10 pm

drhoeh wrote:Thanks for the help but I am not entirely sure how to do that. Do I just put "mount -a" in "sudo nano /etc/network/if-up.d/" or is there more to it?
put the following in /etc/network/if-up.d/mount_all_hack:

Code: Select all

#!/bin/bash
/bin/mount --all &
the sudo chmod +x /etc/network/if-up.d/mount_all_hack

The script could be a lot smarter (i.e. make sure eth0 came up instead of lo etc...) but the above should do as a start.
Don't add any extensions to the filename (i.e. "hack.sh") or it will be assumed to be a backup file and ignored.

drhoeh
Posts: 8
Joined: Fri Jun 26, 2015 4:36 am

Re: constantly have to mount -a

Sat Jun 27, 2015 1:22 am

thanks, I am still learning this stuff but, if I understand you right I am going to write a script. I want to be certain before I get myself into trouble.

I am going to create a file called
1. sudo mkdir etc/network/if-up.d

2. create a shell script sudo nano "/etc/network/if-up.d/mount_all_hack"
and put in

"#!/bin/bash
/bin/mount --all &"


3. I am then going to execute the script with, "sudo chmod +x /etc/network/if-up.d/mount_all_hack"
4. Then sudo /etc/network/if-up.d/mount_all_hack

Did I get this right?

diederik
Posts: 393
Joined: Wed Mar 26, 2014 11:17 pm

Re: constantly have to mount -a

Sat Jun 27, 2015 3:20 pm

drhoeh wrote:3. I am then going to execute the script with, "sudo chmod +x /etc/network/if-up.d/mount_all_hack"
4. Then sudo /etc/network/if-up.d/mount_all_hack

Did I get this right?
Almost.
With "chmod +x <file>" you make it executable (but you're not actually executing/running it)
You don't have to do step 4 yourself. That script will be run automatically when the network becomes available.

rubikwizard
Posts: 95
Joined: Tue Jan 10, 2012 10:37 pm
Location: West Yorkshire
Contact: Website

Re: constantly have to mount -a

Sat Jun 27, 2015 8:52 pm

drhoeh wrote:I have a pi2 running raspbian and I have mapped it to a wd mycloud NAS. I entered the following in /etc/fstab

//myIP/public /home/pi/mynas/myshare cifs guest,workgroup=WORKGROUP, users,auto,user_xattr 0 0

I save and exit.
Then I enter sudo mount -a. Everything works just fine and all of my drives are mounted, however when I reboot the system nothing. I have to enter sudo mount -a every time I reboot the system.

Why do I have to remount the NAS after every reboot?
Any help would be greatly appreciated.
Thanks,
This is a known issue with the May 2015 release and another solution is given here.

Basically add "mount -a" to the end of the file /etc/rc.local (before the line "exit 0").

drhoeh
Posts: 8
Joined: Fri Jun 26, 2015 4:36 am

Re: constantly have to mount -a

Sat Jun 27, 2015 11:24 pm

WOW!!!

That did it, thanks for all the help.
The solution was to add "mount -a" to /etc/rc.local before exit 0.

You guys are great!
I appreciate all of the help.

sprinkmeier
Posts: 410
Joined: Mon Feb 04, 2013 10:48 am
Contact: Website

Re: constantly have to mount -a

Sat Jun 27, 2015 11:49 pm

drhoeh wrote:thanks, I am still learning this stuff but, if I understand you right I am going to write a script. I want to be certain before I get myself into trouble.

I am going to create a file called
1. sudo mkdir etc/network/if-up.d
(missing leading "/", but nevermind)
That directory should already exist, and probably have a few files in it. If it doesn't then your install might be borked.
If you ever do need to create a directory hierarchy (rather than just one level at a time) use "mkdir --parents"

Return to “Raspbian”