6

Hello i am trying to get my slave media center to mount a network drive at startup automatic. I have written this to my /etc/fstab/

\\192.168.1.2\root /media/data cifs username=doomstone,password=XXXX,auto,user 0 0
\\192.168.1.2\xbmc /media/xbmc cifs username=doomstone,password=XXXX,auto,user 0 0

Now when i do a "mount /media/data" it all works just fine, but it dose not mount it on statup. witch is a pain as the computer dose not have a keyboard, only a remote. So i need to ssh the computer and mount the drives each time i boot. As far as i can figure is that the computer dose not have a network connection at the mount time, and thus fails the mount of the network drives.

How can i do this so it can be mounted at startup?

1
  • I'm brining the problem up again as it did not work, it only worked for 2-3 reboots and then it manuel mount for me again!
    – Androme
    Oct 8, 2010 at 9:32

3 Answers 3

12

Try replacing auto with _netdev in the options in /etc/fstab - this should make the mount wait until the network is up.

4
  • 3
    The most underrated fstab option. There are not enough people who know about this, even though it is unspeakably useful. +1
    – wzzrd
    Aug 2, 2010 at 9:44
  • Cool i will try it when i get home from work
    – Androme
    Aug 2, 2010 at 11:04
  • Thank you. This is the only place on the internet documenting _netdev. :P
    – earthmeLon
    Feb 22, 2013 at 22:01
  • This does NOT work with Samba/CIFS filesystems as noted here: help.ubuntu.com/community/Fstab#Options
    – nxet
    Sep 14, 2020 at 17:13
0

Either write mount /media/{data,xbmc} to /etc/rc.local (hope it's called so in Ubuntu) or take a look at autofs.

Edit: didn't see this, you have to replace your backslashes with "/" in /etc/fstab.

2
  • I have tryed that, it diden't work
    – Androme
    Aug 2, 2010 at 9:15
  • 2
    Would have voted you up if you had refrained from mentioning putting stuff into /etc/rc.local. Don't do that, unless there is no other straight-forward way to do something. In this case, there is with either autofs or - and I would prefer this - using _netdev.
    – wzzrd
    Aug 2, 2010 at 9:42
0

I've spent way too much time myself to get this sorted so I'm posting what worked for me, to have Samba 4.9.5 shares automount on boot with Debian Buster 10.5. The /etc/fstab line I initially had was something like:

//server/music /mnt/music cifs ro,vers=3.0,guest,_netdev 0 0

With the line above (using _netdev) my /var/log/syslog reported failures in name resolution, so I tried to amend the configuration using the server's IP address. This did not work either, with the errors logged being rather useless:

Sep 14 18:52:05 hostname systemd[1]: mnt-music.mount: Mount process exited, code=exited, status=1/FAILURE
Sep 14 18:52:05 hostname systemd[1]: mnt-music.mount: Failed with result 'exit-code'

At this point it's important to note, more so because this is the most relevant search result and it's straight up false and misleading, that the _netdev option is useless with Samba/CIFS mounts, it only works with NFS as specified at point 12 here.

What finally did it was replacing _netdev with comment=systemd.automount, as suggested by another user here with the difference that I completely omitted _netdev, for a final result like:

//server/music /mnt/music cifs ro,vers=3.0,guest,comment=systemd.automount 0 0

This works like a charm, and in my specific scenario mounts 6 different file systems without a problem, making them available right at boot.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .