shell
Mount a Samba Network Share
Automatic mounting of an SMB network share is well-supported.
-
Make sure to have
cifsinstalled:apt install cifs-utils.Otherwise, you might see error code -13.
-
Open up your
/etc/fstaband configure the mount point://theip/sharedfolder /media/sharedfolder cifs credentials=/root/cifs-credentials,uid=1000,gid=1000,rw 0 0Dissecting this further:
//theip/sharedfolder: Local Network IP of the computer sharing something./media/sharedfolder: Where you want the folder mounted on your machine. We’ll create this shortly.cifs: the filesystem type.credentials=/root/cifs-credentials,: I assume the shared folder is password protected. We’ll store it in a separate file instead of the world readablefstab. Security! We get to this in a minute.uid=1000,: Specify the owner your local folder belongs to.gid=1000,: Specify the group owning your local folder.rw: read-write0: don’t ever dump this filesystem. Doesn’t make sense with a network share.0: don’t runfsckon this. Doesn’t make sense with a network share.
-
Persist the credentials. Create the
/root/cifs-credentialsfile and fill it up:username=shareuser password=sharepassw0rd -
Set permissions so that only root can read the file:
chmod 600 /root/cifs-credentials -
Ensure the local folder exists:
mkdir -p /media/sharedfolder
That’s that. Run mount -a to test. Once that worked, do a reboot and verify it actually works.