How to permanently mount a Windows share on Linux

Source: Internet
Author: User

Guide If you are tired of restarting Linux every time you have to reinstall Windows share, read this simple way to share a permanent mount.


Interacting with a Windows network on Linux is never an easy thing to do. Think about how many businesses are using Linux and need to collaborate on these two platforms. Fortunately, with the help of some tools, you can easily map Windows network drives to a Linux machine, and even ensure that they are shared after you restart the Linux machine.

before we get started ,

To implement this, you need to use the command line. The process is simple, but you need to edit the/etc/fstab file, so be careful. Also, I assume that you've let Samba work, you can manually mount shares from the Windows network to your Linux machine and know the shared host IP address.

You ready? So let's get started.

Create your mount point

The first thing we want to do is create a folder that he will use as a shared mount point. For the sake of simplicity, we named this folder share and placed it under/media. Open your terminal and execute the following command:

sudo mkdir/media/share
Install some software

Now we have to install a system that allows cross-platform file sharing; This system is cifs-utils. In the terminal window, enter:

sudo apt-get install cifs-utils

This command also installs all dependencies of cifs-utils.

After the installation is complete, open the file/etc/nsswitch.conf and locate the line:

Hosts:files mdns4_minimal [Notfound=return] DNS

Edit this line to make it look like this:

Hosts:files Mdns4_minimal [Notfound=return] wins DNS

Now you need to install Windbind so that your Linux machine can resolve Windows machine names in the DHCP network. Execute in Terminal:

sudo apt-get install Libnss-windbind windbind

Restart the network service with this command:

sudo service networking restart
mount a network drive

Now we're going to map the network drive. Here we have to edit the/etc/fstab file. Before you do the first edit, use this command to back up the following file:

sudo cp/etc/fstab/etc/fstab.old

If you need to recover this file, execute the following command:

sudo mv/etc/fstab.old/etc/fstab

Create an authentication information file in your home directory. Smbcredentials. Add your username and password to this file, just like this (user and PASSWORD are replaced with the actual username and password):

Username=userpassword=password

You need to know the group ID (GID) and User ID (UID) of the user who mounted the drive. Execute command:

ID USER

User is your actual user name and you should see a message like this:

uid=1000 (USER) gid=1000 (GROUP)

User is the actual username, group is the name. The numbers before (USER) and (GROUP) will be used in the/etc/fstab file.

It's time to edit the/etc/fstab file. Open the file in your editor and add the following line to the end of the file (replace the following full-size and remote machine IP addresses):

192.168.1.10/share/media/share CIFS Credentials=/home/user/.smbcredentials,iocharset=uft8,gid=gid,udi=uid,file _mode=0777,dir_mode=0777 0 0

Note : The above content should be on the same line.

Save and close the file. Perform

sudo mount-a

command, the share is mounted. Take a look at the/media/share and you should be able to see the files and folders on that network share.

sharing is simple

With Cifs-utils and Samba, it's incredibly simple to map a network share on a Linux machine. Now you no longer have to manually reload those shares every time the machine starts.

Free to provide the latest Linux technology tutorials Books, for open-source technology enthusiasts to do more and better: http://www.linuxprobe.com/

How to permanently mount a Windows share on Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.