2

Here is my current /etc/rc.local:

#!/bin/sh -e

# Test 1
echo line1 > /home/myHome/rclog.txt

# the mount
mount /mnt/mediaDrive &> /home/myHome/mountlog.txt

# Test 2
echo line2 >> /home/myHome/rclog.txt

exit 0

The /mnt/mediaDrive is a noauto in fstab. It is a network share, hence the mount in rc.local.

The mount in the above script does not work at boot. After boot, the rclog.txt file contains both line1 and line2, and the mountlog.txt file is empty. This would indicate that all commands in the script were run successfully, however, the drive is not mounted.

Running sudo /etc/rc.local manually in a terminal does mount the network share.

There is nothing relevant in /var/syslog that I can see, and permissions for rc.local are 755. The relevant fstab entry:

//192.168.1.100/home  /mnt/mediaDrive  cifs  noauto,credentials=/home/myHome/.mediaCredentials,uid=myName,gid=myGroup  0  0

What's going on here?

0
3

The problem must be that at boot time your network isn't available yet, and it's the reason why it mounts after boot. You must use another mechanisms to mount the device, like upstart. Example using upstart:

# mount CIFS share

start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]

pre-start script /bin/mount /mnt/mediaDrive
pre-stop script /bin/umount /mnt/mediaDrive

You can modify it to suit your needs. The file name must end with .conf and saved in the /etc/init directory.

5
  • I'll sure give this a try! But I do think it's strange the network is not up at the time rc.local is run... – Rody Oldenhuis Nov 26 '13 at 11:37
  • @RodyOldenhuis you can ping yourself and see ;), change mount by ping -c2 192.168.1.100 and try. – Braiam Nov 26 '13 at 11:39
  • I'll try that too. By the way, would it be an idea to use a simple _netdev option in fstab? My intention is to have several bind mounts to locations on the network drive, so can you use _netdev on a bind mount? Never tried that... – Rody Oldenhuis Nov 26 '13 at 11:45
  • @RodyOldenhuis apparently _netdev is ignored in ubuntu and seems that there are problems in fedora too. – Braiam Nov 26 '13 at 11:54
  • Yes, that's what I read too, which is what pushed me to the approach I was taking. Nevertheless, the option appears to be working on 13.10 again; see my answer. – Rody Oldenhuis Nov 26 '13 at 11:56
1

As noted by Braiam, at the time rc.local is run there is no network available for some reason.

This was the original reason I moved to the noauto + rc.local approach. So, although I'm not quite sure why, this approach is faulty.

In my case, a simple _netdev (instead of noauto) in /etc/fstab did the trick.

Note that in my case, I had several dozen bind mounts to locations on the network drive. Each of these bind mounts also need a _netdev option in /etc/fstab, next to the bind option.

1

Just add a "sleep 5" above your network command in the rc.local

I had the problem to mount cifs access on my raspberry with osmc, with this 5s the network is up and the mount is OK

1
  • +1, but seems rather more like a workaround than a solution...i.e., it adds an unnecessary 5s to the boot time. And who is to say 5s is enough? – Rody Oldenhuis Sep 22 '16 at 5:43
0

Adding noauto,x-systemd.automount to my fstab line is what finally worked for me. I also have a mount /media/share line in my rc.local, but I'm not sure if that's important or redundant.

_netdev in /etc/fstab did not work for me (with or without a mount command in rc.local)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.