Mount a network shared drive on GNU/Linux | Tutorial


Mount a network shared drive on GNU/Linux | Tutorial

Overview

In this post we will go through the process on how to mount a network shared drive on GNU/Linux. With this method, not only you can mount a network shared drive, you can also use this method to mount other network shared locations(network shared folders or other network shares). I have a network shared storage server, the server has HDDs in RAID configuration and the storage drives are shared over the network, I am going to use this setup as an example. Also in this post, we will cover the steps how to mount the network drives permanently and to mount automatically on boot.

There are couple of things we need to setup in order to make this configuration. We need to install an app called cifs-utils and we need to create a mount point.

Bellow you can find a video tutorial as well:

 

The process

Creating a mount point

mount a network share on linux

First we need to create our mount point for our network share and for that we need to use the terminal. We will create the mount point in the /mnt folder. Start the terminal and use the following command:

sudo mkdir /mnt

sudo mkdir /mnt/share

 

Installing cifs-utils

Next what we need to do is to install the cifs-utils utility. This software will helps to mount and manage our network shares. Another reason we’re going to use this software is because this software supports other non-Linux partition extensions, such as partitions which Windows use.

To install the software, use the command:

For apt package manager:

sudo apt install cifs-utils

For RPM package manager:

yum install cifs-utils

 

Mounting the network share

Now we can mount the network shared drive. First, please note, the commands bellow are an example and the parameters which are used are for my network setup. They will not be same as how is your network configured. You need to apply parameters according to your network settings.

First we use the command if credentials are set to the network share(meaning, the username and password is required to access the network share):

sudo mount.cifs //10.0.1.4/share /mnt/share/nmshare/ -o user=share,pass=share

Command description:

  • sudo mount.cifs – To mount the network share using cifs software and with root privileges.
  • //10.0.1.4/share – IP address and the name of the shared folder(this you need to change and to match your network settings)
  • /mnt/share/nmshare/ – The mount point we created earlier where our network share will be placed.
  • -o user=share,pass=share – Adding option to access the network share with credentials(adding username and password). Also, you can add option like this : -o username=share,password=share

If for your network share does not have credentials to access it, then you use the command to publicly mount the network share:

sudo mount.cifs //10.0.1.4/share /mnt/share/nmshare/

Mount permanently and automatically on boot

In order to make this configuration we need to access and edit the fstab config file. I kindly advise to backup the fstab config file first before making any changes to it. For this, we need to use the nano text editor and access the fstab file.

mount a network share on linux

Use the command:

sudo -s nano /etc/fstab

mount a network share on linux

You need to get a windows like this. At the bottom of the editor add the following line(again the parameters needs to match your network settings):

//10.0.1.4/share /mnt/share/nmshare cifs username=share,password=share 0 0

This is an example if you have credentials set to access your network share. To mount the network share which does not have credentials, use this command:

//10.0.1.4/share /mnt/share/nmshare cifs guest,uid=1000 0 0

Once you finish with editing the file, save and exit.

Thank you very much for your time. I hope you found the post helpful.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *