嵌入式Linux中tftp和nfs的笔记

来源:互联网 发布:萨尔 知乎 编辑:程序博客网 时间:2024/05/16 04:41

一、tftp

我用的ubuntu14.04已经安装好tftp服务,这里记录下网上的安装方法:
1、服务器安装tftp,
apt-get install tftpd-hpa, tftp-hpa
我没有安装xinetd,能够成功从服务器下载文件到开发板。
2、配置TFTP服务器:

# /etc/default/tftpd-hpaTFTP_USERNAME="tftp"TFTP_DIRECTORY="/root/hi3518/tftpboot"  #服务器端的tftp目录TFTP_ADDRESS="0.0.0.0:69"#TFTP_OPTIONS="--secure"  TFTP_OPTIONS="-l -c -s"

3、重启tftp服务service tftpd-hpa restart

看看服务是否开启
netstat -a | grep tftp
显示结果为
udp 0 0 :tftp :*
表明服务已经开启,就表明tftp配置成功了。
4、在服务器端测试tftp:
tftp
get “filename”
但我这步没有成功。

下面是在开发板上测试tftp
“需要注意的的是设置开发板的serverip与服务器的ip设置一样”
“关闭防火墙”
“开发板在编译内核时应该把tftp选中,编译进内核中”
1、在开发板进入Linux系统后,busybox中的tftp命令为:

# tftpBusyBox v1.16.1 (2015-04-01 19:35:12 HKT) multi-call binary.Usage: tftp [OPTIONS] HOST [PORT]Transfer a file from/to tftp serverOptions:        -l FILE Local FILE (本地文件)        -r FILE Remote FILE (远程服务器上tftp目录下的文件)        -g      Get file  (下载文件)        -p      Put file  (上传文件到服务器)        -b SIZE Transfer blocks of SIZE octets# 

2、下载文件到当前目录tftp -g -r

# lshello    hello.c  world.c# rm hello   # lshello.c  world.c# rm hello.c# rm world.c# ls# tftp -g -r hello.c 192.168.1.105hello.c              100% |**************************|   512  --:--:-- ETA# cat hello.c#include<stdio.h>main(){  printf("hello\r\n");}# tftp -g -r hello 192.168.1.105hello                100% |*************************|  5120  --:--:-- ETA# ./hello-sh: ./hello: Permission denied# ls -l hello-rw-r--r--    1 root     root          4681 Jan  1 00:13 hello# chmod 777 hello# ./hellohello# 

3、uboot中也带有tftp服务,其命令格式与busybox中的不一样
在uboot命令下tftp下载服务器文件到ram中的确定的地址
mw.b 82000000 ff 100000 (擦除一定空间大小)
tftp 0x82000000 (下载文件到此地址中)

这样可方便的下载编译好的内核和文件系统,如果在Windows系统下用tftp需要tftpd32软件,把在Linux系统中编译好的文件复制到Windows下,比较麻烦。

二、nfs

1、服务器端nfs的配置,网上很多
配置文件:etc目录下的exports文件,最后面添加下面一句:
/root/hi3518/nfs *(insecure,rw,sync,no_root_squash)
前面的目录自己设置,*表示所有ip都可以访问这个目录,若要指定Ip可以这样写
/root/hi3518/nfs 192.168.1.*(insecure,rw,sync,no_root_squash)
开启nfs
/etc/init.d/portmap start //用service portmap stasrt也可以
/etc/init.d/nfs start 或者service nfs start也可以

nfs挂载有两种,一是把服务器端的完整的文件系统作为开发板的跟文件系统挂载,
参考嵌入式linux之NFS启动根文件系统
二是把服务器nfs目录挂载在开发板上的一个目录上。
linux nfs配置

# lsnfs   tftp# cd nfs# cd ..# mount -t nfs -o nolock 192.168.1.105:/root/hi3518/nfs nfs# cd nfs# lshello        hello.c      ircut        ko           redled       sample_venc# cd ..# lsnfs   tftp# umount -t nfs 192.168.1.105:/root/hi3518/nfsumount: can't umount 192.168.1.105:/root/hi3518/nfs: No such file or directory# lsnfs   tftp# cd nfs# ls# 
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 宝宝吃了护臀膏怎么办 八字五行同类强怎么办? 重装系统出现两个系统盘怎么办 看视频手机发烫怎么办 dhcp获取ip失败怎么办 苹果笔记本打不出数字怎么办 系统盘读不出来怎么办 waifai密码忘了怎么办 window xp忘记密码怎么办 winxp密码忘了怎么办 xp电脑密码忘记怎么办 xp桌面图标有阴影怎么办 联想电脑忘记登录密码怎么办 xp系统忘掉密码怎么办 xp密码忘记了怎么办 电脑忘记开机密码怎么办 注销了win7用户名怎么办 xp启动后黑屏怎么办 开机要按esc怎么办 excel产品激活失败怎么办 米粉卡激活失败怎么办 电脑死机ppt保存怎么办 电脑装系统黑屏怎么办 电脑c盘无法访问怎么办 d盘变成ntfs怎么办 系统重装卡住了怎么办 系统关机没反应怎么办 232串口打开失败怎么办 逆水寒cpu不支持怎么办 显卡被禁用了怎么办 vmvare注册错了怎么办 电脑主机未成功启动怎么办 主机未成功启动怎么办 电脑主机未能成功启动怎么办 虚拟机没有自带怎么办 错误连接为720怎么办 dns错误不能上网怎么办 家里无线用不了怎么办 磁盘c5坏了怎么办 一体机装xp蓝屏怎么办 虚拟机密码忘记了怎么办