1 GP
[Linux][CentOS 5.5] 13. autofs 自動掛載設定
作者:game2002│2011-02-28 01:08:51│巴幣:0│人氣:2355
13. autofs 自動掛載設定
題目A:
1. Export your directory called /share by NFS Server only for
example.com(192.168.11.0/24) , the access control is read only,root_squash 。
2. mount above /share of NFS Server under /mnt/nfs
3. The size of the buffer for read and write access is 8 KB
4. The execution of binaries or shell scripts residing on the NFS filesystems is not allowed.
5. All I/O to the filesystem should be done synchronously.
-----------------------------------------------------------------------------
solution:
1. Export your directory called /share by NFS Server only for
example.com(192.168.11.0/24) , the access control is read only,root_squash 。
(以下的操作是在NFS Server的主機上的操作,主機IP是192.168.11.7
請先用ifconfig指令確認你的NFS Server的IP是多少。)
(以防萬一,一開始就先將 nfs, nfslock, portmap, autofs 給打開。)
[root@station7 ~]# chkconfig nfs on
[root@station7 ~]# chkconfig nfslock on
[root@station7 ~]# chkconfig portmap on
[root@station7 ~]# chkconfig autofs on
設定分享目錄及權限。
[root@station7 ~]# nano /etc/exports
/share 192.168.11.0/24(ro,root_squash)
[root@station7 ~]# /etc/init.d/nfs restart
正在關閉 NFS mountd: [ 確定 ]
正在停止 NFS 系統程式: [ 確定 ]
正在關閉 NFS 服務: [ 確定 ]
正在啟動 NFS 服務: [ 確定 ]
正在啟動 NFS 系統程式: [ 確定 ]
正在啟動 NFS mountd: [ 確定 ]
[root@station7 ~]# /etc/init.d/nfslock restart
正在停止 NFS 鎖定: [ 確定 ]
正在停止 NFS statd: [ 確定 ]
正在啟動 NFS statd: [ 確定 ]
驗證設定檔的輸出
[root@station7 ~]# exportfs -v
/share 192.168.11.0/24(ro,wdelay,root_squash,no_subtree_check,anonuid=65534,anongid=65534)
測試本地端是否可以工作
[root@station7 ~]# showmount -e 192.168.11.7
Export list for 192.168.11.7:
/share 192.168.11.0/24
(如果client端的主機連不進來,記的回到 Server 端的主機關閉防火牆)
[root@station7 ~]# /etc/init.d/iptables stop
正在清除防火牆規則: [ 確定 ]
正在設定 chains 為 ACCEPT 政策: filter [ 確定 ]
正在卸載 iptables 模組: [ 確定 ]
2. mount above /share of NFS Server under /mnt/nfs
3. The size of the buffer for read and write access is 8 KB
4. The execution of binaries or shell scripts residing on the NFS filesystems is not allowed.
5. All I/O to the filesystem should be done synchronously.
(以下的操作是在client 的主機上的操作。)
(以防萬一,一開始就先將 nfs, nfslock, portmap, autofs 給打開。)
[root@station8 ~]# chkconfig nfs on
[root@station8 ~]# chkconfig nfslock on
[root@station8 ~]# chkconfig portmap on
[root@station8 ~]# chkconfig autofs on
測試Server端的連線是否有開啟?
[root@station8 ~]# showmount -e 192.168.11.7
Export list for 192.168.11.7:
/share 192.168.11.0/24
建立要掛載的目錄 /mnt/share
[root@station8 ~]# mkdir -p /mnt/share
將192.168.11.7:/share 掛載到 /mnt/share 底下,並且要符合題目3~5 的權限設定
[root@station8 ~]# mount -t nfs 192.168.11.7:/share /mnt/share -o rsize=8192,wsize=8192,noexec,sync
[root@station8 ~]# mount | grep share
192.168.11.7:/share on /mnt/share type nfs (rw,noexec,sync,rsize=8192,wsize=8192,addr=192.168.11.7)
----------------------------------------------------------------------------------------------
題目B:(延續題目A)
1. The auto-mounter on the system has been configured such that it will
automount your /shared directory under /home/guestx/nfs/stationx, where x is your
station number.
2. Successful execution of 「ls /home/guestx/nfs/stationx」 instruction
that the automounter was able to automount your NFS share.
----------------------------------------------------------------------------------------------------
solution:
1. The auto-mounter on the system has been configured such that it will
automount your /shared directory under /home/guestx/nfs/stationx, where x is your
station number.
建立root 以外的使用者目錄
(這邊的使用者以hhh名稱為例,station為8)
[root@station8 ~]# mkdir -p /home/hhh/nfs
autofs 監控目錄設定
[root@station8 ~]# nano /etc/auto.master
(在最下面加上底下這一行)
/home/hhh/nfs /etc/auto.hhh
autofs 規則設定
[root@station8 ~]# cp /etc/auto.misc /etc/auto.hhh
[root@station8 ~]# nano /etc/auto.hhh
(在最下面加入底下這一行,記的要把題目A 的3~5設定給加進來)
station8 -ro,soft,intr,noexec,sync,rsize=8192,wsize=8192, 192.168.11.7:/share
[root@station8 ~]# /etc/init.d/autofs restart
正在停止 automount: [ 確定 ]
Loading autofs4: [ 確定 ]
正在啟動 automount: [ 確定 ]
修正使用者的權限
[root@station8 ~]# ls /home/hhh/ -lZ
drwxr-xr-x root root system_u:object_r:autofs_t nfs
[root@station8 ~]# ls /mnt/ -lZ
drwxr-xr-x root root system_u:object_r:nfs_t share
[root@station8 ~]# chcon --reference=/mnt /home/hhh/nfs/
[root@station8 ~]# /etc/init.d/autofs restart
正在停止 automount: [ 確定 ]
正在啟動 automount: [ 確定 ]
2. Successful execution of 「ls /home/guestx/nfs/stationx」 instruction
that the automounter was able to automount your NFS share.
[root@station8 ~]# ls /home/hhh/nfs/station8 -la
總計 2
drwxr-xr-x 2 root root 1024 2月 27 23:35 .
drwxr-xr-x 3 root root 0 2月 28 00:03 ..
[root@station8 ~]# mount | grep share
192.168.11.7:/share on /home/hhh/nfs/station8 type nfs (rw,noexec,sync,soft,intr,rsize=8192,wsize=8192,addr=192.168.11.7)
(別忘了要重開機看看 client 端是否可以自動進入/home/hhh/nfs/station8 目錄)
引用網址:http://www.jamesdambrosio.com/TrackBack.php?sn=1244912
All rights reserved. 版權所有,保留一切權利