[root tip] [How To] Step By Step - File Share Using Samba

Basic Samba Setup

  • This guide is without the usual explanations.
  • It is intended for those who just want to get it done.
  • Further information and in-depth guides is linked below.

It is assumed the system is up-to-date with the package samba synced

The following values are used

Item Value Description
User Group smbusers the usergroup allowing write access to the share
Device path /dev/sdy1 example device partition path
Partition Label MySharedData name of the partition with the shared files
Mount Point /a/MyShare the local mount point providing access to the files
Share Name MyShare name of share exposed by samba
Workgroup MYHOME samba workgroup name
  1. Create a group called smbusers

    sudo groupadd smbusers
    
  2. Add your username to the group
    (you must log off for the group to take effect - even for testing)

    sudo gpasswd -a $USER smbusers
    
  3. Ensure your user is in the samba password database

    sudo smbpasswd -a $USER
    
  4. Create the mountpoint /a/MyShare and assign group permissions

    sudo mkdir -p /a/MyShare
    sudo chmod g+w /a/MyShare
    sudo chgrp smbusers /a/MyShare
    
  5. Enable mounting by Partition Label

    sudo e2label /dev/sdy1 MySharedData
    
  6. Create a mount unit for your data disk/partition

    sudo touch /etc/systemd/system/ a-MyShare.mount
    

    Open the file and edit the content of the mount unit

    [Unit]
    Description=Mount MySharedData partition
    
    [Mount]
    What=/dev/disk/by-partlabel/MySharedData
    Where=/a/MyShare
    Type=auto
    Options=rw,noatime
    
    [Install]
    WantedBy=multi-user.target
    
  7. Enable and Start the unit

    sudo systemctl enable --now a-MyShare.mount
    
  8. Edit the file /etc/samba/smb.conf to contain

    [global]
    	server role = standalone server
    	max log size = 50
    	map to guest = Bad Password
    	guest account = nobody
    	unix password sync = yes
    	passwd program = /usr/bin/passwd %u
    	passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password* %n\n *passwd:*all*authentication*tokens*updated*successfully*
    	obey pam restrictions = yes
    	pam password change = yes
    	server string = My Samba File Service
    	workgroup = MYHOME
    	log file = /var/log/samba/%m.log
    
    [MyShare]
    	path = /a/MyShare
    	guest ok = no
    	browseable = yes
    	comment = Share for laptop exchange
    	read only = no
    	inherit permissions = no
    
  9. Enable and start samba and nmb services

    sudo systemctl enable --now smb nmb
    
  10. Ensure the service is discoverable

    sudo systemctl enable --now avahi-daemon
    

Mount unit documentation

Other samba guides

8 Likes

If you have questions - please create a new topic and link to the guide

https://forum.manjaro.org/t/180315
2 Likes