You are helping the user set up SMB/CIFS (Windows/Samba) mounts to remote systems.
Walks you through mounting SMB/CIFS shares from Windows or Samba servers. Use this when you need to securely connect to remote file shares and make them persistent across reboots.
/plugin marketplace add danielrosehill/linux-desktop-plugin/plugin install lan-manager@danielrosehillYou are helping the user set up SMB/CIFS (Windows/Samba) mounts to remote systems.
Check SMB client prerequisites:
dpkg -l | grep cifs-utilssudo apt update
sudo apt install cifs-utils
Gather mount information from the user: Ask the user for:
192.168.1.100 or nas.local)shared or documents)WORKGROUP)/mnt/smb/remote-share)Test SMB server accessibility:
ping -c 3 <remote-ip>smbclient -L //<remote-ip> -U <username>
Set up credentials file (recommended for security): Create a credentials file to avoid storing passwords in /etc/fstab:
sudo mkdir -p /etc/samba/credentials
sudo touch /etc/samba/credentials/<share-name>
sudo chmod 700 /etc/samba/credentials
sudo chmod 600 /etc/samba/credentials/<share-name>
Edit the credentials file:
username=<username>
password=<password>
domain=<domain>
Secure it:
sudo chown root:root /etc/samba/credentials/<share-name>
sudo chmod 600 /etc/samba/credentials/<share-name>
Create local mount point:
sudo mkdir -p <local-mount-point>
Test mount temporarily: Before making it permanent, test the mount:
sudo mount -t cifs //<remote-ip>/<share-name> <local-mount-point> \
-o credentials=/etc/samba/credentials/<share-name>,uid=$(id -u),gid=$(id -g)
Verify the mount:
df -h | grep <local-mount-point>
ls -la <local-mount-point>
Configure mount options: Discuss common CIFS mount options with the user:
credentials=<file> - Use credentials fileuid=<uid> - Set file owner (use id -u)gid=<gid> - Set file group (use id -g)file_mode=0644 - File permissionsdir_mode=0755 - Directory permissionsvers=3.0 - SMB protocol version (2.0, 2.1, 3.0, 3.1.1)iocharset=utf8 - Character set_netdev - Required for network filesystemsnofail - Don't fail boot if mount unavailablenoauto - Don't mount automatically (use with autofs)rw / ro - Read-write or read-onlyRecommended default options:
credentials=/etc/samba/credentials/<share-name>,uid=<uid>,gid=<gid>,file_mode=0644,dir_mode=0755,vers=3.0,iocharset=utf8,_netdev,nofail
Detect SMB version: Help determine the best SMB version to use:
smbclient -L //<remote-ip> -U <username> --option='client max protocol=SMB3'
Common versions:
Make mount permanent via /etc/fstab:
Backup current fstab:
sudo cp /etc/fstab /etc/fstab.backup.$(date +%Y%m%d_%H%M%S)
Add entry to /etc/fstab:
//<remote-ip>/<share-name> <local-mount-point> cifs <options> 0 0
Test fstab entry without rebooting:
sudo umount <local-mount-point>
sudo mount -a
df -h | grep <local-mount-point>
Set up automount with systemd (alternative to fstab): If the user prefers automount, create systemd mount units:
Create /etc/systemd/system/mnt-smb-remote\x2dshare.mount:
[Unit]
Description=SMB Mount for remote-share
After=network-online.target
Wants=network-online.target
[Mount]
What=//<remote-ip>/<share-name>
Where=<local-mount-point>
Type=cifs
Options=<options>
[Install]
WantedBy=multi-user.target
Enable and start:
sudo systemctl daemon-reload
sudo systemctl enable mnt-smb-remote\\x2dshare.mount
sudo systemctl start mnt-smb-remote\\x2dshare.mount
sudo systemctl status mnt-smb-remote\\x2dshare.mount
Configure for Windows Active Directory (if applicable): If connecting to AD domain:
sudo apt install krb5-user
/etc/krb5.conf)sec=krb5 option if Kerberos is configuredTest and verify:
touch <local-mount-point>/test-file
ls -la <local-mount-point>/test-file
Troubleshooting guidance: If issues occur, check:
ping <remote-ip>smbclient -L //<remote-ip> -N (null session)vers= optionssmbclient //<remote-ip>/<share-name> -U <username>sudo journalctl -u <mount-unit> or dmesg | grep cifsuid, gid, file_mode, dir_modedmesg | tail -20Provide best practices:
/etc/samba/credentials/ with 600 permissions_netdev and nofail options to prevent boot issuesuid and gid for file access_netdev and nofail options to prevent boot issues