Linuxwilliam hill官网
登录
直播中
lotusp
10年用户
1063经验值
擅长:电源/新能源
私信
关注
[资料]
Ubuntu环境搭建
Ubuntu
环境搭建(华清远见)
tftp服务器搭建
[1]基本原理
tftp服务器最好搭建在Linux系统上面,这里是在虚拟机(ubuntu)上搭建tftp服务器,搭建步骤如下:
1.确认虚拟机和外网连通
2.安装tftp服务软件并启动
3.配置tftp服务软件权限和参数
4.本机验证tftp服务
[2]具体过程
1.确认网络连通
在ubuntu上,安装软件需要网络的支持,所以安装软件前必须保证已经联网,且DNS配置正确。检测命令如下:
ubuntu@ubuntu:~/work$ping –c4
www.baidu.com
PING
www.a.shifen.com(119.75.218.77) 56(84) bytes of data.
64 bytesfrom 119.75.218.77: icmp_req=1 ttl=128
ti
me=68.1 ms
表示网络和DNS已经配置正确
2.安装tftp服务软件
在ubuntu上,执行如下命令:
ubuntu@ubuntu:~/work$sudo apt-get install tftp-hpa tftpd-hpa
tftp-hpa是客户端,tftpd-hpa是服务器
3.确认tftp服务运行
在ubuntu系统下,执行如下命令:
ubuntu@ubuntu:~/work$ps -ef | grep tftp
root 1019 1 0 06:58? 00:00:00 /usr/***in/in.tftpd--listen --user tftp --address 0.0.0.0:69--secure /home/ubuntu/work/tftpboot
ubuntu 10476 2841 0 17:29 pts/0 00:00:00 grep--color=auto tftp
/usr/***in/in.tftpd程序进程存在表示tftp服务运行成功。
4.修改tftp服务根目录
如果想修改tftp服务的根目录,运行如下命令:
ubuntu@ubuntu:~/work$sudo vim /etc/default/tftpd-hpa
会出现如下界面:
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-c -s -l"
修改TFTP_DIRECTORY="/tftpboot"这一行中引号中的路径,然后杀掉tftpd服务进程,命令如下:
ubuntu@ubuntu:~/work$sudo kill -9 `ps -ef | grep tftpd | grep root | awk '{print $2}'`
或
ubuntu@ubuntu:~/work$sudo service tftpd-hpa restart
ubuntu会自动重启服务,服务启动后,根路径设置就生效了。
5.验证tftp服务配置成功
放置uImage文件到tftp服务根目录,然后运行tftp命令,过程如下:
ubuntu@ubuntu:~/work$ls /home/ubuntu/work/tftpboot/uImage
/home/ubuntu/work/tftpboot/uImage
ubuntu@ubuntu:~/work$tftp 127.0.0.1
tftp>get uImage
tftp>quit
ubuntu@ubuntu:~/work$ls uImage
uImage
nfs服务器搭建
nfs是网络文件系统,它可以将服务器上的一个文件夹挂载到本机作为一个文件系统。利用这个工具可以直接利用服务器上面的文件,而不用先下载到本地,给调试程序和文件系统带来极大的便利。
[1]基本原理
nfs服务器最好搭建在Linux系统上面,这里是在虚拟机(ubuntu)上搭建nfs服务器,搭建步骤如下:
1.确认虚拟机和外网连通
2.安装nfs服务软件并启动
3.配置nfs服务软件权限和参数
4.本机验证nfs服务
[2]具体过程
使用nfs前需要在服务器端搭建nfs服务环境:
[1]安装端口映射程序
ubuntu@ubuntu:~/work/rootfs$sudo apt-get install portmap
[2]安装nfs服务程序及客户端程序
ubuntu@ubuntu:~/work/rootfs$sudo apt-get install nfs-kernel-server nfs-common
注意:安装过程中可能会,提示/etc/exports.d目录不存在,如果不存在则新建,命令如下:
ubuntu@ubuntu:~/work/rootfs$sudo mkdir /etc/exports.d
确保exportfs安装成功
[3]导出nfs文件系统
1.配置nfs文件系统
打开/etc/exports文件,修改如下行:
/source/rootfs*(rw,sync,no_root_squash)
“/source/rootfs”是存放nfs文件系统的路径;“*”表示在所有的网段都可以共享;“rw”表示nfs文件系统允许读写;“sync”表示修改都会同步到nfs服务端,否则只是会暂存在本地内存;
运行下面的命令,修改权限:
ubuntu
@ubuntu:~/work/rootfs$chmod 777 -R /source/rootfs
2.导出
ubuntu@ubuntu:~/work/rootfs$sudo exportfs –av
注意:这步一定要成功,否则下面mount会失败
[4]配置权限
1.修改/etc/hosts.deny文件中对应的行如下:
portmap:ALL
lockd: ALL
mountd: ALL
rquotad:ALL
statd: ALL
文件/etc/hosts.deny用于禁止访问本机的IP地址段
2.修改/etc/hosts.allow文件中对应的行如下:
portmap:192.168.1.0/255.255.255.0
lockd:192.168.1.0/255.255.255.0
rquotad:192.168.1.0/255.255.255.0
mountd:192.168.1.0/255.255.255.0
statd:192.168.1.0/255.255.255.0
文件/etc/hosts.allow用于允许访问本机的IP地址段,一定要把客户端所在的网段设置进去
3.重启服务
ubuntu@ubuntu:~/work/rootfs$sudo service portmap restart
ubuntu@ubuntu:~/work/rootfs$sudo /etc/init.d/nfs-kernel-server restart
[5] 测试
1.新建客户端目录
ubuntu@ubuntu:~/work/rootfs$mkdir /srv/nfsclient
ubuntu@ubuntu:~/work/rootfs$ls /srv/nfsclient -ld
drwxr-xr-x2 root root 4096 2012-01-10 20:43 /srv/nfsclient
2.
挂载到nfs服务器
ubuntu@ubuntu:~/work/rootfs$sudo mount -t nfs 127.0.0.1:/home/ubuntu/work/rootfs/rootfs /srv/nfsclient
[sudo]password for ubuntu:
3.确认挂载成功
ubuntu@ubuntu:~/work/rootfs$df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 19609276 7010752 11602428 38% /
udev 506028 4 506024 1% /dev
tmpfs 205216 1396 203820 1% /run
none 5120 0 5120 0% /run/lock
none 513040 180 512860 1% /run/shm
/dev/sdb1 61926396 3774704 55006016 7% /home/ubuntu/work
127.0.0.1:
/source/rootfs
61926400 3774592 55006080 7% /srv/nfsclient
ubuntu@ubuntu:~/work/rootfs$
确认粗体行一定要存在,这样表示nfs服务器搭建成功
samba环境搭建
samba服务器用于把Linux下的文件夹以windows共享的方式,共享给主机或局域网内其他的主机。
[1] 基本原理
samba服务器最好搭建在Linux系统上面,这里是在虚拟机(ubuntu)上搭建samba服务器,搭建步骤如下:
1.确认虚拟机和外网连通
2.安装samba服务软件并启动
3.配置共享目录
4.创建samba用户
5.测试samba服务
[2]具体过程
1.确认网络连通
在ubuntu上,安装软件需要网络的支持,所以安装软件前必须保证已经联网,且DNS配置正确。检测命令如下:
ubuntu@ubuntu:~/work$ping –c4
www.baidu.com
PING
www.a.shifen.com(119.75.218.77) 56(84) bytes of data.
64 bytesfrom 119.75.218.77: icmp_req=1 ttl=128 time=68.1 ms
表示网络和DNS已经配置正确
2.安装samba服务软件
ubuntu@ubuntu:~/work/rootfs$sudo apt-get install samba smbfs
3.配置共享目录
打开本目录下的smb.conf,配置最后5行如下:
[ubuntu]
path=/home/ubuntu
validusers=ubuntu
public=yes
writable=yes
ubuntu是当前共享目录的用户,这里是将ubuntu的用户目录共享给主机。配置完成后拷贝到/etc/samba/目录下覆盖默认目录。
4.运行重启samba服务
ubuntu@ubuntu:sudoservice smbd restart
5.创建samba用户
ubuntu@ubuntu:~/work/rootfs$sudo smbpasswd -a ubuntu
创建samba用户,这里最后跟Linux用户名及密码相同,否则不便于记忆。
6.测试samba服务
在主机下用windows系统访问虚拟机共享,如下图:
回帖
(2)
512469
2014-3-28 09:41:11
学习了。。。。。。。。。。。。。。。。。。。。。。。
学习了。。。。。。。。。。。。。。。。。。。。。。。
举报
lxq_cher
2014-4-2 22:29:28
方便,所有的服务器配置都有了
方便,所有的服务器配置都有了
举报
更多回帖
rotate(-90deg);
回复
相关帖子
搭建
Windows+
Ubuntu
混合开发
环境
2022-05-11
3072
怎样去
搭建
一种基于
Ubuntu
14.04的PopMetal Android开发
环境
2022-03-10
2848
如何在PC-
ubuntu
下
搭建
一种rknn模拟
环境
呢
2022-02-14
1860
如何基于
Ubuntu
+Eclipse+GDB+OpenOCD+STlink
搭建
STM32开发
环境
?
2022-02-08
1401
介绍lvgl在
ubuntu
的vscode上模拟
环境
的
搭建
2022-01-18
578
如何
搭建
Ubuntu
20开发
环境
?
2021-12-29
887
如何
搭建
嵌入式Linux开发
环境
2021-12-16
1455
【资料】
ubuntu
安装及嵌入式Arm-Linux开发
环境
搭建
2021-08-16
1102
PHP
环境
搭建
流程
2020-03-18
970
windows下虚拟机
ubuntu
+Qt开发
环境
搭建
的详细过程
2019-09-26
1565
发帖
登录/注册
20万+
工程师都在用,
免费
PCB检查工具
无需安装、支持浏览器和手机在线查看、实时共享
查看
点击登录
登录更多精彩功能!
英国威廉希尔公司网站
william hill官网 版块
小组
免费开发板试用
ebook
直播
搜索
登录
×
20
完善资料,
赚取积分