# NFS掛載 ##### **NFS Server** 1.APT更新 `apt update` 2.安裝NFS伺服器軟體,跑完按y `apt install nfs-kernel-server` 3.系統開機便啟動NFS Server `systemctl enable nfs-server` 4.查看NFS的執行狀態 `systemctl status nfs-server`  5.建置1個共享目錄,我們在root下建立1個share目錄 `mkdir -p /share` 6.將目錄給定用戶和群組,並設定權限為皆可 ``` chown -R nobody:nogroup /share chmod 777 /share ```  7.輸入`ip a`,在eth0的地方可以找到台虛擬機的IP,先記下來。 8.設定目錄可由NFS Server提供出去 `vi /etc/exports` 再按a進入編輯模式。 最後一行加入`/share 172.x.x.x/24(rw,sync,no_subtree_check)` ,IP請輸入剛剛查到的IP,再按Esc,再輸入`:wq!`存檔離開。  9.讓NFS設定分享目錄生效 `exportfs -a` 10.重啟NFS Server `systemctl restart nfs-server` 11.檢查NFS Server上的共享目錄 `exportfs -v` ##### **NFS Client** 1.先做APT的更新 `apt update` 2.安裝NFS Client軟體,跑完按y `apt install nfs-common` 3.建立掛載NFS目錄的掛載點 `mkdir -p /mnt/data` 4.將NFS Server的分享目錄掛載,IP請輸入剛剛查到的IP,輸入完不能跑出錯誤訊息才是成功。 `mount 172.x.x.x:/share /mnt/data` 5.確認NFS Server的掛載,要出現類似倒數第二行的資訊才是成功。 `df -h`  6.如要系統開機後就自動掛載NFS Server分享的目錄,可 `vi /etc/fstab`再按a,於最後一行加入 `172.x.x.x:/share /mnt/data nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0` IP請輸入剛剛查到的IP,再按Esc,並輸入`:wq!`存檔離開即可。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up