Setup Samba share for external drive
An external drive on Ubuntu Server can be made accessible to other machines by mounting as a Samba share drive. In this case we add the drive as a TimeMachine accessible Samba share.
Summary
echo -e "[my_pwd]\n[my_pwd]\n" | sudo smbpasswd -a [my_user]- Add Samba usersudo vim /etc/samba/smb.conf- Edit Samba configuration to add Timemachine readable share for external drive.service smbd restart- Restart Samba service.fw allow samba- Open Samba ports in firewall.ufw --force enable- Restart firewall.
Procedure
Add Samba user
Add the user owning /media/[drive] as a samba user.
echo -e "[my_pwd]\n[my_pwd]\n" | smbpasswd -a [my_user]
Add share to Samba conf
DRV_SIZE=1.8T
DRV_NAME=seagate1-${DRV_SIZE//./_}
cat >> /etc/samba/smb.conf <<'EEOF'
[${DRV_NAME}]
comment = Backups (${DRV_NAME})
path = /media/${DRV_NAME}
valid users = [my_user]
read only = no
vfs objects = catia fruit streams_xattr
fruit:time machine = yes
EEOF
Confirm samba configuration with:
tail /etc/samba/smb.conf
Now restart Samba daemon
service smbd restart
Update firewall
Open ports for Samba in firewall.
ufw allow samba
ufw --force enable
References