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?

Androme
  • 411
  • 2
  • 5
  • 12
  • 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 08 '10 at 09:32

3 Answers3

12

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

James
  • 7,553
  • 2
  • 24
  • 33
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.

nxet
  • 101
  • 1
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.

weeheavy
  • 4,039
  • 1
  • 27
  • 41
  • I have tryed that, it diden't work – Androme Aug 02 '10 at 09: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 02 '10 at 09:42