分类: LINUX
2011-09-16 15:49:07
DHCP
yum install dhcp
vi /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.50.0 netmask 255.255.255.0 {
option routers 192.168.50.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.1.1;
option time-offset -18000; # Eastern Standard Time
range dynamic-bootp 192.168.50.128 192.168.50.254;
default-lease-time 21600;
max-lease-time 43200;
allow booting;
allow bootp;
next-server 192.168.50.59;
filename "/pxelinux.0";
}
service dhcpd restart
chkconfig dhcpd on
TFTPSERVER
yum install tftp-server
vi /etc/xinetd.d/tftp and change disable to 'no'
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
~
service xinetd restart
SYSLINUX
yum install syslinux
cp /usr/lib/syslinux/pxelinux.0 /tftpboot
cp /usr/lib/syslinux/menu.c32 /tftpboot
cp /usr/lib/syslinux/memdisk /tftpboot
cp /usr/lib/syslinux/mboot.c32 /tftpboot
cp /usr/lib/syslinux/chain.c32 /tftpboot
准备pxe config文件
mkdir /tftpboot/pxelinux.cfg
vi /tftpboot/pxelinux.cfg/default
default menu.c32
prompt 0
timeout 300
ONTIMEOUT local
MENU TITLE PXE Menu
LABEL Pmajic
MENU LABEL Pmajic
kernel images/pmagic/bzImage
append noapic initrd=images/pmagic/initrd.gz root=/dev/ram0 init=/linuxrc ramdisk_size=100000
label Dos Bootdisk
MENU LABEL ^Dos bootdisk
kernel memdisk
append initrd=images/622c.img
LABEL CentOS 5 x86 NO KS eth0
MENU LABEL CentOS 5 x86 NO KS eth0
KERNEL images/centos/i386/5.5/vmlinuz
APPEND ks initrd=images/centos/i386/5.5/initrd.img ramdisk_size=100000 ksdevice=eth0 ip=dhcp url --url
LABEL CentOS 5 x86_64 NO KS eth0
MENU LABEL CentOS 5 x86_64 NO KS eth0
KERNEL images/centos/5/x86_64/vmlinuz
APPEND ks initrd=images/centos/5/x86_64/initrd.img ramdisk_size=100000 ksdevice=eth1 ip=dhcp url --url
实战: pxe安装centos
下载centos5.5 i386的iso
CentOS-5.5-i386-bin-DVD.torrent
准备启动文件
将光盘根目录中的images/pxeboot/下的vmlinuz and inttrd.img拷贝到
mount -o loop a.iso 挂载目录
/tftp/images/centos/5.5/i386
准备光盘镜像文件
将光盘镜像文件放到相应文件夹中
/tftpboot/images/centos/5.5/i386/
准备nfs
vi /etc/exports
/tftpboot/images/centos/5.5/i386 *(ro,sync)
exportfs -a
准备kickstart脚本
/tftpboot/images/centos/5.5/i386/ks.cfg
------------------------------------------------------------------------------
/tftpboot/images/centos/5.5/i386/ks.cfg
kickstart 文件,该文件在每次安装完成操作系统之后会保存在/root/anaconda-ks.cfg
# Kickstart file automatically generated by anaconda.
install
nfs --server=192.168.50.72 --dir=/tftpboot/images/centos/5.5/i386
lang zh_CN.UTF-8
keyboard us
skipx
text
network --device eth0 --bootproto dhcp --hostname XXX
rootpw --iscrypted $1$LCNmaMaA$gGyp9YjKMWJfrzoLJsWSI1
firewall --enabled --port=22:tcp --port=22:tcp
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="rhgb quiet"
reboot
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --drives=sda
part /boot --fstype ext3 --size=100 --ondisk=sda
part pv.100000 --size=0 --grow --ondisk=sda
volgroup VolGroup00 --pesize=32768 pv.100000
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1000 --grow --maxsize=5952
logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
%packages
@admin-tools
@base
@chinese-support
@core
@dns-server
@development-libs
@development-tools
@dialup
@editors
@ftp-server
@gnome-desktop
@games
@graphical-internet
@graphics
@legacy-network-server
@legacy-software-development
@legacy-software-support
@mail-server
@network-server
@news-server
@office
@printing
@server-cfg
@sound-and-video
@system-tools
@text-internet
@web-server
@smb-server
------------------------------------------------------------------------------
准备pxe启动配置文件
vi /tftpboot/pxelinux.cfg/default
LABEL CentOS 5 x86 KS eth0
MENU LABEL CentOS 5 x86 NO KS eth0
KERNEL images/centos/5.5/i386/vmlinuz
APPEND initrd=images/centos/5.5/i386/initrd.img ramdisk_size=100000 ksdevice=eth0 ks=nfs:192.168.50.72:/tftpboot/images/centos/5.5/i386/ks.cfg
===============================================================================
实战ubuntu11.04 pxe 安装
准备文件
上传到服务器上目录
/tftpboot/images/ubuntu/11.04
下载引导文件
http://mirrors.163.com/ubuntu/dists/natty/main/installer-i386/current/images/netboot/ubuntu-installer/i386/linux
http://mirrors.163.com/ubuntu/dists/natty/main/installer-i386/current/images/netboot/ubuntu-installer/i386/initrd.gz
修改启动菜单文件/tftpboot/pxelinux.cfg/default
kernel /tftpboot/images/ubuntu/11.04/linuz
append boot=casper only-ubiquity initrd=/tftpboot/images/ubuntu/11.04/initrd.gz netboot=nfs nfsroot=192.168.50.72:/tftpboot/imgages/ubuntu/11.04/desktop quiet splash—
TFTP一般用于向目标板下载镜像文件TFTP是用来下载远程文件的最简单网络协议,它其于UDP协议而实现。嵌入式linux的tftp开发环境包括两个方面:一是linux服务器端的tftp-server支持,二是嵌入式目标系统的tftp-client支持。因为u-boot本身内置支持tftp-client,所以嵌入式目标系统端就不用配置了。下面就详细介绍一下linux服务器端tftp-server的配置。
执行下面的命令能够看到服务是否已经启动,若已经启动则不用安装,否则需要安装下面的步骤安装tftp-server服务器。
#netstat -a|grep tftp
udp 0 0 *:tftp *:*
1. 安装tftp服务
我的系统是Fedora7,所以执行一下命令:
#yum install tftp tftp-server //Fedora下用此命令,其它系统做相应改动
在linux下,不管使用的是哪一种super-server,inetd或者xinetd,默认情况下TFTP服务是禁用的,所以要修改文件来开启服务。
根据(1)的安装方法,可以修改文件/etc/xinetd.d/tftp。主要是设置TFTP服务器的根目录,开启服务。修改后的文件如下:
service tftp
{ socket_type =dgram
protocol =udp
wait =yes
user =root
server =/usr/sbin/in.tftpd
server_args =-s /home/lqm/tftpboot -c
disable =no
per_source =11
cps =100 2
flags =IPv4
}
说明:修改项server_args= -s
3. 创建tftp根目录,启动tftp-server。
#mkdir /home/lqm/tftpboot
#chmod o+w /home/lqm/tftpboot
#service xinetd restart
停止 xinetd: [确定]
启动 xinetd: [确定]
这样,tftp-server就启动了。你可以登陆本机测试以下,命令如下:
#tftp <your-ip-address>
tftp>get
tftp>put
tftp>q
#
安装过程中出现的问题及原因
SELINUX=disabled
然后重启电脑即可
或者执行命令 system-config-securitylevel 打开 “安全级别配置”对话框,将SELinux(S)选项中 “强制” 改为“允许”。
现象三:
tftp> put ex070416.log
Error code 1: File not found
原因:
指定的文件不存在;或tftpd启动参数中没有指定-c选项,允许上传文件
现象四:
tftp> get test.log
Error code 2: Only absolute filenames allowed
原因:
在/etc/xinetd.d/tftpd中设置的server_args为/etc/default/tftpd-hpa
cat /etc/default/tftpd-hpa
#Defaults for tftpd-hpa
RUN_DAEMON="no"
OPTIONS="-s /home/tftpd -c -p -U 077 -u tftpd"
设置的时候只要将server_args=改为你自己设定的服务器文件夹就行了