2

I'm on Debian 8.1 and trying to mount a network drive (WD MyCloud) on startup. At first I added the following to /etc/fstab:

192.168.1.101/the_red_drive /media/the_red_drive cifs uid=fossi,credentials=/home/fossi/.smbcredentials

While this worked initially, it ended up causing interrupting the boot process and opening an emergency session. From some research I did, it seems to be caused by the command being run prior to the network being set up properly.

I then followed this guide adding the following to /etc/init.d/fossi_startup:

#!/bin/bash
### BEGIN INIT INFO
# Provides:          fossi_startup
# Required-Start:    $remote_fs $syslog $network
# Required-Stop:     $remote_fs $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO
mount -t cifs -o uid=fossi,credentials=/home/fossi/.smbcredentials \
       //192.168.1.101/the_red_drive /media/the_red_drive

I then ran the following commands as per guide:

sudo chmod +x /etc/init.d/fossi_startup.sh
sudo update-rc.d fossi_startup.sh defaults 100

However this doesn't seem to execute or at least doesn't execute successfully. How can I run the mount on startup without interfering with the boot process?

  • 2
    If you are using systemd, you would use a service file, not something in etc/init.d. See fstab entry for Samba share or mounting NFS share at startup... – jasonwryan Aug 8 '15 at 1:55
  • @jasonwryan thanks for the links. I'll try removing the uid part from the fstab line giving the warning in your first link. If this doesn't work I'll try the systemd approach. Sorry I'm quite new to linux and not totally clear about the difference between systemd and init.d. Is the latter completely unused now in Debian 8? – pandita Aug 8 '15 at 2:08
  • There isn't a Systemd Approach Debian 8.1 is Systemd, meaning that it's the only option... – eyoung100 Aug 8 '15 at 2:20
4

You can do this with fstab, as long as you mark the mount as a network one. Just add _netdev to the options field.

  • Sorry for the late reply. In the meantime I had other difficulties with my network drive unrelated to the question. I'll try your option once I solved the current issue. Cheers! – pandita Aug 11 '15 at 12:03
  • Excellent, this works like a charm...Thanks for that! – pandita Aug 16 '15 at 7:19

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.