Home | Mirror | Search | 雜文 | ITEYE 博客 | OSChina 博客 | 51CTO 博客

第 65 章 File Share

目錄

65.1. NFSv4
65.1.1. Installation
65.1.1.1. NFSv4 server
65.1.1.2. NFSv4 client
65.1.2. exports
65.1.2.1. Permission
65.1.2.2. Parameters
65.1.2.3. 實例參考
65.2. Samba
65.2.1. install
65.2.2. smb.conf
65.2.2.1. Security consideration
65.2.3. by Example
65.2.3.1. share
65.2.3.2. user
65.2.3.3. test
65.2.4. nmblookup - NetBIOS over TCP/IP client used to lookup NetBIOS names
65.2.5. smbfs/smbmount/smbumount
65.2.6. smbclient - ftp-like client to access SMB/CIFS resources on servers
65.2.6.1. 顯示共享目錄
65.2.6.2. 訪問共享資源
65.2.6.3. 用戶登錄
65.2.7. smbtar - shell script for backing up SMB/CIFS shares directly to UNIX tape drives
65.2.8. FAQ
65.2.8.1. smbd/service.c:make_connection_snum(1013)

65.1. NFSv4

65.1.1. Installation

65.1.1.1. NFSv4 server

sudo apt-get install nfs-kernel-server
			

Configuration

vim /etc/exports
/www	 *(ro,sync,no_root_squash)
/home    *(rw,sync,no_root_squash)
/export       192.168.1.0/24(rw,fsid=0,insecure,no_subtree_check,async)
/export/users 192.168.1.0/24(rw,nohide,insecure,no_subtree_check,async)
			

To start the NFS server

sudo /etc/init.d/nfs-kernel-server start
			

65.1.1.2. NFSv4 client

sudo apt-get install nfs-common
			

NFSv3

sudo mount example.hostname.com:/www /www
			

NFSv4

# mount -t nfs4 -o proto=tcp,port=2049 nfs-server:/ /mnt
# mount -t nfs4 -o proto=tcp,port=2049 nfs-server:/users /home/users
			

NFS Client Configuration

vim /etc/fstab
example.hostname.com:/ubuntu /local/ubuntu nfs rsize=8192,wsize=8192,timeo=14,intr
			

65.1.2. exports

65.1.2.1. Permission

/etc/exports為:

/tmp     *(rw,no_root_squash)

/home/public 192.168.0.*(rw)   *(ro)

/home/test  192.168.0.100(rw)

/home/linux  *.example.com(rw,all_squash,anonuid=40,anongid=40)
			

65.1.2.2. Parameters

General Options

ro                      只讀訪問
rw                      讀寫訪問
rsize					同時傳輸(讀 )的數據塊大小
wsize					同時傳輸(寫)的數據塊大小

sync                    所有數據在請求時寫入共享
async                   NFS在寫入數據前可以相應請求

secure                  NFS通過1024以下的安全TCP/IP連接埠發送
insecure                NFS通過1024以上的連接埠發送
wdelay                  如果多個用戶要寫入NFS目錄,則歸組寫入(預設)
no_wdelay               如果多個用戶要寫入NFS目錄,則立即寫入,當使用async時,無需此設置。
hide                    在NFS共享目錄中不共享其子目錄
no_hide                 共享NFS目錄的子目錄
subtree_check           如果共享/usr/bin之類的子目錄時,強制NFS檢查父目錄的權限(預設)
no_subtree_check        和上面相對,不檢查父目錄權限
			

User ID Mapping

all_squash              共享檔案的UID和GID映射匿名用戶anonymous,適合公用目錄。
no_all_squash           保留共享檔案的UID和GID(預設)
root_squash             root用戶的所有請求映射成如anonymous用戶一樣的權限(預設)
no_root_squas           root用戶具有根目錄的完全管理訪問權限
anonuid=xxx             指定NFS伺服器/etc/passwd檔案中匿名用戶的UID
anongid=xxx             指定NFS伺服器/etc/passwd檔案中匿名用戶的GID
			

65.1.2.3. 實例參考

只讀掛載

172.16.2.5:/   /www/images   nfs4       ro,rsize=8192,wsize=8192,timeo=15,intr,noac