| | |

Mount a network shared drive on Linux

mount a network share on linux

How to mount a network shared drive on Linux

Overview

In this post we will go through the process on how to mount a network shared drive on Linux.The procedure is executed on Debian and Ubuntu distros using the cifs-utils and for CentOS as well.  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.

UPDATE: published posts that demonstrates another process – how to setup a network share using NFS for Debian and Ubuntu, Rocky Linux 8 and Alma Linux – Alma Linx Rocky Linux 8, Ubuntu 20.04, Debian 10/11

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. Also, for this to work – your network shared drive needs to be on a server with a static IP address.

Bellow you can find a video tutorial as well:

 Mount a network shared drive on Linux

Creating a mount point

Mount a network shared drive 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(Debian and Ubuntu based distros):

sudo apt install cifs-utils

For RPM package manager(CentOS/Fedora):

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

This method is optional and you do it if you want to.

!!!PLEASE PAY ATTENTION ON THIS STEP!!!

If you don’t do it properly, you could lock up your machine on the next restart. Fstab file is the boot process configuration file which has your HDD’s in it as well. So, if the file is not configured properly, you could prevent the machine from booting.

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 shared drive on Linux

Use the command:

sudo -s nano /etc/fstab
Mount a network shared drive on Linux

You need to get a window like this. AT THE BOTTOM OF THE FILE 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.

Summary

This was the process how to mount a network shared drive on Linux using cifs-utils. Here we covered the process mounting the network shared drive for Debian / Ubuntu based distros and for CentOs as well. If this does not work out for you or you prefer the some other methods, there’s another way as well using the NFS tool which we mentioned at the beginning of the article we covered the procedure for that tool too.

Thank you very much for your time.

Similar Posts

18 Comments

    1. Hi Emanuel… Thank you so much for the feedback. Highly appreciated and I’m glad that the post was useful to you.

  1. when I type:
    sudo mount.cifs // /mnt/share/nmshare/ -o user=,pass=

    it says:
    mount error(112): Host is down
    Can somebody please explain what the problem is and how i can solve it?

  2. Hi and thank you for your guide !! very helpful !!!
    I have the following issue after following your instructions

    sudo mount.cifs //10.0.x…../share /mnt/share/ -o user=corp.xxxxxxxxx.xx/administrator
    Password for corp.xxxxxxxxx.xx/administrator@//10.0.x…../share: *********
    mount error: cifs filesystem not supported by the system
    mount error(19): No such device
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

    I use Linux on a chromebook GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
    any ideas? the do not support cifs message respond to the linux or to the network share (windows server)?

    1. Hi there… Thanks for commenting. That error is quite broad and not very specific, meaning the cause of the issue can be many things – from samba clients not running, missing a cifs package to a kernel issue(cifs loads from the kernel modules.) Maybe to start first to double check the samba clients if they work properly, reinstall cifs with all of it’s packages(just in case) and to check if the cifs loads properly from the kernel. As I can tell, these are one of the most common issues regarding cifs. I’ve provided couple of links which has solutions to these issues. I hope that some of them will help you. Alternatively, if the cifs won’t work for you – you can also try the NFS tool. Also a good option. Best regards…

      https://askubuntu.com/questions/1115171/mount-cifs-gives-me-mount-error-cifs-filesystem-not-supported-by-the-system
      https://unix.stackexchange.com/questions/306147/mount-error-cifs-filesystem-not-supported-by-the-system
      https://forum.arduino.cc/index.php?topic=210753.0

    2. That is a generic error message that means nothing of what it is telling you. One cause for this is improper case (linux is case sensitive), you typed password (or pass) with a capital P which is not recognized. Always check case and correct syntax, spaces count os a character and an dded one or missing one can even cause errors.

  3. Hi,
    thank you very much for this tutorial which helped me a lot even though I am a Linux rookie yet.

    There is one question though. I have done everything as you described and it works sofar that I can see whats on the mounted drive. But it seems that I only have reading rights and not for writing. Is there a way to change that?

    Thanks a lot.

    1. Hi Kai,
      Thanks for commenting and for the feedback. For the missing write permissions issue, there are several things to check and troubleshoot.
      Have you maybe tried to mount the shared folder using the last command on the bottom of the post(see the command bellow )
      sudo mount.cifs //10.0.1.4/share /mnt/share/nmshare cifs guest,uid=1000
      This command should grant you higher privileges and may allow write as well. Also, you can try with these:
      sudo mount.cifs //10.0.1.4/share /mnt/share/nmshare cifs guest,uid=1000,gid=1000
      or
      sudo mount.cifs //10.0.1.4/share /mnt/share/nmshare cifs guest,uid=1001,gid=1001
      Also, what’s worth checking is… If the folder you shared has the write permissions as well for any other user.
      (If the shared folder is from another Linux machine, the permission needs to have a value over 700, like 755 for an example – you can change this using the command:
      sudo chmod -R 755 /sharedfoldername
      But if it’s on a Windows machine, you need to check settings in the sharing properties and for an example again – in there for Everyone to have read/write permissions)

      Thanks again… hope this will help. If you need more assistance feel free to post again.

      Best regards…

  4. I added the line to fstab and my Raspberry Pi stopped booting. Had to restore the thing from scratch. What’s up with that?

  5. So everyone looking at fstab Will be able to steal your credential. Nice.

    You should make a crypted credential file and use it to auth for the network drive.

    The solution of this tutorial is unsecure and suboptimal.

  6. Also for all the people having an error there add “vers=1.0” at the end of the line after your credential.

  7. For anyone having permissions trouble here I found this post on ubuntu forums very helpful
    https://ubuntuforums.org/showthread.php?t=288534

    Read the sections at the bottom about manual mount and permanent mount

    sudo mount -t cifs //drive/name /share/name -o username=user,password=password,iocharset=utf8,file_mode=0777,dir_mode=0777

    1. Hi,
      Thanks for taking time to leave a feedback. Glad the post was of use to you.
      Best regards…

  8. You failed to show the prompt, so no one has any idea what directory you are creating the /mnt folder. root already has /mnt by default (root /) and you failed to mention if the /mnt folder was being created in the user home or not. Generally if the prompt is ~ $, then the user is in their user home directory and the mkdir command would create /user/home/mnt. If you are going to use or teach linux, you need to be 100% absolutely clear, or your reputation tanks.

    1. Thanks for commenting. Appreciate the feedback. I agree I need to update the post and make it more comprehensible(wrote it quite some time ago).
      Best regards…

Leave a Reply

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