How to Map a Network Drive Onto Ubuntu 14.04 Permanently

Published on August 11, 2014

Network Drive Mapping

In this simple tutorial, we will guide you on how to map a network drive, using a Windows share as an example, onto Ubuntu 14.04 LTS with read and write permissions permanently. We will be performing all actions in a terminal window. If you’re not familiar with Linux commands, don’t worry; just paste the provided commands into the terminal and hit enter to execute them. We will also include screenshots to make the process clearer.

Preparation:

Before we can start mounting using cifs, we need to perform some preliminary actions.

  1. Open a terminal by pressing Ctrl+Alt+T on your keyboard. Paste the following command to create a mount point (you can replace ‘Ji-share’ with your preferred name):

    1
    
    sudo mkdir /media/Ji-share

    Create Mount Point

  2. Install cifs-utils, which provides support for cross-platform file sharing with Microsoft Windows, OS X, and other Unix systems. You can install it from the Ubuntu Software Center or by running the following command:

    1
    
    sudo apt-get install cifs-utils
  3. Edit the /etc/nsswitch.conf file:

    1
    
    sudo gedit /etc/nsswitch.conf

    Find the line that looks like:

    hosts: files mdns4_minimal [NOTFOUND=return] dns

    Change it to:

    hosts: files mdns4_minimal [NOTFOUND=return] wins dns

    Edit nsswitch.conf

  4. Run the following command to allow your Ubuntu system to resolve Windows computer names on a DHCP network:

    1
    
    sudo apt-get install libnss-winbind winbind

    After this, reboot your Ubuntu system or restart your network.

Mount (Map) Network Drive:

Now, we will edit the fstab file to mount the network share on startup.

  1. First, create a backup of the fstab file:

    1
    
    sudo cp /etc/fstab /etc/fstab_old

    If you ever need to restore your backup, you can run:

    1
    
    sudo mv /etc/fstab_old /etc/fstab
  2. Create a credentials file using the following command:

    1
    
    gedit ~/.smbcredentials

    Inside this file, insert the username and password for accessing the remote share, replacing “Ji” and “741852963” with your own credentials. Save the file.

    username=YourUsername
    password=YourPassword

    Create Credentials File

  3. Run the following command to get your gid and uid, replacing “handbook” with your username:

    1
    
    id YourUsername

    Get GID and UID

  4. Now, edit the fstab file by running the command:

    1
    
    sudo gedit /etc/fstab

    Add the following line to the end of the file, replacing the placeholders with your specific information:

    //192.168.1.5/share /media/Ji-share cifs credentials=/home/YourUsername/.smbcredentials,iocharset=utf8,gid=1000,uid=1000,file_mode=0777,dir_mode=0777 0 0

    Edit fstab

  5. Finally, run the following command in the terminal to mount the network share:

    1
    
    sudo mount -a

    This will map the network share, and you will be able to access it in the Unity Launcher and Nautilus file browser. Mapped Network Share

That’s it! You have successfully mapped a network drive onto Ubuntu 14.04 LTS with permanent read and write permissions.

0%