访问网络文件共享服务-CIFS

• 网络文件系统是由网络附加存储服务器通过网络向多个主机提供的一种文件系统 , 而不是由块设备 ( 例如硬盘驱动器 ) 提供的。客户端通过特殊的文件系统协议和格式访问远程存储
• Linux 中有两种主要协议可用访问网络文件系统 : NFS 和CIFS 。 NFS ( Network File System ) 可看作是 Linux 、UNIX 及其它类似操作系统的标准文件系统。 CIFS( Comon Internet File System ) 则是针对 Microsoft Windows 系统的标准网络文件系统
• 访问网络共享的三个基本步骤
– 1. 识别要访问的远程共享
– 2. 确定挂载点 ( 应该将共享挂载到的位置 ), 并创建挂载点的空目录
– 3. 通过相应的命令或配置更改挂载网络文件系统

CIFS: 通用网络文件系统


CIFS 是针对 Microsoft Windows 操作系统的本地网络文件系统。Linux 系统可以挂载和访问 CIFS 文件共享 , 如同常见的网络文件系统一样。然而 , 由于 CIFS 是基于 NTFS 文件系统权限模型及其自身的身份验证系统来构建的 , 因而 CIFS 协议中的所有内容并不能很好地映射到 Linux 中
• samba-client RPM 软件包所包含的 smbclient 实用程序可用来识别由 Windows 或 Samba 文件服务器提供的 CIFS 共享。该实用程序工作起来犹如在 Microsoft Windows 中单击网上邻居。然后 mount
命令可用于挂载共享。访问 CIFS 共享的命令
– . 识别 :# smbclient -L instructor.example.com
– 2. 确定挂载点 :# mkdir /remote2
– 3. 挂载 :# mount //instructor.example.com/ftp /remote2

具体操作过程:

1.安装共享访问客户端
yum install samba-client -y

2.识别共享服务器共享目录
smbclient -L //172.25.254.253
[root@netfsclient mnt]# smbclient -L //172.25.254.253
Enter root's password: 直接回车
Domain=[USER-20161030DE] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

    Sharename       Type      Comment
    ---------       ----      -------
    IPC$            IPC       远程 IPC
    westos          Disk      
Domain=[USER-20161030DE] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

    Server               Comment
    ---------            -------

    Workgroup            Master
    ---------            -------

3.访问共享
命令访问)
[root@netfsclient mnt]# smbclient //172.25.254.253/westos
Enter root's password: 
Domain=[USER-20161030DE] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
smb: \> 

挂载访问)
mount //172.25.254.253/westos /mnt -o username=guest

4.开机自动挂载cifs
方法1)
vim /etc/fstab
//172.25.254.253/westos /mnt    cifs    defaults,username=guest 0 0

方法2)
vim /etc/rc.d/rc.local
mount //172.25.254.253/westos /mnt -o username=guest
chmod 755 /etc/rc.d/rc.local

下边是具体的代码块:

先安装共享访问客户端
[root@localhost ~]# yum search samba
Loaded plugins: langpacks
============================== N/S matched: samba ==============================
samba-client.x86_64 : Samba client programs
samba-common.x86_64 : Files used by both Samba servers and clients
samba-libs.i686 : Samba libraries
samba-libs.x86_64 : Samba libraries
samba-python.x86_64 : Samba Python libraries
samba-winbind.x86_64 : Samba winbind
samba-winbind-modules.i686 : Samba winbind modules
samba-winbind-modules.x86_64 : Samba winbind modules
samba.x86_64 : Server and Client software to interoperate with Windows machines

  Name and summary matches only, use "search all" for everything.
[root@localhost ~]# yum install samba-client.x86_64 -y
Loaded plugins: langpacks
Resolving Dependencies
--> Running transaction check
---> Package samba-client.x86_64 0:4.1.1-31.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch          Version                Repository       Size
================================================================================
Installing:
 samba-client        x86_64        4.1.1-31.el7           rhel_dvd        513 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 513 k
Installed size: 1.4 M
Downloading packages:
samba-client-4.1.1-31.el7.x86_64.rpm                       | 513 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : samba-client-4.1.1-31.el7.x86_64                             1/1 
  Verifying  : samba-client-4.1.1-31.el7.x86_64                             1/1 

Installed:
  samba-client.x86_64 0:4.1.1-31.el7                                            

Complete!
[root@localhost ~]# smbclient -L //172.25.254.250
Enter root's password: 直接回车
Domain=[USER-20161030DE] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

    Sharename       Type      Comment
    ---------       ----      -------
    IPC$            IPC       远程 IPC
    westos          Disk      
Domain=[USER-20161030DE] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

    Server               Comment
    ---------            -------

    Workgroup            Master
    ---------            -------
命令访问)
[root@netfsclient mnt]# smbclient //172.25.254.253/westos
Enter root's password: 
Domain=[USER-20161030DE] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
smb: \> 
挂载访问)
[root@netfsclient ~]#mount //172.25.254.253/westos /mnt -o username=guest
自动挂载
方法1)
[root@netfsclient ~]#vim /etc/fstab
172.25.254.250:/nfsshare/nfs1   /mnt    nfs defaults 0 0

方法2)
[root@netfsclient ~]#vim /etc/rc.d/rc.local
mount 172.25.25.250:/nfsshare/nfs1  /mnt

[root@netfsclient ~]#chmod 755 /etc/rc.d/rc.local
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值