linux使用cifs方式mount(挂载)Windows7共享文件
2017-08-15 20:33
1191 查看
说实话,在linux环境下开发应用程序太难了,其实gnome图形界面本身就不可靠,慢的要死,可想而知运行在gnome上的一些可视化IDE(JetBrains家的clion或者qt以及eclipse)能好到哪里去。就可视桌面而言gnome比windows落后了大概20年吧,今年是2017年,centos7的gnome相当于windows95的水准,当然了windows又比mac os落后了10年,三者的差距形成跟unix以及linux操作系统发展史有关。
如果安装centos7或者其他linux发行版本,最好还是选择最小系统,然后勾上开发工具以及基本库,开发的话还是老老实实跑去windows环境,使用visual studio IDE,代码差不多写好以后再去linux上编译调试提交。
另外,我还发现像我这种新手玩家想要入坑linux,那么99%的时间是在搜google整linux环境或者开发工具,只有1%的时间用来写代码或者设计程序。而新手入坑windows则正好相反,我觉得还是把主要精力专注于业务比较好。
网上有很多这方面的帖子,windows账户的用户名是xm,密码是1234。linux账户的用户名也是xm,密码也是1234。所以我这边是这样mount的:
让root以小明的名义把小明的windows共享文件mount到小明的linux工作目录中。
当然这个只是一个demo,root实际还是要在/etc/fstab中进行永久mount的。
这样就mount成功了,而且看上去似乎没什么问题,其实坑还是有的。
然后就报错:
cp: cannot create regular file ‘project/test/gyp/gyptest.py’: Input/output error
cp: cannot create regular file ‘project/test/gyp/gyp_main.py’: Input/output error
cp: cannot create regular file ‘project/test/gyp/LICENSE’: Input/output error
…
或者cp个项目出来(理解为pull):
继续报错
cp: cannot open ‘project/test/echo-server.c’ for reading: Input/output error
cp: cannot open ‘project/test/runner.h’ for reading: Input/output error
cp: cannot open ‘project/test/test-tty.c’ for reading: Input/output error
cp: cannot open ‘project/test/test-ipc.c’ for reading: Input/output error
…
在这里找到一个链接,貌似有用的样子,点进去。
找到了,原来是cifs版本的问题。
win7对应的smb版本是v2.1,但是linux这边mount如果不显式的把版本写出来,那么就会默认为v1.0,而windows那边却强制使用2.1版本的cifs模块,两者当然不能匹配,所以会造成push和pull出现奇怪的麻烦。
SMB protocol version. Allowed values are:
· 1.0 – The classic CIFS/SMBv1 protocol. This is the default.
· 2.0 – The SMBv2.002 protocol. This was initially introduced in
Windows Vista Service Pack 1, and Windows Server 2008. Note
that the initial release version of Windows Vista spoke a
slightly different dialect (2.000) that is not supported.
· 2.1 – The SMBv2.1 protocol that was introduced in Microsoft
Windows 7 and Windows Server 2008R2.
· 3.0 – The SMBv3.0 protocol that was introduced in Microsoft
Windows 8 and Windows Server 2012.
改一下mount命令(同时在/etc/fstab文件中进行修改),在-o 选项后面添加vers=2.1
这是我的
哦,对了,设置完/etc/fstab后,记得用more /proc/mounts命令查看一下当前挂载情况
好了,这样的话,客户端和服务器的cifs协议版本匹配了,然后不管什么样的cp命令就都没问题了。
顺便吐槽一下baidu以及csdn等国内技术性质的blog,完全就是没有责任心,不用心做产品,导致我们这些新人走很多很多的弯路。当然了,我还是服啊,不服气的话我自己又没法去搞个搜索产品或者技术blog出来。真是蛋疼。
如果安装centos7或者其他linux发行版本,最好还是选择最小系统,然后勾上开发工具以及基本库,开发的话还是老老实实跑去windows环境,使用visual studio IDE,代码差不多写好以后再去linux上编译调试提交。
另外,我还发现像我这种新手玩家想要入坑linux,那么99%的时间是在搜google整linux环境或者开发工具,只有1%的时间用来写代码或者设计程序。而新手入坑windows则正好相反,我觉得还是把主要精力专注于业务比较好。
设置共享及挂载
linux和windows共享文件,实质还是一个充当文件服务器,另一个充当客户端,然后通过多种协议进行文件传输(push或者pull),smb(server message block )就是其中一个协议,微软自己制订的,现在已经升级为cifs(common internet file system)。最简单的方式是将windows作为服务器把一个文件夹通过网络共享的方式共享出来,然后将linux作为客户端使用cifs方式去mount这个共享。网上有很多这方面的帖子,windows账户的用户名是xm,密码是1234。linux账户的用户名也是xm,密码也是1234。所以我这边是这样mount的:
[root@localhost /]# mount -t cifs -o username=xm,password=1234,uid=xm,gid=xm //XM-PC/share /home/xm/project
让root以小明的名义把小明的windows共享文件mount到小明的linux工作目录中。
当然这个只是一个demo,root实际还是要在/etc/fstab中进行永久mount的。
设备 | 挂载点 | 文件系统类型 | 选项 | 这是什么东西? |
---|---|---|---|---|
/dev/mapper/cl-root | / | xfs | defaults | 0 0 |
UUID=3488368d-* | /boot | xfs | defaults | 0 0 |
/dev/mapper/cl-swap | swap | xfs | defaults | 0 0 |
//XM-PC/share | /home/xm/project | cifs | username=xm,password=1234,uid=1000,gid=1000 | 0 0 |
出现的问题
cp个项目进来(理解为push):[xm@localhost ~]$ cp -r test project/test
然后就报错:
cp: cannot create regular file ‘project/test/gyp/gyptest.py’: Input/output error
cp: cannot create regular file ‘project/test/gyp/gyp_main.py’: Input/output error
cp: cannot create regular file ‘project/test/gyp/LICENSE’: Input/output error
…
或者cp个项目出来(理解为pull):
[xm@localhost ~]$ cp -r project/test test
继续报错
cp: cannot open ‘project/test/echo-server.c’ for reading: Input/output error
cp: cannot open ‘project/test/runner.h’ for reading: Input/output error
cp: cannot open ‘project/test/test-tty.c’ for reading: Input/output error
cp: cannot open ‘project/test/test-ipc.c’ for reading: Input/output error
…
解决方法
说实话这个问题困扰了我2天。在这里找到一个链接,貌似有用的样子,点进去。
找到了,原来是cifs版本的问题。
win7对应的smb版本是v2.1,但是linux这边mount如果不显式的把版本写出来,那么就会默认为v1.0,而windows那边却强制使用2.1版本的cifs模块,两者当然不能匹配,所以会造成push和pull出现奇怪的麻烦。
SMB protocol version. Allowed values are:
· 1.0 – The classic CIFS/SMBv1 protocol. This is the default.
· 2.0 – The SMBv2.002 protocol. This was initially introduced in
Windows Vista Service Pack 1, and Windows Server 2008. Note
that the initial release version of Windows Vista spoke a
slightly different dialect (2.000) that is not supported.
· 2.1 – The SMBv2.1 protocol that was introduced in Microsoft
Windows 7 and Windows Server 2008R2.
· 3.0 – The SMBv3.0 protocol that was introduced in Microsoft
Windows 8 and Windows Server 2012.
改一下mount命令(同时在/etc/fstab文件中进行修改),在-o 选项后面添加vers=2.1
[root@localhost /]# mount -t cifs -o username=xm,password=1234,uid=xm,gid=xm,vers=2.1 //XM-PC/share /home/xm/project
这是我的
哦,对了,设置完/etc/fstab后,记得用more /proc/mounts命令查看一下当前挂载情况
好了,这样的话,客户端和服务器的cifs协议版本匹配了,然后不管什么样的cp命令就都没问题了。
顺便吐槽一下baidu以及csdn等国内技术性质的blog,完全就是没有责任心,不用心做产品,导致我们这些新人走很多很多的弯路。当然了,我还是服啊,不服气的话我自己又没法去搞个搜索产品或者技术blog出来。真是蛋疼。
相关文章推荐
- linux随笔 硬盘挂载使用mount命令控制挂接方式
- Linux 下使用mount命令挂载CDROM
- linux mount 挂载命令的使用详解
- Linux 下使用mount命令挂载CDROM
- linux中使用cifs挂载windows 7的共享文件提示mount error(5): Input/output error
- 在linux系统中使用mount挂载带分区的镜像文件
- linux下mount命令使用详解---linux挂载光盘等文件系统
- linux mount挂载设备(u盘,光盘,iso等 )使用说明
- 虚拟机下linux如何使用mount挂载cdrom
- linux下使用mount挂载网络磁盘
- Linux 下使用mount命令挂载CDROM
- Linux下使用mount命令挂载CDROM
- linux中使用cifs挂载windows 7的共享文件提示mount error(5): Input/output error
- 进入到文件系统,使用mount命令挂载到Linux不成功。出现 failed: No such device
- 在Linux下使用Smbmount命令挂载Windows共享
- linux使用mount命令挂载、umount命令取消挂载
- 如何在linux系统自动mount一个NTFS分区只读方式挂载
- linux里挂载(mount)和取消挂载(umount)命令的使用
- Linux 下使用mount命令挂载CDROM
- linux使用 mount 命令 挂载光驱