【背景】
折腾:
【记录】尝试用QEMU模拟ARM开发板去加载并运行Uboot,kernel,rootfs
期间,需要在Ubuntu下为QEMU安装一个Open TFTP Server。
【折腾过程】
1.去参考教程:
下载
http://cdnetworks-kr-1.dl.sourceforge.net/project/tftp-server/tftp%20server%20multithreaded/opentftpmtV1.63.tar.gz
结果地址已失效:
crifan@ubuntu:opentftp$ wget http://cdnetworks-kr-1.dl.sourceforge.net/project/tftp-server/tftp%20server%20multithreaded/opentftpmtV1.63.tar.gz --2013-08-16 01:35:14-- http://cdnetworks-kr-1.dl.sourceforge.net/project/tftp-server/tftp%20server%20multithreaded/opentftpmtV1.63.tar.gz Resolving cdnetworks-kr-1.dl.sourceforge.net (cdnetworks-kr-1.dl.sourceforge.net)... 202.102.110.204 Connecting to cdnetworks-kr-1.dl.sourceforge.net (cdnetworks-kr-1.dl.sourceforge.net)|202.102.110.204|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 686 [text/html] Saving to: ‘opentftpmtV1.63.tar.gz’ 100%[==================================================================>] 686 --.-K/s in 0s 2013-08-16 01:35:14 (72.7 MB/s) - ‘opentftpmtV1.63.tar.gz’ saved [686/686] crifan@ubuntu:opentftp$ ls opentftpmtV1.63.tar.gz crifan@ubuntu:opentftp$ tar xf opentftpmtV1.63.tar.gz gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now crifan@ubuntu:opentftp$ tar xzf opentftpmtV1.63.tar.gz gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now crifan@ubuntu:opentftp$ tar xvzf opentftpmtV1.63.tar.gz gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now crifan@ubuntu:opentftp$
2.然后去找到sourceforge的地址(注意是multithreaded):
http://sourceforge.net/projects/tftp-server/files/tftp%20server%20multithreaded/
去下载对应的:
得到后,解压:
crifan@ubuntu:opentftp$ ls opentftpmtV1.63.tar.gz opentftpmtV1.65.tar.gz crifan@ubuntu:opentftp$ tar xf opentftpmtV1.65.tar.gz crifan@ubuntu:opentftp$ ls opentftp opentftpmtV1.63.tar.gz opentftpmtV1.65.tar.gz crifan@ubuntu:opentftp$ cd opentftp/ crifan@ubuntu:opentftp$ ls LICENSE opentftpd opentftpd.cpp opentftpd.h opentftp.ini rc.opentftp README crifan@ubuntu:opentftp$
3.然后移动到opt下:
crifan@ubuntu:opentftp$ mv opentftp/ /opt/ crifan@ubuntu:opentftp$ cd /opt/opentftp/ crifan@ubuntu:opentftp$ ls LICENSE opentftpd opentftpd.cpp opentftpd.h opentftp.ini rc.opentftp README crifan@ubuntu:opentftp$
4.编译配置文件opentftpd.ini,加上HOME的路径后为:
#This file stores configuration settings. #Anything starting with punctuation would be comment #comment ' should be removed in front of sample values if used/changed #IMPORTANT WARNING Never Edit this file using Windows Editor [LISTEN-ON] #if you have more than one NIC card on your server, you #can specify which cards/ports will listen TFTP requests #Specify the Interfaces you would like server to listen #Upto 8 interfaces can be specified. #default listening port is 69, but can be overridden here. #listening on ports less than 1024 needs root account to #start the server but can switch to another user while #running (please see username under [TFTP-OPTIONS] section. #You can also listen on 0.0.0.0, which will amount to #listening on all interfaces on single socket. If you do #not specify any interface, it will automatically detect #all interfaces.and would listen individually on these #interfaces. Also if the system is running under root #(please see username under [TFTP-OPTIONS] section), then #server will also dynamically detect changes in interfaces. '0.0.0.0 '128.254.185.131 '192.168.0.40:69 '127.0.0.1:3000 [HOME] #You should specify home directory(s) here #You can specify one directory as home #directory, from where files will be served or #deposited like:- '/home/me/firmware/ #If no home directory is specified default is the #home directory of username (see [TFTP OPTIONS]) #Alternatively if you want to specify multiple #home directories, you need to use aliases #like:- 'routers=/hda1/RouterImages/Images 'boot=/mnt/pc1/PXEBoot/Images 'installs=/hda5/installs #add home directory for tftp /opt/versatilepb/kernel/ [LOGGING] #Logging will be done only if run as Service. #LogLevels can be set as None, Errors or All #Log file need to be specified at command line. #Log file name should include %Y%m%d, %Y will be replaced #by Current Year, %m by current month and %d by current year. #For example #/opt/dualserver/dualserver -l/opt/dualserver/log/dualserver%Y%m%d.log 'None 'Errors 'All [ALLOWED-CLIENTS] #These are permitted clients for TFTP Access. #Hosts having IP address within these ip ranges #only will be responded to DNS requests. #32 hosts or 32 ranges can be specified. #If none is specified, then all are allowed '192.168.0.1-192.168.0.254 '10.0.0.1-10.255.255.254 '33.67.8.123 [TFTP-OPTIONS] #First option is username (login), this is the user, who #will be owner of process, the process can be started as #privileged user and after opening privileged ports, #would run as this user. This user would be owner #of new files put to server. When overwriting files, #this user should have write access and for reading #files, this user should have read access to the files. 'username=myname #Next option is server port range on which tftpserver #would respond from, if you have firewall #issues, you may like to restrict this #range. default is any free port #do not use reserve ports less than 1024 #The Multithreaded TFTP Server listens the #requests on port 69 but responds on any free #port within these ranges, these are server #ports not client ports, client can use any port #if there is a fire wall issue, it should be #opened for server ip for these ports. 'port-range=30000-30010 #Next is default timeout per interval #if not overridden by client #min is 1, max can be 255, default is 3 'timeout=3 #Next is Thread Pool Size #value of 0 means there is no thread pool #threads will be created just in time and #killed after serving requests. #if simultaneous request are more than #thread pool size, extra threads will be #created and killed after serving requests #but ready threads will never be less than this value #min is 0, max can be 100 ThreadPoolSize=1 #Next is max block size, allowed #on client request. Max is 65464 #it can be reduced if there are memory issues. #if not overridden by client #it is always 512 'blksize=65464 #Next are the file operation permissions #Clients can only read files if read is #set to Y, default is Y 'Read=Y #Clients can only create new files if write is #set to Y, default is N 'Write=N #Clients can only overwrite existing files if #overwrite is #set to Y, default is N 'Overwrite=N
5.然后再去运行:
crifan@ubuntu:opentftp$ sudo rc.opentftp start sudo: rc.opentftp: command not found crifan@ubuntu:opentftp$ pwd /opt/opentftp crifan@ubuntu:opentftp$ ls LICENSE opentftpd opentftpd.cpp opentftpd.h opentftp.ini opentftp.ini~ rc.opentftp README crifan@ubuntu:opentftp$ ll -lha total 184K drwxr-xr-x 2 crifan crifan 4.0K Aug 16 01:44 ./ drwxr-xr-x 7 crifan root 4.0K Aug 16 01:40 ../ -rw-r--r-- 1 crifan crifan 18K Jun 22 2007 LICENSE -rwxr-xr-x 1 crifan crifan 49K Jun 13 2011 opentftpd* -rwxr--r-- 1 crifan crifan 61K Jun 11 2011 opentftpd.cpp* -rwxr--r-- 1 crifan crifan 4.5K Jun 11 2011 opentftpd.h* -rwxr--r-- 1 crifan crifan 4.1K Aug 16 01:44 opentftp.ini* -rwxr--r-- 1 crifan crifan 4.1K Jun 5 2011 opentftp.ini~* -rwxr--r-- 1 crifan crifan 1.6K Jun 4 2011 rc.opentftp* -rwxr--r-- 1 crifan crifan 9.8K Jun 5 2011 README* crifan@ubuntu:opentftp$ chomod 777 * No command 'chomod' found, did you mean: Command 'chmod' from package 'coreutils' (main) chomod: command not found crifan@ubuntu:opentftp$ chmod 777 rc.opentftp crifan@ubuntu:opentftp$ ls -lha total 184K drwxr-xr-x 2 crifan crifan 4.0K Aug 16 01:44 . drwxr-xr-x 7 crifan root 4.0K Aug 16 01:40 .. -rw-r--r-- 1 crifan crifan 18K Jun 22 2007 LICENSE -rwxr-xr-x 1 crifan crifan 49K Jun 13 2011 opentftpd -rwxr--r-- 1 crifan crifan 61K Jun 11 2011 opentftpd.cpp -rwxr--r-- 1 crifan crifan 4.5K Jun 11 2011 opentftpd.h -rwxr--r-- 1 crifan crifan 4.1K Aug 16 01:44 opentftp.ini -rwxr--r-- 1 crifan crifan 4.1K Jun 5 2011 opentftp.ini~ -rwxrwxrwx 1 crifan crifan 1.6K Jun 4 2011 rc.opentftp -rwxr--r-- 1 crifan crifan 9.8K Jun 5 2011 README crifan@ubuntu:opentftp$ sudo rc.opentftp start sudo: rc.opentftp: command not found crifan@ubuntu:opentftp$ sudo ./rc.opentftp start Open TFTP Server started crifan@ubuntu:opentftp$ sudo ./rc.opentftp status Open TFTP Server is running - Pid : 23360 crifan@ubuntu:opentftp$
6.然后想要加到启动项中去:
结果此处Ubuntu中没有找到/etc/rc.d/rc.local:
crifan@ubuntu:opentftp$ gedit /etc/ Display all 245 possibilities? (y or n) crifan@ubuntu:opentftp$ gedit /etc/rc rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/ rc6.d/ rc.local rcS.d/ crifan@ubuntu:opentftp$ gedit /etc/rc^C crifan@ubuntu:opentftp$ ls /etc/rc* -lha -rwxr-xr-x 1 root root 306 Apr 24 10:02 /etc/rc.local /etc/rc0.d: total 20K drwxr-xr-x 2 root root 4.0K Aug 11 23:43 . drwxr-xr-x 143 root root 12K Aug 15 18:38 .. lrwxrwxrwx 1 root root 29 Aug 6 19:41 K10unattended-upgrades -> ../init.d/unattended-upgrades lrwxrwxrwx 1 root root 20 Aug 6 19:41 K20kerneloops -> ../init.d/kerneloops lrwxrwxrwx 1 root root 27 Aug 6 19:41 K20speech-dispatcher -> ../init.d/speech-dispatcher lrwxrwxrwx 1 root root 23 Aug 11 23:43 K38open-vm-tools -> ../init.d/open-vm-tools -rw-r--r-- 1 root root 353 Jan 30 2013 README lrwxrwxrwx 1 root root 18 Aug 6 19:41 S20sendsigs -> ../init.d/sendsigs lrwxrwxrwx 1 root root 17 Aug 6 19:41 S30urandom -> ../init.d/urandom lrwxrwxrwx 1 root root 22 Aug 6 19:41 S31umountnfs.sh -> ../init.d/umountnfs.sh lrwxrwxrwx 1 root root 18 Aug 6 19:41 S40umountfs -> ../init.d/umountfs lrwxrwxrwx 1 root root 20 Aug 6 19:41 S60umountroot -> ../init.d/umountroot lrwxrwxrwx 1 root root 14 Aug 6 19:41 S90halt -> ../init.d/halt /etc/rc1.d: total 20K drwxr-xr-x 2 root root 4.0K Aug 11 23:43 . drwxr-xr-x 143 root root 12K Aug 15 18:38 .. lrwxrwxrwx 1 root root 22 Aug 6 19:41 K20acpi-support -> ../init.d/acpi-support lrwxrwxrwx 1 root root 20 Aug 6 19:41 K20kerneloops -> ../init.d/kerneloops lrwxrwxrwx 1 root root 15 Aug 6 19:41 K20saned -> ../init.d/saned lrwxrwxrwx 1 root root 27 Aug 6 19:41 K20speech-dispatcher -> ../init.d/speech-dispatcher lrwxrwxrwx 1 root root 23 Aug 11 23:43 K38open-vm-tools -> ../init.d/open-vm-tools -rw-r--r-- 1 root root 369 Jan 30 2013 README lrwxrwxrwx 1 root root 19 Aug 6 19:41 S30killprocs -> ../init.d/killprocs lrwxrwxrwx 1 root root 19 Aug 6 19:41 S70dns-clean -> ../init.d/dns-clean lrwxrwxrwx 1 root root 18 Aug 6 19:41 S70pppd-dns -> ../init.d/pppd-dns lrwxrwxrwx 1 root root 16 Aug 6 19:41 S90single -> ../init.d/single /etc/rc2.d: total 20K drwxr-xr-x 2 root root 4.0K Aug 11 23:43 . drwxr-xr-x 143 root root 12K Aug 15 18:38 .. -rw-r--r-- 1 root root 677 Jan 30 2013 README lrwxrwxrwx 1 root root 20 Aug 6 19:41 S20kerneloops -> ../init.d/kerneloops lrwxrwxrwx 1 root root 27 Aug 6 19:41 S20speech-dispatcher -> ../init.d/speech-dispatcher lrwxrwxrwx 1 root root 23 Aug 11 23:43 S38open-vm-tools -> ../init.d/open-vm-tools lrwxrwxrwx 1 root root 15 Aug 6 19:41 S50rsync -> ../init.d/rsync lrwxrwxrwx 1 root root 15 Aug 6 19:41 S50saned -> ../init.d/saned lrwxrwxrwx 1 root root 19 Aug 6 19:41 S70dns-clean -> ../init.d/dns-clean lrwxrwxrwx 1 root root 18 Aug 6 19:41 S70pppd-dns -> ../init.d/pppd-dns lrwxrwxrwx 1 root root 14 Aug 6 19:41 S75sudo -> ../init.d/sudo lrwxrwxrwx 1 root root 22 Aug 6 19:41 S99acpi-support -> ../init.d/acpi-support lrwxrwxrwx 1 root root 21 Aug 6 19:41 S99grub-common -> ../init.d/grub-common lrwxrwxrwx 1 root root 18 Aug 6 19:41 S99ondemand -> ../init.d/ondemand lrwxrwxrwx 1 root root 18 Aug 6 19:41 S99rc.local -> ../init.d/rc.local /etc/rc3.d: total 20K drwxr-xr-x 2 root root 4.0K Aug 11 23:43 . drwxr-xr-x 143 root root 12K Aug 15 18:38 .. -rw-r--r-- 1 root root 677 Jan 30 2013 README lrwxrwxrwx 1 root root 20 Aug 6 19:41 S20kerneloops -> ../init.d/kerneloops lrwxrwxrwx 1 root root 27 Aug 6 19:41 S20speech-dispatcher -> ../init.d/speech-dispatcher lrwxrwxrwx 1 root root 23 Aug 11 23:43 S38open-vm-tools -> ../init.d/open-vm-tools lrwxrwxrwx 1 root root 15 Aug 6 19:41 S50rsync -> ../init.d/rsync lrwxrwxrwx 1 root root 15 Aug 6 19:41 S50saned -> ../init.d/saned lrwxrwxrwx 1 root root 19 Aug 6 19:41 S70dns-clean -> ../init.d/dns-clean lrwxrwxrwx 1 root root 18 Aug 6 19:41 S70pppd-dns -> ../init.d/pppd-dns lrwxrwxrwx 1 root root 14 Aug 6 19:41 S75sudo -> ../init.d/sudo lrwxrwxrwx 1 root root 22 Aug 6 19:41 S99acpi-support -> ../init.d/acpi-support lrwxrwxrwx 1 root root 21 Aug 6 19:41 S99grub-common -> ../init.d/grub-common lrwxrwxrwx 1 root root 18 Aug 6 19:41 S99ondemand -> ../init.d/ondemand lrwxrwxrwx 1 root root 18 Aug 6 19:41 S99rc.local -> ../init.d/rc.local /etc/rc4.d: total 20K drwxr-xr-x 2 root root 4.0K Aug 11 23:43 . drwxr-xr-x 143 root root 12K Aug 15 18:38 .. -rw-r--r-- 1 root root 677 Jan 30 2013 README lrwxrwxrwx 1 root root 20 Aug 6 19:41 S20kerneloops -> ../init.d/kerneloops lrwxrwxrwx 1 root root 27 Aug 6 19:41 S20speech-dispatcher -> ../init.d/speech-dispatcher lrwxrwxrwx 1 root root 23 Aug 11 23:43 S38open-vm-tools -> ../init.d/open-vm-tools lrwxrwxrwx 1 root root 15 Aug 6 19:41 S50rsync -> ../init.d/rsync lrwxrwxrwx 1 root root 15 Aug 6 19:41 S50saned -> ../init.d/saned lrwxrwxrwx 1 root root 19 Aug 6 19:41 S70dns-clean -> ../init.d/dns-clean lrwxrwxrwx 1 root root 18 Aug 6 19:41 S70pppd-dns -> ../init.d/pppd-dns lrwxrwxrwx 1 root root 14 Aug 6 19:41 S75sudo -> ../init.d/sudo lrwxrwxrwx 1 root root 22 Aug 6 19:41 S99acpi-support -> ../init.d/acpi-support lrwxrwxrwx 1 root root 21 Aug 6 19:41 S99grub-common -> ../init.d/grub-common lrwxrwxrwx 1 root root 18 Aug 6 19:41 S99ondemand -> ../init.d/ondemand lrwxrwxrwx 1 root root 18 Aug 6 19:41 S99rc.local -> ../init.d/rc.local /etc/rc5.d: total 20K drwxr-xr-x 2 root root 4.0K Aug 11 23:43 . drwxr-xr-x 143 root root 12K Aug 15 18:38 .. -rw-r--r-- 1 root root 677 Jan 30 2013 README lrwxrwxrwx 1 root root 20 Aug 6 19:41 S20kerneloops -> ../init.d/kerneloops lrwxrwxrwx 1 root root 27 Aug 6 19:41 S20speech-dispatcher -> ../init.d/speech-dispatcher lrwxrwxrwx 1 root root 23 Aug 11 23:43 S38open-vm-tools -> ../init.d/open-vm-tools lrwxrwxrwx 1 root root 15 Aug 6 19:41 S50rsync -> ../init.d/rsync lrwxrwxrwx 1 root root 15 Aug 6 19:41 S50saned -> ../init.d/saned lrwxrwxrwx 1 root root 19 Aug 6 19:41 S70dns-clean -> ../init.d/dns-clean lrwxrwxrwx 1 root root 18 Aug 6 19:41 S70pppd-dns -> ../init.d/pppd-dns lrwxrwxrwx 1 root root 14 Aug 6 19:41 S75sudo -> ../init.d/sudo lrwxrwxrwx 1 root root 22 Aug 6 19:41 S99acpi-support -> ../init.d/acpi-support lrwxrwxrwx 1 root root 21 Aug 6 19:41 S99grub-common -> ../init.d/grub-common lrwxrwxrwx 1 root root 18 Aug 6 19:41 S99ondemand -> ../init.d/ondemand lrwxrwxrwx 1 root root 18 Aug 6 19:41 S99rc.local -> ../init.d/rc.local /etc/rc6.d: total 20K drwxr-xr-x 2 root root 4.0K Aug 11 23:43 . drwxr-xr-x 143 root root 12K Aug 15 18:38 .. lrwxrwxrwx 1 root root 29 Aug 6 19:41 K10unattended-upgrades -> ../init.d/unattended-upgrades lrwxrwxrwx 1 root root 20 Aug 6 19:41 K20kerneloops -> ../init.d/kerneloops lrwxrwxrwx 1 root root 27 Aug 6 19:41 K20speech-dispatcher -> ../init.d/speech-dispatcher lrwxrwxrwx 1 root root 23 Aug 11 23:43 K38open-vm-tools -> ../init.d/open-vm-tools -rw-r--r-- 1 root root 351 Jan 30 2013 README lrwxrwxrwx 1 root root 18 Aug 6 19:41 S20sendsigs -> ../init.d/sendsigs lrwxrwxrwx 1 root root 17 Aug 6 19:41 S30urandom -> ../init.d/urandom lrwxrwxrwx 1 root root 22 Aug 6 19:41 S31umountnfs.sh -> ../init.d/umountnfs.sh lrwxrwxrwx 1 root root 18 Aug 6 19:41 S40umountfs -> ../init.d/umountfs lrwxrwxrwx 1 root root 20 Aug 6 19:41 S60umountroot -> ../init.d/umountroot lrwxrwxrwx 1 root root 16 Aug 6 19:41 S90reboot -> ../init.d/reboot /etc/rcS.d: total 20K drwxr-xr-x 2 root root 4.0K Apr 24 10:06 . drwxr-xr-x 143 root root 12K Aug 15 18:38 .. -rw-r--r-- 1 root root 447 Jan 30 2013 README lrwxrwxrwx 1 root root 16 Aug 6 19:41 S25brltty -> ../init.d/brltty lrwxrwxrwx 1 root root 18 Aug 6 19:41 S37apparmor -> ../init.d/apparmor lrwxrwxrwx 1 root root 17 Aug 6 19:41 S55urandom -> ../init.d/urandom lrwxrwxrwx 1 root root 20 Aug 6 19:41 S70x11-common -> ../init.d/x11-common crifan@ubuntu:opentftp$
7.所以,去试试,直接修改/etc/rc.local:
改为:
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. /opt/opentftp/rc.opentftp start /opt/opentftp/rc.opentftp status exit 0
然后重启Ubuntu去试试是否可以自动运行此tftp。
结果是可以的:
crifan@ubuntu:Desktop$ /opt/ crosscompile/ crosstool-ng/ opentftp/ qemu/ versatilepb/ crifan@ubuntu:Desktop$ /opt/opentftp/ opentftpd opentftpd.h opentftp.ini~ README opentftpd.cpp opentftp.ini rc.opentftp crifan@ubuntu:Desktop$ /opt/opentftp/rc.opentftp status Open TFTP Server is running - Pid : 1515 crifan@ubuntu:Desktop$
如图:
【总结】
此处,只是下载合适的tftpopen,并且加到启动项里面。即可。