3

I've got raspbian installed and need to mount a cifs path after boot is completed. In fstab I got an entry for this with the noauto parameter. When using auto, boot hangs.

So in raspbian, the file is located in /etc/rc.local

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

#mount media storage via cifs
if grep -qs '/media/Seagate' /proc/mounts; then
    echo "Seagate already mounted."
else
    echo "Mounting Seagate.."
    sudo -n mount /media/Seagate
fi

exit 0

According to the man page the -n parameter will suppress a password prompt for the sudo command. This is not the case, however. So I tried editing the sudoers file.

# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults    env_reset
Defaults    mail_badpass
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) NOPASSWD: ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
pi ALL=(ALL) NOPASSWD: ALL

Only the %sudo line is changed. I assume root to be in group sudo and since the %sudo line is after the root line, no password should be required. Note that root does not have a password anyways on raspbian, I can fill anything at the password prompt.

Any suggestions? Other approaches like crontab may also be suitable

EDIT 1 Further info: there is

#!/bin/sh -e

on top of the file; the '-e' parameter apparently makes it not halt on errors. The permissions are

drwxr-xr-x 2 root root 4096 Feb 23 12:09
  • Further info: there is #!/bin/sh -e on top, which apparently makes it not halt on errors. Also the permissions are different from the other rc scripts: drwxr-xr-x 2 root root 4096 Feb 23 12:09 rc6.d -rwxr-xr-x 1 root root 620 Feb 24 08:20 rc.local – Nino van Hooff Feb 24 '14 at 7:34
  • Add information to your original post instead of using comments, you have better editing facilities, some users indicate new edit with text "Edit 1" . You are comparing a directory and a file! You appear to have a new problem, tick this as answered (If you agree) and ask a new question. – X Tian Feb 24 '14 at 12:31
  • Thanks for the tips, X Tian. My problem is unsolved however – Nino van Hooff Feb 24 '14 at 12:44
  • The title of this post is "disable password prompt ...", I've answered this already. Now you say it doesn't work, what doesn't work ? What is your Question ? – X Tian Feb 24 '14 at 13:48
1

Your rc.local is run as root so you do not need to use the sudo command.

add a whoami line just to see for yourself.

  • I would say you are right, but removing sudo -n has no effect. Is it because of the changes I made in sudoers maybe? – Nino van Hooff Feb 24 '14 at 7:18
  • whoami does indeed show root – Nino van Hooff Feb 24 '14 at 7:25
  • What do you mean "has no effect" ? If you have removed sudo then it cant be asking for you for a password. What is your new problem ? You don't need to fiddle with sudoers to run your programs as root. If you have fiddled with sudoers then undo you changes, if you can't remember how, then this is a new question. "I've change sudoers and now ... " Explain what doesn't work though. on my system the sudo group is empty! grep sudo /etc/group – X Tian Feb 24 '14 at 13:03
  • Has no effect as in: I am still asked for a password. A colleague at work suggested that it is not the root account which asks for a password, but the cifs/samba share. I will experiment later today and share results. – Nino van Hooff Feb 24 '14 at 13:52
1

Root permissions were not the problem, cifs authentication was.

Because I only saw 'Password:' On my screen, I could not tell what was asking for permission, and I assumed it was su. In fact, I specified a user but not a password in fstab, thus it prompted for one. X Tian: thank you for your patience.

Wrong

//192.168.2.1/volume1 /media/Seagate cifs noauto,sec=ntlm,uid=1000,gid=1000,user,_netdev 0 0

Correct

//192.168.2.1/volume1 /media/Seagate cifs noauto,sec=ntlm,uid=1000,gid=1000,guest,_netdev 0 0

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.