Prerequisites
- SMB share exists on remote server
- Network connectivity to server confirmed
- cifs-utils package installed
Step 1: Install Required Package
sudo apt update
sudo apt install cifs-utils -y
Step 2: Verify Network Connectivity
ping <server_ip>
Ensure the remote server is reachable before proceeding.
Step 3: Create the Local Mount Point
sudo mkdir -p /mnt/fileshare
The mount point must exist before mounting.
Step 4: Test Manual Mount (Temporary)
sudo mount -t cifs //<server_ip>/<share_name> /mnt/fileshare \
-o username=<username>,password=<password>,vers=3.0
If successful, verify:
lsblk
df -h
ls /mnt/fileshare
Unmount after testing:
sudo umount /mnt/fileshare
Step 5: Secure Credentials (Recommended)
sudo nano /root/.smbcredentials
Add:
username=<username>
password=<password>
Secure the file:
sudo chmod 600 /root/.smbcredentials
Step 6: Add Entry to /etc/fstab
sudo nano /etc/fstab
Add the following line (replace placeholders):
//<server_ip>/<share_name> /mnt/fileshare cifs credentials=/root/.smbcredentials,vers=3.0,_netdev 0 0
Explanation:
credentials=→ references secure credential filevers=3.0→ SMB protocol version (adjust if needed)_netdev→ ensures mount occurs after network is available0 0→ no dump, no fsck (network filesystems are not checked)
Step 7: Validate fstab Configuration
sudo mount -a
If no errors are returned, the configuration is valid.
Step 8: Reboot and Confirm Persistent Mount
sudo reboot
After reboot, verify:
df -h
ls /mnt/fileshare
Confirm the share is mounted automatically and accessible.