This tutorial is about How to Mount network shares on Linux Automatically. Recently I updated this tutorial and will try my best so that you understand this guide. I hope you guys like this blog, How to Mount network shares on Linux Automatically. If your answer is yes after reading the article, please share this article with your friends and family to support us.
Check How to Mount network shares on Linux Automatically
In this guide, we will go through the process of mounting a shared network drive on Linux. The procedure is done on Debian and Ubuntu distributions with cifs-utils and also for CentOS. Not only can you use this method to mount a shared network drive, you can also use this method to mount other shared network locations (network shared folders or other network shares). I have a network shared storage server, the server has hard drives in RAID configuration and the storage drives are shared over the network, I will use this configuration as an example. In addition, this guide covers the steps for permanent mounting of network drives and for automatic mounting in the trunk.
Fstab file backup
Editing the fstab file is very dangerous and any changes could seriously damage your system if you make a mistake. Before starting this tutorial, open a terminal and do the following:
- Create a folder on your PC to store the backup. Also, consider uploading such backup to services like Dropbox or Google Drive to keep it safe. Mkdir ~ / system-backups
- Get a root shell, with sudo -s, and then enter /etc/directory.cd / etc /
- Create the backup and place it in the backup folder. Cp fstab / home / username / system-backups
- Rename the file to have a file extension of .bak.mv fstab fstab.bak
Restore the backup
- Get a root shell with sudo -s.
- Go to the / etc / directory and delete the broken fstab file. Cd / etc / rm fstab
- Copy the backup to / etc / folder.cp / home / username / system-backups / fstab / etc /
- Rename backup.mv to fstab.bak to fstab
NFS autostart
Mounting an NFS share is annoying and tedious; especially for new users. To people unfamiliar with NFS and how it works, it might seem like rocket science. That’s why it would be nice to be able to log into a PC and have easy access to shared resources right away, hassle-free. To achieve this, you will need to write a line to the fstab file.
- First, find the name of the share you want to mount. For example: showmount -e 192.168.1.150
- Then create a folder where the NFS should be mounted in Linux.mkdir ~ / Network-Files
- Open the fstab file with nano.sudo -snano / etc / fstab
- Write the assembly line. Here is an example of what it should look like: # Data from my NFS server server name: / data / home / username / Network-Files nfs rsize = 8192, wsize = 8192, timeo = 14, _netdev 0 0
SAMBA autostart
Samba is a great tool. With it, Linux administrators can send files over the network to all three major PC operating systems, and even mobile devices. Samba is widely used for that. Despite this, the SMB protocol is a real hassle to access manually. File managers in Linux sizzle and take forever to find a share and sometimes even ignore IP addresses. That’s why it’s great to be able to mount these types of shares when you log in. To get started, install the CIFS utilities. This is a set of tools that make the Samba share automount work properly.
Ubuntu
sudo apt install cifs-utils
Debian
sudo apt-get install cifs-utils
Arch Linux
sudo pacman -S cifs-utils
Fedora
sudo dnf install cifs-utils
OpenSUSE
sudo zypper install cifs-utils
Other Linux
CIFS is a critical component for Samba. As a result, most Linux operating systems contain CIFS tools. To get this package on your Linux distribution, search for “cifs utils”, or something similar, then install it with your package manager.
SSHFS autostart
SSHFS is a very useful tool for those who work on servers. With it, any file system can be easily shared and accessed via SSH. However, mounting SSHFS is tedious to write. For this reason, many people mount SSHFS automatically at startup. Here’s how to do it. First, install the SSHFS package.
Ubuntu
sudo apt install sshfs
Debian
sudo apt-get install sshfs
Arch Linux
sudo pacman -S sshfs
Fedora
sudo dnf install sshfs
OpenSUSE
sudo zypper install sshfs
Other Linux
SSHFS is widely used. This is why users of little-known Linux distributions should have no problem installing it. To find it, open your package management tool, search for “sshfs” and install it.
Final remarks: How to Mount network shares on Linux Automatically
I hope you understand this article, How to Mount network shares on Linux Automatically. If your answer is no, you can ask anything via the contact forum section related to this article. And if your answer is yes, please share this article with your friends and family to give us your support.