差異處
這裏顯示兩個版本的差異處。
Both sides previous revision 前次修改 下次修改 | 前次修改 | ||
nfs [2017/01/04 01:01] 127.0.0.1 |
nfs [2018/02/20 11:50] (目前版本) jz |
||
---|---|---|---|
行 1: | 行 1: | ||
- | ====== NFS ====== | + | ======= NFS ======= |
+ | |||
+ | ====== Server ====== | ||
===== exports ===== | ===== exports ===== | ||
- | ''/etc/exports'' | + | create folder for exporting |
+ | <code> | ||
+ | mkdir -p /home/nfs/public /home/nfs/private | ||
+ | </code> | ||
+ | vi ''/etc/exports'' | ||
<code> | <code> | ||
- | /usr/home/public 140.116.82.0/24 140.116.245.0/24 140.116.246.0/24 -maproot=root | + | /home/nfs/public -maproot=root -network=140.116.245.193/26 |
- | /usr/home/private -ro 140.116.82.0/24 140.116.245.0/24 140.116.246.0/24 -maproot=root | + | /home/nfs/private -maproot=root -ro -network=140.116.245.193/26 |
</code> | </code> | ||
- | if exports is edited, use ''service mountd reload'' to reload | + | everytime exports is edited, use ''service mountd reload'' to reload |
+ | |||
+ | |||
+ | if ufs is used, without adding new disk, bind folder to folder like so: | ||
+ | <code> | ||
+ | mkdir -p /var/nfs/public | ||
+ | mkdir -p /var/nfs/private | ||
+ | vi /etc/fstab | ||
+ | </code> | ||
+ | |||
+ | add following content to fstab, and remount by doing ''mount -a'' | ||
+ | <code> | ||
+ | /var/nfs/public /usr/home/nfs/public nullfs rw 0 0 | ||
+ | /var/nfs/private /usr/home/nfs/private nullfs rw 0 0 | ||
+ | </code> | ||
+ | |||
+ | |||
+ | |||
+ | if zfs is used, edit exports at ''/etc/zfs/exports'', | ||
+ | the exported path needs to be zfs dataset. | ||
+ | <code> | ||
+ | zfs create zroot/usr/home/nfs | ||
+ | zfs create zroot/usr/home/nfs/public | ||
+ | zfs create zroot/usr/home/nfs/private | ||
+ | </code> | ||
==== service config ==== | ==== service config ==== | ||
行 23: | 行 53: | ||
==== start service ==== | ==== start service ==== | ||
+ | |||
start nfs server | start nfs server | ||
<code> | <code> | ||
行 28: | 行 59: | ||
</code> | </code> | ||
+ | ====== Client ====== | ||
+ | |||
+ | ===== Service config ===== | ||
+ | <code> | ||
+ | sysrc nfs_client_enable="YES" | ||
+ | </code> | ||
+ | |||
+ | ==== Start NFS client ==== | ||
+ | |||
+ | <code> | ||
+ | service nfsclient start | ||
+ | </code> | ||
+ | |||
+ | ===== Mount on startup ===== | ||
+ | |||
+ | add following content into ''/etc/fstab'' | ||
+ | <code> | ||
+ | # nfs | ||
+ | 10.0.15.31:/home/nfs/public /home/nfs/public nfs rw,vers=3,proto=tcp 0 0 | ||
+ | 10.0.15.31:/home/nfs/private /home/nfs/private nfs rw,vers=3,proto=tcp 0 0 | ||
+ | </code> | ||
+ | |||
+ | create directory to be mount | ||
+ | <code bash> | ||
+ | mkdir -p /home/nfs/public /home/nfs/private | ||
+ | </code> | ||
+ | |||
+ | |||
+ | ===== Showmount ===== | ||
+ | <code> | ||
+ | showmount <servername> -e | ||
+ | </code> | ||