[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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



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.


Reply to: