Start autofs on boot

I have autofs all setup, and it correctly mounts my shared directories.

However, right now, I have to manually run sudo upstart autofs start after every boot, before the automounting actually works.

I think in installed autofs manually through synaptic, though it has been a while. The computer in question is used as a lightweight server, and rarely gets restarted, so having to manually start a service isn’t too big a deal, but my backups do not work until autofs is running, so I do worry.

Answer

Add this to /etc/rc.local

Using any editor:

Graphical

gksu gedit /etc/rc.local

Command line

sudo -e /etc/rc.local 

add / edit the following:

#!/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.

service autofs start &

mount -a

exit 0

You could probably improve on that a bit, 4 60 second sleep are probably excessive, I would try one, and increase the number if needed.

Make it executable

sudo chmod u+x /etc/rc.local

Reboot and it should work. If not, try adding a sleep as per the bug report below.

See also Bug Report

Attribution
Source : Link , Question Author : Fake Name , Answer Author : Panther

Leave a Comment