0

I have Ubuntu 16.04 LTS server with configured public share on it.
My /etc/samba/smb.conf is below

[public_share]
    comment = Ubuntu Public Share
    path = /srv/samba/public_share
    guest ok = yes
    read only = no

For some reasons I need to mount this share on boot to /media/public_share. So I added it to the /etc/fstab:

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
//localhost/public_share /media/public_share/ cifs guest,noperm 0 2

But it does not get mounted on boot. It mounts only manually with sudo mount -a after login.

Adding it to /etc/rc.local such as

mount -t cifs //localhost/public_share /media/public_share/ -o guest,noperm

does not help too.

What am I doing wrong?
How I can auto-mount //localhost/public_share to /media/public_share/ during boot?
Do I need special systemd configuration or something special?

Update 1: For localhost server name I have the following log:

$ systemctl status media-public_share.mount 
● media-public_share.mount - /media/public_share
   Loaded: loaded (/etc/fstab; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Вт 2017-12-19 22:15:05 MSK; 16min ago
    Where: /media/public_share
     What: //localhost/public_share
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
  Process: 1461 ExecMount=/bin/mount //localhost/public_share /media/public_share -t cifs -o guest,noperm (code=exited, status=32)

дек 19 22:15:05 hostname systemd[1]: Mounting /media/public_share...
дек 19 22:15:05 hostname mount[1461]: Unable to find suitable address.
дек 19 22:15:05 hostname systemd[1]: media-public_share.mount: Mount process exited, code=exited status=32
дек 19 22:15:05 hostname systemd[1]: Failed to mount /media/public_share.
дек 19 22:15:05 hostname systemd[1]: media-public_share.mount: Unit entered failed state.

Changing address to 127.0.0.1, or setting 127.0.0.1 with options username=guest,password=,noperm do not remove "Unable to find suitable address" message.

I moved update 2 and update 3 to answer.

4
  • Thank you for your comment, @Rinzwind. See updates above. It does not work. Do you have other suggestions?
    – N0rbert
    Dec 19, 2017 at 19:43
  • 3rd attempt :D have you seen this page: wiki.ubuntu.com/MountWindowsSharesPermanently ? maybe one if those works :)
    – Rinzwind
    Dec 19, 2017 at 19:48
  • 3rd attempt does not help. I added and tested quick dirty hack with /etc/network/if-up.d. It just works.
    – N0rbert
    Dec 19, 2017 at 20:24
  • Adding x-systemd.automount,noauto to /etc/fstab helps without hacks.
    – N0rbert
    Dec 20, 2017 at 17:37

1 Answer 1

0

Problem may be solved with one of the following solutions:

  • Quick dirty hack with /etc/network/if-up.d:

    cat <<EOF | sudo tee /etc/network/if-up.d/zz-mount-all
    #!/bin/sh
    mount -a
    
    EOF
    
    sudo chmod a+x /etc/network/if-up.d/zz-mount-all
    

With this change it mounts normally:

$ systemctl status media-public_share.mount 
● media-public_share.mount - /media/public_share
   Loaded: loaded (/etc/fstab; bad; vendor preset: enabled)
   Active: active (mounted) (Result: exit-code) since Вт 2017-12-19 23:17:34 MSK; 7s ago
    Where: /media/public_share
     What: //127.0.0.1/public_share
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
  Process: 1481 ExecMount=/bin/mount //127.0.0.1/public_share /media/public_share -t cifs -o guest,noperm (code=exited, status=32)

It works even with localhost address.

  • It works as expected without hacks if I add x-systemd.automount,noauto to /etc/fstab as

     //localhost/public_share /media/public_share/ cifs guest,noperm,x-systemd.automount,noauto 0 255
    

and it creates two systemd units:

$ systemctl status media-public_share.*
● media-public_share.mount - /media/public_share
   Loaded: loaded (/etc/fstab; bad; vendor preset: enabled)
   Active: active (mounted) since Ср 2017-12-20 20:33:10 MSK; 3min 4s ago
    Where: /media/public_share
     What: //localhost/public_share
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
  Process: 2461 ExecMount=/bin/mount //localhost/public_share /media/public_share -t cifs -o guest,noperm,x-systemd.automount (code=exited, status=0/SUCCESS)

дек 20 20:33:10 hostname systemd[1]: Mounting /media/public_share...
дек 20 20:33:10 hostname systemd[1]: Mounted /media/public_share.

● media-public_share.automount
   Loaded: loaded (/etc/fstab; bad; vendor preset: enabled)
   Active: active (running) since Ср 2017-12-20 20:33:02 MSK; 3min 12s ago
    Where: /media/public_share
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)

дек 20 20:33:09 hostname systemd[1]: media-public_share.automount: Got automount request for /media/public_share, triggered by 2456 (pool)
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavail

But this solution adds two share icons to my Caja file-manager window.

So I'll use if-up.d hack.

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.