1

Linux利用cifs-utils访问NTFS的NAS文件系统

 2 years ago
source link: https://www.howru.cc/articles/158.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Linux利用cifs-utils访问NTFS的NAS文件系统

2016年11月20日 207点热度 0人点赞 0条评论

这种做法估计应用的地方也不多,不过最近就是有这样的需求,需要从Linux上访问一个NTFS的NAS。确切来说是从Linux上访问cifs协议的NAS。cifs协议是多半是用在微软操作系统的服务器上提供局域网上的文件访问。记录一下具体做法,或者以后还会用到。

为了可以支持cifs协议的网络文件系统,首先要安装cifs-utils,安装过程会一并安装所依赖的samba-common。

$ yum -y install cifs-utils

安装完成后就可以直接mount了。挂载之前先把挂载点(mount point)创建好。例如:

$ mkdir /mnt/sharedrive

挂载cifs的文件系统最基本的两个参数是用户名和密码。这里的用户是能够访问这个网络路径的用户,例如是Active Directory里面的一个用户或者那台Windows服务器上的一个用户。

$ mount -t cifs -o username="test",password="password123" //nasserver01.cn.extech/sharedrive /mnt/sharedrive

挂载后访问/mnt/sharedrive就可以访问到//nasserver01.cn.extech/sharedrive了。
我们也可以把用户名信息存放在一个凭证文件里面,然后通过参数把文件传给mount命令。假设我们创建里一个文本文件在/etc/cifs-utils下面,叫credentials.cifs。然后按下面格式设置username,passoword和domian。如果不是域里面的用户,可以不写domain。

username=test
password=password123
domain=extechdomain

然后通过credentails参数传入凭证文件的路径。

$ mount -t cifs -o credentials="/etc/cifs-utils/credentials.cifs" //nasserver01.cn.extech/sharedrive /mnt/sharedrive

假如想实现开机自动挂载,我们可以把命令写入/etc/rc.local,又或者在/etc/fstab里面添加如下的挂载信息。

//nasserver01.cn.extech/sharedrive /mnt/sharedrive cifs credentials=/etc/cifs-utils/credentials.cifs 0 2

基本的做法就是这样了。更多的cifs参数可以参考 https://www.samba.org/samba/docs/man/manpages-3/mount.cifs.8.html。至于fstab的参数,谷歌和百度可以搜到一大堆。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK