The Server Message Block (SMB) protocol is used for file sharing across a network. It’s useful when you have a server running on your network and you want to access resources from a client machine that are stored on the server in a SMB share.
How to Mount an SMB Share on Arch
- Install the
cifs-utilsandsambapackages. - Create a credential file in
/etc/samba/credentialsformatted like this:username=SERVER-USERNAME password=SERVER-PASSWORD domain=WORKGROUPThe default domain name is often
WORKGROUP, but your domain may be different. - Restrict the permissions on your credential file by running
sudo chmod 600 /etc/samba/credentials. - Mount the share:
sudo mount -t cifs \ //SERVER-IP/SHARE-NAME /mnt/mountpoint -o credentials=/etc/samba/credentials,uid=1000,gid=1000,iocharset=utf8 - For a permanent mount, open
/etc/fstaband add a record for the share://SERVER-IP/SHARE-NAME /mnt/mountpoint cifs credentials=/etc/samba/credentials,uid=1000,gid=1000,iocharset=utf8,noauto,user 0 0
Additional Helpful Tidbits
If you have Tailscale, you can easily take the SMB share with you wherever you have an internet connection by using the server’s tailnet IP in the fstab entry and mount command.
The uid=1000 and gid=1000 options are used to make the first non-root user the owner. If the account you want to set as the owner of the files doesn’t match up with this, get the right user ID by running id.
The noauto option in the fstab file means that the share will not automount at boot, which is probably a good choice in case the network isn’t ready at boot. So, with the fstab entry as configured above, mounting the share is as simple as running mount /mnt/mountpoint after you’ve established a connection to the network.
The user option in the fstab allows regular users to mount the share. Without it, mounting always requires root privileges.
The -t cifs part of the mount command is to specify the filesystem type for the share. In this case, that’s cifs, also known as Common Internet File System, which is just another expression for SMB.