how can I force a mount -a to run after the system boots up?
One way to add your command at startup would be to add it as a cron
job.
Add your command to the root
cron
by typing in the following line in a terminal window:
sudo crontab -e
then at the bottom of the cron
add a line that reads like this:
@reboot /bin/mount -a
or if you want to add a delay of like 10 seconds to it:
@reboot /bin/bash -c 'sleep 10 && /bin/mount -a'
that should tell it to run the mount -a
command as root
at boot up time.
Or, you could add it to your system wide crontab by editing the following file:
/etc/crontab
and adding the following line:
@reboot root /bin/bash -c 'sleep 10 && /bin/mount -a'
Hope this helps!
Related videos on Youtube
jcollum
Updated on September 18, 2022Comments
-
jcollum over 1 year
Media server running Ubuntu 16.04 and Kodi. Synology NAS in the next room contains all the media.
how can I get my fstab mounts working if they won't mount on bootup? -- tried switching to username/password instead of .smbcredentials, no change.
Tried adding
_netdev
, no change.I've tried fixing my
/etc/fstab
and it's just not working. I'm not sure what the problem is, but I cannot get my NAS folders to mount that way. Posted here, posted on ubuntuforums, no go (didn't get any answers in either one). Every time I reboot I have tossh
in to the box to get my media folders back.So, I thought I'd take a different approach. I'm assuming there is some issue with my NAS or network that makes mounting at boot via
fstab
to not work. I don't know.Since I know that my folders will mount with
sudo mount -a
, how can I run that command at boot time after everything else (network especially) is done? -
jcollum almost 8 years_netdev - sorry, I forgot to mention that I tried that.
-
jcollum almost 8 yearsaskubuntu.com/questions/335615/… -- had to add "root" before /bin/bash. Still doesn't work though. They mount fine with sudo mount but
@reboot root /bin/bash -c 'sleep 10 && /sbin/mount -a'
doesn't do anything. Is it the /sbin that's the problem? I got an error with /bin -
jcollum almost 8 yearsOh wait it worked but using
sudo crontab -e
seems to open the wrong crontab. I didsudo vi crontab
and it worked -
Terrance almost 8 years@jcollum That is interesting, but glad you got it working. =)
-
Terrance almost 8 years@jcollum I am going to add that to my answer here.