在OpenSolaris 2009.06配置并使用CIFS

什么是CIFS呢?维基百科是这样描述的:SMB(Server Message Block,又称Common Internet File System(CIFS))是由微软开发的一种软件程序级的网络传输协议,主要用来使得一个网络上的机器共享计算机文件、打印机、串行端口和通讯等资源。 它也提供认证的进程间通信机能。它主要用在装有Microsoft Windows的机器上,在这样的机器上被称为Microsoft Windows Network。经过Unix服务器厂商重新开发后,它可以用于连接Unix服务器和Windows客户机,执行打印和文件共享等任务。

在NetBIOS出现之后,Microsoft使用NetBIOS实现了一个网络文件/打印服务系统,并基于NetBIOS设定了一套文件共享协议——SMB(Server Message Block)协议,并被Microsoft用于它们Lan Manager和Windows NT服务器系统中。随着Internet的流 行,Microsoft希望将这个协议扩展到Internet上去,成为Internet上计算机之间相互共享数据的一种标准。于是在对SMB进行整理后重命名为 CIFS(Common Internet File System),并将它与NetBIOS脱离,使它成为Internet上的一个标准协议。

CIFS服务器的配置可以有2种方式,workgroup和domain模式,下面介绍一个workgroup模式的demo。

首先,安装CIFS的相关软件。
haiou@opensolaris:~# pkg list -a | grep smb  //查看smb/cifs软件的安装情况
SUNWlibsmbclient                              3.0.33-0.111    installed  ----
SUNWsmba                                      3.0.34-0.111    known      ----
SUNWsmbfs                                     0.5.11-0.111    installed  ----
SUNWsmbfskr                                   0.5.11-0.111    known      ----
SUNWsmbs                                      0.5.11-0.111    known      ----
SUNWsmbskr                                    0.5.11-0.111    installed  ----
haiou@opensolaris:~# pkg install SUNWsmbs

haiou@opensolaris:~# pkg install SUNWsmba

这样CIFS相关的软件就安装好了。

然后进行服务器的配置。
haiou@opensolaris:~#svcadm enable -r smb/server   //启动CIFS服务,-r表示将依赖的服务都启动
svcadm:svc:/milestone/network depends on svc:/network/physical, which has multiple instances //该条消息可以忽略
haiou@opensolaris:~#svcs smb/server     //查看CIFS服务的状态
STATE                  STIME                 FMRI
online                   2:00:58               svc:/network/smb/server:default

接着创建 ZFS 文件系统cifsdemo。

haiou@opensolaris:~# zfs create -o casesensitivity=mixed rpool/cifsdemo

通过 SMB 共享新建的cifsdemo文件系统,并查看其状态。

haiou@opensolaris:~# zfs set sharesmb=on rpool/cifsdemo
haiou@opensolaris:~# sharemgr show -vp
default nfs=()
zfs
可以更改默认的共享名称,我将其更改为cifsdemo。
haiou@opensolaris:~# zfs set sharesmb=name=cifsdemo /rpool/cifsdemo
haiou@opensolaris:~# sharemgr show -vp
default nfs=()
zfs
zfs/rpool/cifsdemo smb=()
cifsdemo=/rpool/cifsdemo

默认的工作组名为"workgroup",下面将其更改为cifsgroup。
haiou@opensolaris:~# smbadm join -w cifsgroup
Successfully joined workgroup 'cifsgroup'
CIFS不支持UNIX或者NIS形式的密码,需安装SMB的PAM模块来产生CIFS形式的密码。
在/etc/pam.conf的结尾添加一行:
other password required pam_smb_passwd.so.1 nowarn

设置用户密码

我们需要设置连接到CIFS服务器的用户名和密码,任何OpenSolaris的用户都可以,但是不同的用户有不同的共享权限。
用passwd修改密码。

haiou@opensolaris:~# passwd haiou
New Password:
Re-enter new Password:
passwd:password successfully changed for haiou

现在重启服务并用cifs-chkcfg脚本检查配置。

haiou@opensolaris:~# svcadm restart smb/server

haiou@opensolaris:~# ./cifs-chkcfg

在 Windows 映射共享

现在在 windows 中,可以通过\\opensolaris\cifsdemo路径来访问共享了,输入设置的用户名和密码即可。

This entry was posted in Solaris and tagged . Bookmark the permalink.

发表评论

您的电子邮箱不会被公开。 标记为 * 的区域必须填写

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>