# (七)NFS server設定
## Server部分
```
$ yum -y install nfs-utils
```
[創建NFS server資料夾]
```
$ mkdir /rhome
```
```
$ mkdir /rhome/ldapuser3
```
[編輯nfs檔案]
```
$ vim /etc/exports
```
```dockerfile=
#執行結果(加入最後一行)
/myshare 172.24.10.0/24(ro) localhost(rw) *.linux.shu(ro,sync)
/myshare *(rw,no_root_squash)
/home/public 172.24.10.0/24(rw) *(ro)
/rhome kvm8.chuck.im.shu(rw,sync)
```


[重新掛載資料夾]
```
$ exportfs -arv
```
```dockerfile=
#執行結果(會出現以下)
exporting kvm8.chuck.im.shu:/rhome
```
## Client部分
### [前置作業]
```
$ showmount -e chuck.im.shu
```
為了確認Server有沒有提供Client下載
```dockerfile=
#執行結果
Export list for chuck.im.shu:
/rhome kvm8.chuck.im.shu
```
```
$ yum -y install autofs
```
```
$ systemctl start autofs
```
```
$ systemctl enable autofs
```
[編輯auto.master]
```
$ vim /etc/auto.master
```
```dockerfile=
#執行結果(加入第9行)
# Sample auto.master file
# This is a 'master' automounter map and it has the following format:
# mount-point [map-type[,format]:]map [options]
# For details of the format look at auto.master(5).
#
/misc /etc/auto.misc
/rhome /etc/auto.shu
#
# NOTE: mounts done from a hosts map will be mounted with the
# "nosuid" and "nodev" options unless the "suid" and "dev"
# options are explicitly given.
#
/net -hosts
#
# Include /etc/auto.master.d/*.autofs
# The included files must conform to the format of this file.
#
+dir:/etc/auto.master.d
#
# If you have fedfs set up and the related binaries, either
# built as part of autofs or installed from another package,
# uncomment this line to use the fedfs program map to access
# your fedfs mounts.
#/nfs4 /usr/sbin/fedfs-map-nfs4 nobind
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
+auto.master
```
[編輯auto.shu]
```
$ vim /etc/auto.shu
```
```dockerfile=
#執行結果
* chuck.im.shu:/rhome/&
```
[創建使用者&資料夾]
```
$ mkdir /rhome
```
```
$ useradd -d /rhome/ldapuser3 ldapuser3
```
[檢查]
```
$ su – ldapuser3
```
```
$ df -h
```
```dockerfile=
#執行結果
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.5M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/cs-root 44G 3.5G 41G 8% /
/dev/sda1 1014M 202M 813M 20% /boot
tmpfs 374M 0 374M 0% /run/user/0
chuck.im.shu:/rhome/ldapuser3 46G 16G 30G 34% /rhome/ldapuser3
```
:::warning
出現上面第10行即成功!
:::