Re: mount an external usb hdd and share it through samba

2020-05-06 Thread Andrei POPESCU
On Mi, 06 mai 20, 01:35:02, Michael Morgan wrote:
> 
> Since automount works, and samba will work well if I restart it, my guess is
> that on boot, samba (smbd service) starts before /usb-hdd is mounted. To
> make it working, 
> I need make sure the fstab mounting happens before samba starts. Can anyone
> tell me how to do it? Or, any better solution for auto mount and share a usb
> HDD?

According to systemd.mount(5) there are fstab options to force ordering 
before a specific unit.

It does seem strange that this is needed though. Could you please attach 
the smbd.service unit? Please also specify which Debian release you are 
using.

Kind regards,
Andrei
-- 
http://wiki.debian.org/FAQsFromDebianUser


signature.asc
Description: PGP signature


Re: mount an external usb hdd and share it through samba

2020-05-06 Thread Marco Möller

On 06.05.20 08:35, Michael Morgan wrote:

Dear all,

  


I have an external usb hdd. I would like to automount it on boot and share
it through samba.

  


1) So I put it in the fstab. It automounts correctly on boot, no problem:

UUID=XXX /usb-hdd ext4 defaults,nofail 0 0

  


2) I then share the directory "/usb-hdd" through samba (in smb.conf) after
it was mounted. No problem again:

[usb-hdd]

comment = raid5-usb

path = /usb-hdd

read only = No

valid users = michaelm

  


3) however, if the machine restarts, automounts works but the samba share
always fails. I can easily fix it by:

systemctl restart smbd

  


Since automount works, and samba will work well if I restart it, my guess is
that on boot, samba (smbd service) starts before /usb-hdd is mounted. To
make it working,
I need make sure the fstab mounting happens before samba starts. Can anyone
tell me how to do it? Or, any better solution for auto mount and share a usb
HDD?


This kind of dependencies can be added to the service unit file in 
section [Unit], in your case in the file "smbd.service"


[Unit]
RequiresMountsFor=/this/path/needs/to/be/present



Good luck,
Marco.



mount an external usb hdd and share it through samba

2020-05-06 Thread Michael Morgan
Dear all,

 

I have an external usb hdd. I would like to automount it on boot and share
it through samba.

 

1) So I put it in the fstab. It automounts correctly on boot, no problem:

UUID=XXX /usb-hdd ext4 defaults,nofail 0 0

 

2) I then share the directory "/usb-hdd" through samba (in smb.conf) after
it was mounted. No problem again:

[usb-hdd]

comment = raid5-usb

path = /usb-hdd

read only = No

valid users = michaelm

 

3) however, if the machine restarts, automounts works but the samba share
always fails. I can easily fix it by:

systemctl restart smbd 

 

Since automount works, and samba will work well if I restart it, my guess is
that on boot, samba (smbd service) starts before /usb-hdd is mounted. To
make it working, 
I need make sure the fstab mounting happens before samba starts. Can anyone
tell me how to do it? Or, any better solution for auto mount and share a usb
HDD?

 

Thank you very much.

Micahel Morgan