Here’s a concise guide to mounting network drives in Ubuntu, covering both SMB/CIFS (Windows) and NFS (Linux/Unix) protocols:
1. Mounting SMB/CIFS (Windows) Shares
Install Required Tools
First, install the cifs-utils package (needed for SMB/CIFS support):
sudo apt update && sudo apt install cifs-utils
Create a Mount Point
Choose a local directory to access the shared files (e.g., /mnt/windows_share):
sudo mkdir -p /mnt/windows_share
Temporary Mount (Restart Required)
Use the mount command with your Windows share details. Replace placeholders (, , , ) with actual values:
sudo mount -t cifs /// /mnt/windows_share \
-o username=,password=,uid=$UID
- Key Options:
uid=$UID: Grants your Ubuntu user access to the mounted files.vers=2.0: Use for older Windows systems (e.g., Win7); omit for newer versions (Win10/11).
Permanent Mount (Auto-Start)
For automatic mounting at boot, edit the /etc/fstab file:
sudo nano /etc/fstab
Add this line (replace values as above and create a credentials file for security):
/// /mnt/windows_share cifs credentials=/etc/samba/credentials,uid=1000,gid=1000,vers=2.0 0 0
- Credentials File: Store your username/password securely (600 permissions):
echo "username=" | sudo tee /etc/samba/credentials > /dev/null echo "password=" | sudo tee -a /etc/samba/credentials > /dev/null sudo chmod 600 /etc/samba/credentials
Apply changes:
sudo mount -a
Verify Mount
Check if the share is accessible:
df -h | grep windows_share
ls /mnt/windows_share
2. Mounting NFS Shares
Install Required Tools
Ensure the nfs-common package is installed (for NFS clients):
sudo apt update && sudo apt install nfs-common
Create a Mount Point
Select a local directory (e.g., /mnt/nfs_share):
sudo mkdir -p /mnt/nfs_share
Temporary Mount (Restart Required)
Use the mount command with your NFS server details. Replace and :
sudo mount -t nfs : /mnt/nfs_share
- Example: Mount
/exports/datafrom192.168.1.100to/mnt/nfs_share:sudo mount -t nfs 192.168.1.100:/exports/data /mnt/nfs_share
Permanent Mount (Auto-Start)
Edit /etc/fstab to add the NFS share:
sudo nano /etc/fstab
Add this line (replace values as above):
: /mnt/nfs_share nfs defaults 0 0
Apply changes:
sudo mount -a
Verify Mount
Check the mount status and access files:
df -h | grep nfs_share
ls /mnt/nfs_share
Troubleshooting Tips
- Permissions: Ensure the Windows share has read/write permissions for your user. For NFS, verify the server allows your Ubuntu IP.
- Firewall: Allow SMB (ports 445/tcp, 137-139/udp) or NFS (port 2049/tcp) traffic in your firewall.
- Network: Confirm the server is reachable (
ping). - Logs: Check system logs (
dmesg | tailor/var/log/syslog) for mount errors.