Mount network share automatically on startup

13,571

I've been able to solve the problem on my system by adding x-systemd.automount, to the list of options in my fstab entry. I was seeing the same problem with Raspbian Jessie (from Wheezy) which led me to a forum post.

Share:
13,571

Related videos on Youtube

drohm
Author by

drohm

Updated on September 18, 2022

Comments

  • drohm
    drohm over 1 year

    I'm trying to have two network shares automatically mount upon rebooting my machine but I'm having no luck. I've read through several similar AskUbuntu questions but I can't seem to get it to mount the shares on rebooting. This is my current configuration:

    /etc/fstab:

    //192.168.1.18/FileDepot    /mnt/FileDepot  cifs    credentials=/home/user1/.credentials,uid=1000,gid=1000,user,sec=ntlm    0   0
    //192.168.1.18/Incoming     /mnt/Incoming   cifs    credentials=/home/user1/.credentials,uid=1000,gid=1000,user,sec=ntlm    0   0
    

    In my home folder, I have the .credentials file:

    username=user1
    password=mypass
    

    As I mentioned, this will not autmatically mount the shares on a reboot, but if I manually run:

    sudo mount -a
    

    it works.

    I'm running Xubuntu 15.10 x64. Any idea what I'm doing wrong or missing?

    ifconfig output:

    enp0s25   Link encap:Ethernet  HWaddr 54:ee:75:4d:ec:01  
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
              Interrupt:20 Memory:f1200000-f1220000 
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:443 errors:0 dropped:0 overruns:0 frame:0
              TX packets:443 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:40169 (40.1 KB)  TX bytes:40169 (40.1 KB)
    
    wlp4s0    Link encap:Ethernet  HWaddr 34:02:86:42:e4:06  
              inet addr:192.168.1.78  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::3602:86ff:fe42:e406/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:2128 errors:0 dropped:0 overruns:0 frame:0
              TX packets:1960 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:1324170 (1.3 MB)  TX bytes:723204 (723.2 KB)`
    

    cat /etc/network/interfaces:

    # interfaces(5) file used by ifup(8) and ifdown(8)
    auto lo
    iface lo inet loopback
    

    Here is some output from dmesg:

    [    5.077816] CIFS VFS: Error connecting to socket. Aborting operation.
    [    5.077818] CIFS VFS: Error connecting to socket. Aborting operation.
    [    5.078083] CIFS VFS: cifs_mount failed w/return code = -101
    [    5.078666] CIFS VFS: Error connecting to socket. Aborting operation.
    [    5.078836] CIFS VFS: cifs_mount failed w/return code = -101
    [    5.080887] CIFS VFS: Error connecting to socket. Aborting operation.
    [    5.081008] CIFS VFS: cifs_mount failed w/return code = -101
    

    I've tried using ethernet and no wifi, but that didn't help. I'm not sure where to go with this now.

    • Neil
      Neil over 8 years
      can you give me the out put of "ifconfig" and "cat /etc/network/interfaces"
    • drohm
      drohm over 8 years
      @Neil I updated the question with the information you requested.
    • Neil
      Neil over 8 years
      did you rename those interfaces to wlp4s0 and enp0s25
    • drohm
      drohm over 8 years
      I didn't edit them, no. This is a clean install I did a couple days ago when 15.10 was released.
    • Neil
      Neil over 8 years
      can you check if 70-persistent-net.rules file exists run "ls /etc/udev/rules.d/70-persistent-net.rules" if it exist can you post what is in the file.
    • Neil
      Neil over 8 years
  • drohm
    drohm over 8 years
    I tried this and unfortunately it didn't work.
  • drohm
    drohm over 8 years
    Thought that was it, but it didn't work on reboot. I can still do sudo mount -a and it will mount the shares without error. I just can't get it to mount on startup.
  • drohm
    drohm over 8 years
    No change after reboot. What does that command actually do?
  • Neil
    Neil over 8 years
    it Regenerates 70-persistent-net.rules file that file gives your interface name for your NIC's.
  • drohm
    drohm over 8 years
    I've tried that, but it still doesn't mount.
  • drohm
    drohm over 8 years
    I didn't explicitly ask for my home folder to be encrypted so I don't believe it is. I also tried specifying username and password in /etc/fstab to bypass having it look for the file and it still doesn't mount on reboot.
  • drohm
    drohm over 8 years
    Thanks Matt. I'd give you an up-vote, but I don't have the rep yet.
  • João Pimentel Ferreira
    João Pimentel Ferreira over 6 years
    Hi, could you give a more comprehensive answer? In which way and how shall you edit the file /etc/fstab? You just add a line with x-systemd.automount ?
  • Admin
    Admin almost 2 years
    Please be a little careful about using Copy and Paste answers across Ask Ubuntu particularly when you are giving a link to a particular application...
  • Admin
    Admin almost 2 years
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review