Here it is as a post written out.
Auto Mount a SAMBA resource via fstab
Mounting a remote LAN Samba server’s resource(s) at PC boot-time via /etc/fstab in Linux allows you to automatically connect to your shared network folders upon system boot. Here's a breakdown of how to do it, along with important considerations:
1. Before beginning, you must gather the following important information
On the SAMBA/’smb’ server
The smb username-password pair for remote users to be recognized must be registered
The resources to share must be defined
The following terminal command MUST work to show SAMBA active and capable of sharing its resources
smbclient -U% -L localhost
2. On your LAN PC, create a Mount Point that will be used to show the SAMBA resource:
Decide where you want to mount the Samba resource on your local file system. This will be your filesystem’s mount-point for the resource. Create a directory for it:
Example: sudo mkdir /mnt/samba-share
3. Create a Credentials File (Recommended) with your Server’s username it allows:
For security, it's best to store your Samba username and password in a separate credentials file rather than directly in /etc/fstab.
Create a file: sudo geany /etc/samba/credentials
Add the following lines, replacing with your actual credentials:
username=that_samba_expects
password=for the user above
After saving the credentials file,
Set security permissions for the credentials file:
sudo chmod 400 /etc/samba/credentials
sudo chown root:root /etc/samba/credentials
4. Edit /etc/fstab:
Open /etc/fstab with root privileges: sudo geany /etc/fstab
Add a line with the following format:
//<ip_address or hostname>/<share_name> /mnt/<mount_point> cifs credentials=/etc/samba/credentials,iocharset=utf8,vers=3.0,uid=<your_local_user_id>,gid=<your_local_group_id>,_netdev 0 0
Explanation of options:
//<server_ip_or_hostname>/<share_name>: The network path to your Samba share. Replace with the server's IP address or hostname and the share name.1
1.Mounting and mapping shares between Windows and Linux with Samba - Red Hat (www.redhat.com)
/mnt/<mount_point>: The local directory where you want to mount the share.
cifs: Specifies the file system type.
credentials=/etc/samba/credentials: Points to your credentials file.
iocharset=utf8: Handles character encoding.
vers=3.0: specifies the samba version. Adjust if needed.
uid=<your_local_user_id>: Sets the owner of the mounted files to your local user. To get your user id, type id -u in the terminal.
gid=<your_local_group_id>: Sets the group ownership. To get your group id, type id -g in the terminal.
_netdev: Ensures that the system waits for network connectivity before attempting to mount the share.
0 0: Dump and fsck options (usually set to 0).
5. Test the Mount:
After saving /etc/fstab, test the mount without rebooting:
sudo mount -a
If there are no errors, your Samba share should be mounted.
Important Notes:
Security: Storing credentials in a separate file with restricted permissions is crucial for security.
Network Connectivity: The _netdev option is essential, especially for systems that rely on Wi-Fi.
Permissions: Ensure that the user and group IDs you specify match your local user and group. Incorrect permissions can lead to access problems.
Samba Version: The vers=3.0 option tries to use version 3.0 of the samba protocol. If you are using an older samba server, you may need to adjust this value.
Troubleshooting: If you encounter errors, check the system logs (/var/log/syslog or journalctl) for detailed information.