pxe linux ftp ks,无人值守安装Linux之Dhcp+tftp+ks+ftp

一.适用环境:

1.需要大规模批量部署linux操作系统

2.客户端无光驱或光驱损坏,需要网络安装linux系统

3.需要隔三差五重复安装linux系统,为了减少麻烦,节约时间,提高效率。

二、原理:

在服务器端搭建DHCP、tftp、ftp服务并用kickstart配置自动安装脚本,DHCP服务用于向客户端分配IP,tftp服务用于传输bootloader文件pxelinux.0,ftp服务负责传输安装镜像文件,用kickstart配置的ks.cfg实现无人值守全自动安装。

前提:客户端网卡内置PXE芯片,现在一般网卡都支持pxe协议。

三.具体操作过程(基于RHEL)1.配Server IP为:192.168.0.20 ,安装镜像挂载到/mnt下。2.安装tftp服务 、dhcp服务和ftp服务.安装前先查看这些服务是否已安装# rpm -qa |grep tftp# rpm -qa |grep dhcp# rpm -qa |grep vsftpd未安装的进行安装#cd /mnt/RedHat/RPMS/在RHEL5中是cd /mnt/Server#rpm –ivh dhcp-*#rpm –ivh tftp-*#rpm –ivh vsftpd*3.配置启动DHCP服务#cp cp /usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample /etc/dhcpd.conf#vi /etc/dhcpd.conf添加filename "pxelinux.0";//指定bootloader文件next-server 192.168.0.20;//指定索取pxelinux.0的tftp服务器IP添加的这两行可在大括号外面,也可在里面,next-server选项可不写,但建议最好写上配置举例:ddns-update-style interim;ignore client-updates;subnet 192.168.0.0 netmask 255.255.255.0 {option routers192.168.0.1;option subnet-mask255.255.255.0;option time-offset-18000; # Eastern Standard Timerange dynamic-bootp 192.168.0.128 192.168.0.254;default-lease-time 21600;max-lease-time 43200;filename "pxelinux.0";next-server 192.168.0.20;}

#service dhcpd start//启动服务

4.复制内核相关文件到/tftpboot下#cd /tftpboot

#cp /mnt/isolinux/* ./(实际需要的是vmlinuz,initrd.img,*.msg这几个文件,但为了操作方便,我直接把isolinux目录下的文件全cp过来)

#mkdir pxelinux.cfg

#mv isolinux.cfg pxelinux.cfg/default(default配置文件的作用是告诉主机从哪里去加载操作系统内核)#cp /usr/lib/syslinux/pxelinux.0./(将启动加载文件拷到/tftpboot下)

5.修改tftp参数并启动tftp服务

# vi /etc/xinetd.d/tftp

……………………………………………………………………………………

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

}

…………………………………………………………………………………………

/tftpboot这个参数主要是指定tftp client客户端从服务器的哪个目录去加载bootloader的pxelinux.0文件。

#service xinetd restart //启动服务

或者不改tftp参数直接启动#chkconfig tftp on#service xinetd restart

6.修改/tftpboot/pxelinux.cfg/default文件

#vi /tftpboot/pxelinux.cfg/default修改第3行,第12行.

1 default linux

2 prompt 1

3 timeout10//时间调小点4 display boot.msg

5 F1 boot.msg

6 F2 options.msg

7 F3 general.msg

8 F4 param.msg

9 F5 rescue.msg

10 label linux

11 kernel vmlinuz

12 appendks=ftp://192.168.0.20/pub/ks.cfginitrd=initrd.img

13 label text……

7.安装kickstart配置ks.cfg#cd /mnt/ RedHat/RPMS/#rpm –ivh *kickstart*

#system-config-kickstart(在图形界面终端打此命令)根据需要配置ks.cfg.

ks.cfg保存到/var/ftp/pub目录下。#chmod 707 /var/ftp/pub/ks.cfg//修改ks.cfg权限

ks.cfg文件,最终配置示例如下:

#Generated by Kickstart Configurator

#platform=x86, AMD64, or Intel EM64T

#Systemlanguage

lang en_SG

#Language modules to install

langsupport zh_CN en_US --default=en_SG

#System keyboard

keyboard us

#System mouse

mouse

#Sytem timezone

timezone Asia/Shanghai

#Root password

rootpw --iscrypted $1$2qm1.E7d$/p/NGomGdh00jvBeeIyLR.

#Reboot after installation

reboot

#Install OS instead of upgrade

install

#Use NFS installation Media

url --url ftp://192.168.0.20/iso

#System bootloader configuration

bootloader --location=mbr

#Clear the Master Boot Record

zerombr yes

#Partition clearing information

clearpart --all --initlabel

#Disk partitioning information

clearpart --all --initlabel

#Disk partitioning information

part swap --size 512

part /boot --fstype ext3 --size 100

part / --fstype ext3 --size 1 --grow

#System authorization infomation

auth--useshadow--enablemd5

#Network information

network --bootproto=dhcp --device=eth0

#Firewall configuration

firewall --disabled

#XWindows configuration information

xconfig --depth=8 --resolution=640x480 --defaultdesktop=GNOME

#Package install information

%packages --resolvedeps

@ base-x//最小化安装(如果用kickstart不能选择安装包时需要手动添加)

如果是RHEL5需要手动添加一行

key --skip//跳过安装序列号

8.配置启动vsftpd服务

#mkdir /var/ftp/iso

#cp /mnt/*/var/ftp/iso(将安装镜像文件cp到/var/ftp/iso)

#service vsftpd start

9.为保证实验一次成功,将所有服务都重新启动一下

#service dhcpd restart

#service xinetd restart

#service vsftpd restart

10.在一客户端上进行测试(与server在同一局域网内).

提示:客户端在确定domain name和host name时会等几分钟时间请耐心等待

※成功标志:能顺利跳过各项设置到开始自动安装软件包代表服务器配置没问题(客户端只能有个开机动作)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值