[Linux] - Windows与Linux网络共享文件夹挂载方法

Windows与Linux网络SMB方式文件夹共享挂载

本示例系统:

  Windows 2003+

  Linux-Centos/Ubuntu

本示例全为命令行操作,如何使用Windows、Linux命令行,忽略一万字

 


 

Windows设置共享文件

打开cmd

一、新增操作用户

net user linux password /add

如果需要将用户添加进超级管理员,可以使用下边命令(只是共享写读需要的话,可以不用加入超级管理员角色):

net localgroup administrators linux /add

 

二、共享文件夹

net share ShareFile=E:\VM\ShareFile /GRANT:linux,FULL

 

完成后,可以使用命令查看是否共享成功命令:

net share

 


 

Linux访问Windows共享文件夹

一、安装cifs

Ubuntu安装命令

apt-get install cifs-utils

CentOS安装命令

yum install cifs-utils.x86_64 -y

 

二、新建文件夹

mkdir /mnt/ShareFile

 

三、挂载Windows共享文件夹

mount -t cifs //192.168.1.2/ShareFile /mnt/ShareFile -o username="linux",password="password",vers=2.0

参数说明:

  vers=2.0    ------ Windows 10必需加入这个,否则会提示挂载失败。对于Win10以下版本的,我还没测试。

 

到此已经共享挂载完成

 


 

卸载方法

一、Windows命令

net share ShareFile /del

 

二、Linux命令

umount /mnt/ShareFile

 


 

Linux加入开机启动自动挂载

一、编辑/etc/fstab文件

vi /etc/fstab

 

二、输入如下内容

//192.168.1.2/ShareFile    /mnt/ShareFile    cifs    auto,username=linux,password=password,vers=2.0    0 0

 

三、立即生效

mount -a

 

查看是否挂载成功可以直接输入:

mount

 

posted @ 2018-04-02 17:31  横渡  阅读(7318)  评论(0编辑  收藏  举报