You are not logged in.

#1 2017-05-01 11:59:28

campo85
Member
Registered: 2012-09-05
Posts: 32

Systemd and SMB share

Hi all,

I've looked in the forum and I've seen there are several posts, i tried to apply their solution to my problem but with any luck. Basically I have a want to be able to mount a samba partition during the boot of my system. I've created a systemd unit and it worked for 6 months. Then I've updated my Arch and i messed up with the repository ( community/community-testing ). The result is at the boot, for some reason the same unit file to mount the samba partition doesn't work anymore:

255 campo@enterprise ~ % ssh nuc                                                                                                                                                          :(
Last login: Mon May  1 12:38:39 2017 from 192.168.0.6

~ ⌚ 12:45:36
$ sudo systemctl status mnt-synology.mount       
* mnt-synology.mount - Mount Synology Share at boot
   Loaded: loaded (/etc/systemd/system/mnt-synology.mount; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2017-05-01 12:45:04 BST; 42s ago
    Where: /mnt/synology
     What: //synology-campo/Video
  Process: 580 ExecMount=/usr/bin/mount //synology-campo/Video /mnt/synology -t cifs -o credentials=/etc/samba/creds/synology,iocharset=utf8,rw,cache=loose (code=exited, status=32)

May 01 12:45:04 NUC systemd[1]: Mounting Mount Synology Share at boot...
May 01 12:45:04 NUC systemd[1]: mnt-synology.mount: Mount process exited, code=exited status=32
May 01 12:45:04 NUC systemd[1]: Failed to mount Mount Synology Share at boot.
May 01 12:45:04 NUC systemd[1]: mnt-synology.mount: Unit entered failed state.

~ ⌚ 12:45:47
$ sudo systemctl restart mnt-synology.mount

~ ⌚ 12:47:03
$ sudo systemctl status mnt-synology.mount 
* mnt-synology.mount - Mount Synology Share at boot
   Loaded: loaded (/etc/systemd/system/mnt-synology.mount; enabled; vendor preset: disabled)
   Active: active (mounted) since Mon 2017-05-01 12:47:03 BST; 2s ago
    Where: /mnt/synology
     What: //synology-campo/Video
  Process: 827 ExecMount=/usr/bin/mount //synology-campo/Video /mnt/synology -t cifs -o credentials=/etc/samba/creds/synology,iocharset=utf8,rw,cache=loose (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/mnt-synology.mount

May 01 12:47:02 NUC systemd[1]: Mounting Mount Synology Share at boot...
May 01 12:47:03 NUC systemd[1]: Mounted Mount Synology Share at boot.

As you can see the unit doesn't work during the boot but it works perfectly if I run it once logged in. My guess is there are some dependencies problems. I tried to debug it but with no luck. The Unit is:

  1 [Unit]
  2 Description=Mount Synology Share at boot
  3 Requires=systemd-networkd.service unbound.service
  4 After=network-online.target unbound.service
  5 Wants=network-online.target unbound.service
  6 
  7 [Mount]
  8 What=//synology-campo/Video
  9 Where=/mnt/synology
 10 Options=credentials=/etc/samba/creds/synology,iocharset=utf8,rw,cache=loose
 11 Type=cifs
 12 TimeoutSec=60
 13 
 14 [Service]
 15 Restart=always
 16 StartLimitIntervalSec=10
 17 StartLimitBurst=10
 18 
 19 [Install]
 20 WantedBy=multi-user.target

I tried to use the restart function in systemd as workaround for any dependency problem, but it still doesn't work. Any clue from anyone ?

Cheers.

Offline

#2 2017-11-23 10:07:50

rbgo
Member
From: Den Haag, Netherlands
Registered: 2017-11-23
Posts: 1

Re: Systemd and SMB share

I had a problem with starting smbd on boot.
Did the commands to get smbd going:

systemctl enable smbd
systemctl start smbd

But on boot 9 times out of 10, smbd wouldn't start.
Typing in a terminal:

systemctl start smbd

would start smbd without failure, making me think that there is a timing problem
where dependencies are not completely loaded yet.

Search of timing options for systemd, I finally found what I needed.
I added the following line to the file /usr/lib/systemd/system/smbd.service
in the [Service] section like:

[Service]
ExecStartPre=/bin/sleep 2

Up until now, no problems with smbd on boot.
The ExecStartPre executes in sync before ExecStart
and so will delay smbd startup to give its dependencies
a little more time to get completely up.

Maybe this idea can help to solve your problem.


Get what most want?
Do what most won't!

Offline

#3 2017-11-23 14:08:59

seth
Member
Registered: 2012-09-03
Posts: 50,000

Online

#4 2017-11-23 22:26:18

Buddlespit
Member
From: Chesapeake, Va.
Registered: 2014-02-07
Posts: 501

Re: Systemd and SMB share

[Unit]
Description=Mount Share (smb) at boot
Requires=NetworkManager-wait-online.service  <=== This
After=network-online.target
Wants=network-online.target

[Mount]
What=//Server/Shares
Where=/mnt/Shares
Options=guest,uid=1000,x-systemd.automount,iocharset=utf8,file_mode=0777,dir_mode=0777
Type=cifs
TimeoutSec=30

[Install]
WantedBy=multi-user.target

edit: Sorry Seth, I didn't read your link first...

Last edited by Buddlespit (2017-11-23 22:27:56)

Offline

#5 2017-11-27 19:34:17

AveryFreeman
Member
Registered: 2017-11-25
Posts: 27

Re: Systemd and SMB share

Why not just put it in fstab?  Am I missing something?

Offline

Board footer

Powered by FluxBB