配置 tftp 服務的步驟:
1.若/etc/xinetd.d/下存在 tftp,執行下列操作
1)關閉 xinetd 服務
$sudo service xinetd stop 2)刪除 tftp 文件
$sudo rm /etc/xinetd.d/tftp
3) 啟動 xinetd 服務
$sudo service xinetd start
2.安裝 tftp 客戶端和服務器端
$sudo apt-get install tftp-hpa
$sudo apt-get install tftpd-hpa
3. 修改 tftpd-hpa 配置文件
$vim /etc/default/tftpd-hpa
修改 “/var/lib/tftpboot” 為 “/tftpboot”
修改 "--secure" 為 "--secure -c" 允許上傳新文件
4.若/tftpboot 不存在,創建該目錄 $sudo mkdir /tftpboot
$sudo chmod 777 /tftpboot
5.重啟 tftpd-hpa 服務
$sudo service tftpd-hpa restart
若服務重啟成功,能查看到相應的進程
$ps -ef |grep in.tftpd
至此 tftp 服務已經安裝完成了,下面可以對其進行一下測試。(假設在當前目錄下有一個測試文件 test.txt)
$tftp 127.0.0.1
tftp> put test.txt
Sent 1018 bytes in 0.0 seconds
tftp> get test.txt
Received 1018 bytes in 0.1 seconds
tftp> quit
$
通過 get 命令,可以把當前目錄下的 test.txt 文件,通過 tftp 上傳到它的服務文件目錄。這時,在/tftpboot 下面會出現 test.txt 文件。通過 put 命令,可以從/tftpboot 下,下載 test.txt 文件。這樣就驗證了 tftp 服務配置的正確性。當文件上傳與下載結束后,可以通過 quit 命令退出。
在 ubuntu 下安裝、配置 nfs 服務的步驟如下:
1、安裝 nfs
Ubuntu 上默認是沒有安裝 nfs 服務器的,因此我們首先安裝 nfs 服務器端: $sudo apt-get install nfs-kernel-server
2、配置/etc/exports
nfs 允許掛載的目錄及權限在文件/etc/exports 中進行了定義。
例如,我們要將根目錄下的 rootfs 目錄共享出來,那么我們需要在/etc/exports 文件末尾添加如下一行:/rootfs *(rw,sync,no_root_squash)
其中:/rootfs 是要共享的目錄,*代表允許所有的網絡段訪問,rw 是可讀寫權限,sync 是資料同步寫入內存和硬盤,no_root_squash 是 nfs 客戶端分享目錄使用者的權限,如果客戶端使用的是 root 用戶,那么對于該共享目錄而言,該客戶端就具有 root 權限。其它 nfs 常用的參數有:
ro 只讀訪問
rw 讀寫訪問 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 和上面相對,不檢查父目錄權限
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
3、重啟服務
$sudo /etc/init.d/portmap restart
$sudo /etc/init.d/nfs-kernel-server restart
4、測試 nfs
此時可以運行以下命令來顯示一下共享出來的目錄:
$showmount -e
或者可以使用以下命令把它掛載在本地磁盤上,例如將/rootfs 掛載到/mnt 下:
$ sudo mount -t nfs localhost:/rootfs /mnt
可以運行 df 命令查看是否掛載成功。查看后可以使用以下命令卸載:
$ sudo umount /mnt