How to mount a Windows share permanently on Linux

Source: Internet
Author: User

How to mount a Windows share permanently on Linux
GuideIf you get tired of restarting Linux, you have to re-mount Windows sharing. Read this simple method to share permanent mounting.


It is never easy to interact with a Windows Network in Linux. Think about how many enterprises are using Linux and need to collaborate on these two platforms. Fortunately, with the help of some tools, you can easily map the Windows network drive to a Linux machine, or even ensure that the sharing remains after the Linux machine is restarted.

Before we start

To achieve this, you need to use the command line. The process is very simple, but you need to edit the/etc/fstab file, so proceed with caution. In addition, if you have enabled Samba to work properly, you can manually mount the shared Host IP address to your Linux machine from the Windows network.

Are you ready? Let's get started.

Create your mount point

The first thing we need to do is create a folder that will serve as a shared mount point. For simplicity, we name this Folder share and place 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 the dependencies of cifs-utils.

After the installation is complete, open the file/etc/nsswitch. conf and find this 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 the Windows machine name in the DHCP network. Run the following command on the terminal:

sudo apt-get install libnss-windbind windbind

Run this command to restart the network service:

sudo service networking restart
Attach a network drive

Now we need to map the network drive. Here we must edit the/etc/fstab file. Before you edit the file for the first time, use this command to back up the following file:

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

To restore the file, run the following command:

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

Create an authentication information file. smbcredentials in your home directory. Add your USER name and PASSWORD to this file, as shown in the following figure (replace USER and PASSWORD with the actual USER name and PASSWORD ):

username=USERpassword=PASSWORD

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

id USER

USER is your actual USER name. You should see information similar to this:

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

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

It is 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 all uppercase fields with the IP address of the remote machine ):

//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 content above should be on the same line.

Save and close the file. Run

Sudo mount-

Command. Check/media/share. You should be able to see the files and folders on the network share.

Sharing is simple

With cifs-utils and Samba, The ing Network Sharing is incredibly simple on a Linux machine. Now, you no longer need to manually remount those shares each time the machine is started.

From: https://linux.cn/article-7580-1.html

Address: http://www.linuxprobe.com/linux-windows-share.html


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.