目录
TFTP和NFS的安装与测试
一、TFTP的安装与测试
#1、使用以下命令安装tftp-hpa tftpd-hpa:
sudo apt-get update
sudo apt-get install tftp-hpa tftpd-hpa
#2、创建tftp服务端工作目录
sudo mkdir /tftpboot
#3、修改目录权限
sudo chmod -R 777 /tftpboot
#4、修改服务端配置文件--tftpd-hpa
sudo vim /etc/default/tftpd-hpa
#文件内容如下:
#RUN_DAEMON="no"
#OPTIONS="-s /tftpboot -c -p -U tftpd"
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot" //这里是tftp的工作目录
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-l -c -s"
#5、使用命令重启运行服务端
sudo service tftpd-hpa restart
#6、测试使用
cd /tftpboot
touch xxx #随便创建一个文件
vim xxx #随便输入一些内容后保存退出
cd ~
tftp 127.0.0.1 #或者使用tftp localhost
tftp>get xxx
tftp>q #输入q退出
cat xxx #查看xxx内容为上面输入的内容则表示安装成功,否则安装过程有问题
二、NFS的安装与测试
#1、使用以下命令安装nfs
sudo apt-get update
sudo apt-get install nfs-kernel-server
#2、编辑服务端配置文件--/etc/exports
sudo vim /etc/exports
#在其内添加一行,内容如下:
/home/ubuntu/nfs/rootfs *(rw,sync,no_root_squash,no_subtree_check)
注意:
我这里的家目录为/home/ubuntu,家目录的名字可能不同,需要按实际修改。
#3、创建挂载点目录并修改挂载点目录的访问权限
sudo mkdir ~/nfs/rootfs -p
sudo chmod 777 ~/nfs/rootfs
#4、启动NFS服务端(每一次修改/etc/exports都要重启nfs)
sudo service nfs-kernel-server restart
sudo service rpcbind restart
#5、验证安装是否正确 #在~/nfs/rootfs下创建一个空文件
cd ~/nfs/rootfs
touch test
sudo mount localhost:/home/ubuntu/nfs/rootfs /mnt
注意:
这里的家目录/home/ubuntu要按自己机器的实际家目录进行修改。
#localhost(表示ubuntu主机) #ubuntu上NFS服务器上被挂目录的绝对路径/home/ubuntu/nfs/rootfs #/mnt(挂载点)
ls -l /mnt #如果有test的话就说明ok了
sudo umount /mnt #卸掉挂载的目录