This comes directly from the archwiki, due to I got tired of mount the nas shares using dolphin (or similar) and have to go to the /run/media....
path everytime, or by manually running:
|
|
Instead, I will just manually run:
|
|
Or enable it to mount it automatically during boot and to unmount I just have to stop the service.
Systemd unit configuration
First create a credential file, in the client, it should only contain the username and password that will be used to mount that specific samba share in /etc/samba/credentials/nas
:
|
|
Give the permissions to the root user, as the credential file should explicitly readable/writeable to root:
|
|
As you can see, you can have multiple credential file for multiple samba shares.
Now create the systemd unit under /etc/systemd/system/mnt-nas.mount
. Here you can name the unit as you like.
Please note the following, that can be edited to fit your needs:
What=//sever/nas
, is the path of the remote server sharing the samba (e.g.//192.168.1.12/nas
).Where=/mnt/nas
, this is where the samba share will be mounted in the client side (e.g./home/your_username/nas
).credentials=/etc/samba/credentials/nas
, the credential file in the client side.uid=username
, specify you username in order to have read-write permissions. Otherwise, only root will be able to read-write. You can also specify a group instead of a user (e.g.gid=group
)
Very important, the systemd unit name mnt-nas.mount
MUST match the mountpoint name Where=/mnt/nas
. See, in both cases it is nas
.
|
|
And that is it. I have nothing more to add this time.
If you found this content useful, please support me:
BTC: 1E2YjL6ysiPxRF4AEdXChpzpesRuyzgE1y