Connecting to network storage in Linux involves mounting the remote drive using protocols like SMB or NFS. If you are wondering how to mount a network drive in linux, this guide walks you through the entire process step by step. Whether you are a beginner or a seasoned sysadmin, these instructions will help you access shared folders from Windows, NAS devices, or other Linux servers.
Network drives are convenient for sharing files across devices. In Linux, mounting a network drive means attaching a remote filesystem to your local directory tree. Once mounted, you can read, write, and manage files just like they were on your own hard drive.
This article covers both temporary and permanent mounts. You will learn about SMB/CIFS for Windows shares and NFS for Unix-like systems. We also include troubleshooting tips and security best practices.
Prerequisites For Mounting A Network Drive In Linux
Before you start, make sure your system is ready. You need a working Linux installation with internet access. Also, know the IP address or hostname of the network drive.
- A Linux distribution (Ubuntu, Debian, Fedora, CentOS, etc.)
- Root or sudo privileges
- Network connectivity to the remote share
- The correct protocol (SMB or NFS) supported by the remote server
Install the required packages. For SMB shares, you need cifs-utils. For NFS, install nfs-common or nfs-utils depending on your distro.
sudo apt update
sudo apt install cifs-utils nfs-common # Debian/Ubuntu
sudo yum install cifs-utils nfs-utils # RHEL/CentOS/Fedora
Check that the packages installed correctly. You can verify with which mount.cifs or which mount.nfs.
How To Mount A Network Drive In Linux
Now let’s get into the actual mounting process. We cover two common protocols: SMB/CIFS and NFS. Follow the section that matches your network share type.
Mounting An SMB/CIFS Network Drive
SMB (Server Message Block) is the protocol used by Windows file sharing. Many NAS devices also support SMB. To mount an SMB share, you need the server address, share name, and credentials.
First, create a mount point. This is a local directory where the remote filesystem will appear.
sudo mkdir -p /mnt/network_share
Now mount the share using the mount command with the cifs type. Replace the placeholders with your actual details.
sudo mount -t cifs //192.168.1.100/shared_folder /mnt/network_share -o username=your_username,password=your_password
If you prefer not to put the password in the command, use the credentials option. Create a credentials file with restricted permissions.
sudo nano /etc/smbcredentials
# Add these lines:
username=your_username
password=your_password
domain=your_domain # optional
sudo chmod 600 /etc/smbcredentials
Then mount using the file:
sudo mount -t cifs //192.168.1.100/shared_folder /mnt/network_share -o credentials=/etc/smbcredentials
You can add additional options like uid and gid to set ownership, or file_mode and dir_mode for permissions. For example:
sudo mount -t cifs //192.168.1.100/shared_folder /mnt/network_share -o credentials=/etc/smbcredentials,uid=1000,gid=1000,file_mode=0644,dir_mode=0755
To verify the mount, run df -h or mount | grep cifs. You should see the remote share listed.
Mounting An NFS Network Drive
NFS (Network File System) is common in Unix and Linux environments. It is simpler than SMB because it often does not require authentication. However, security can be handled at the server level.
First, create a mount point:
sudo mkdir -p /mnt/nfs_share
Now mount the NFS export. The server exports a directory path, not a share name.
sudo mount -t nfs 192.168.1.200:/exported/path /mnt/nfs_share
You can specify NFS version with the vers option. For example, NFSv4:
sudo mount -t nfs -o vers=4 192.168.1.200:/exported/path /mnt/nfs_share
Other useful options include rw (read-write), sync (synchronous writes), and noatime (disable access time updates).
Check the mount with df -h or mount | grep nfs.
Making The Mount Permanent
Temporary mounts disappear after a reboot. To make the network drive mount automatically at boot, edit the /etc/fstab file.
Open the file with sudo:
sudo nano /etc/fstab
Add a line for your SMB share:
//192.168.1.100/shared_folder /mnt/network_share cifs credentials=/etc/smbcredentials,uid=1000,gid=1000,file_mode=0644,dir_mode=0755 0 0
For an NFS share:
192.168.1.200:/exported/path /mnt/nfs_share nfs rw,sync,hard,intr 0 0
Test the fstab entry without rebooting:
sudo mount -a
If there are no errors, the mount succeeded. If you get an error, check the syntax and options.
Troubleshooting Common Issues
Even with careful setup, you might run into problems. Here are frequent issues and solutions.
Permission Denied
This often happens with SMB shares. Check that your username and password are correct. Also, ensure the remote server allows your IP address.
For NFS, verify the export list on the server with showmount -e server_ip. Your client must be in the allowed hosts.
Mount Error: Mount Point Does Not Exist
You forgot to create the mount directory. Use sudo mkdir -p /path/to/mount.
Protocol Not Supported
Your kernel might not have the required module. For SMB, load the cifs module:
sudo modprobe cifs
For NFS, load nfs and nfsd:
sudo modprobe nfs
sudo modprobe nfsd
Fstab Entry Fails At Boot
Network drives might not be available when fstab is processed. Add the _netdev option to delay mounting until the network is up.
//192.168.1.100/shared_folder /mnt/network_share cifs credentials=/etc/smbcredentials,_netdev 0 0
For NFS, the _netdev option is also recommended.
Slow Performance
Check your network connection. Use ping to test latency. For SMB, try adding vers=3.0 or vers=2.0 to the mount options. For NFS, use rsize and wsize to adjust transfer sizes.
sudo mount -t nfs -o rsize=32768,wsize=32768 192.168.1.200:/exported/path /mnt/nfs_share
Security Considerations
Mounting network drives exposes your system to potential risks. Follow these best practices.
- Use strong passwords for SMB shares
- Store credentials in a file with 600 permissions
- Use NFSv4 with Kerberos for authentication if possible
- Restrict access with firewall rules
- Mount shares as read-only when you only need to read files
- Regularly update your system and packages
Also, consider using SSHFS for encrypted transfers over SSH. It is slower but more secure for sensitive data.
Automating Mounts With Systemd
Instead of fstab, you can use systemd mount units. This gives you more control and logging.
Create a mount unit file for your SMB share:
sudo nano /etc/systemd/system/mnt-network_share.mount
Add the following content:
[Unit]
Description=Mount SMB Network Share
After=network-online.target
Wants=network-online.target
[Mount]
What=//192.168.1.100/shared_folder
Where=/mnt/network_share
Type=cifs
Options=credentials=/etc/smbcredentials,uid=1000,gid=1000,file_mode=0644,dir_mode=0755
[Install]
WantedBy=multi-user.target
Enable and start the unit:
sudo systemctl enable mnt-network_share.mount
sudo systemctl start mnt-network_share.mount
Check status with systemctl status mnt-network_share.mount.
Using Graphical Tools
If you prefer a GUI, most Linux desktop environments have built-in tools. In GNOME, open Files and click “Connect to Server”. Enter smb://192.168.1.100/shared_folder for SMB or nfs://192.168.1.200/exported/path for NFS.
KDE’s Dolphin file manager has a similar feature. These tools handle mounting automatically but may not persist across reboots.
For a more permanent solution, use the command-line methods described above.
Unmounting A Network Drive
To safely remove a mounted network drive, use the umount command. Note the spelling: no ‘n’ after the ‘u’.
sudo umount /mnt/network_share
If the device is busy, close any open files or terminal sessions in that directory. You can force unmount with sudo umount -l /mnt/network_share, but this may cause data loss.
Advanced Mount Options
Here are some advanced options for specific scenarios.
Mounting With Guest Access
Some SMB shares allow guest access. Use guest option:
sudo mount -t cifs //192.168.1.100/public /mnt/public -o guest
Mounting With Different UID/GID
If your local user ID differs from the remote server’s, map the user with uid and gid.
sudo mount -t cifs //192.168.1.100/share /mnt/share -o credentials=/etc/smbcredentials,uid=1001,gid=1001
Mounting Over SSH With SSHFS
SSHFS is a FUSE-based filesystem that mounts remote directories over SSH. Install sshfs:
sudo apt install sshfs
Mount with:
sshfs user@remote_host:/remote/path /mnt/ssh_mount
Unmount with fusermount -u /mnt/ssh_mount.
Frequently Asked Questions
How do I mount a network drive in Linux permanently?
Edit /etc/fstab with the appropriate entry for your share type. Use the _netdev option to ensure the network is available before mounting.
Can I mount a Windows share in Linux?
Yes, use the cifs filesystem type with mount -t cifs. Install cifs-utils first.
What is the difference between SMB and NFS?
SMB is used by Windows systems and supports authentication. NFS is native to Unix/Linux and is often simpler but less secure without additional setup.
Why does my mount fail with “mount error(13): Permission denied”?
This usually means incorrect credentials or the server denies access. Check your username/password and ensure the share allows your IP.
How can I see all mounted network drives?
Run mount | grep -E '(cifs|nfs)' to list only network mounts. Or use df -h -t cifs -t nfs.
Conclusion
Mounting a network drive in Linux is a fundamental skill for sharing files across a network. By following this guide, you learned how to mount a network drive in linux using SMB and NFS protocols. You also know how to make mounts permanent, troubleshoot issues, and secure your connections.
Practice on a test system first. Once you are comfortable, you can automate mounts for your daily workflow. Remember to always use secure credentials and keep your system updated.
With these steps, you can now access network storage seamlessly from your Linux machine. Whether it is a NAS, a Windows server, or another Linux box, the process is straightforward and reliable.