KickStart + DHCP + NFS + TFTP + PXE
全自动网络安装
Linux
环境:Linux5.5(32bit)
IP:10.80.11.206
撰写人:hx10
日期:2010/7/7 hangzhou
Blog: http://hi.baidu.com/hx10
远程安装系统过程:PXE网卡启动------DHCP服务器------获得IP------从TFTP上下载pxelinux.0、
vmlinuz、initrd------启动系统------通过PXElinux去nfs下载ks.cfg文件-----跟据ks.cfg去nfs下
载RPM包及安装系统------完成安装
1. 搭建tftp,dhcpf服务器
#yum install tftp-server dhcp
#vim /etc/xinetd.d/tftp
- service tftp
- {
- disable = no
- socket_type = dgram
- protocol = udp
- wait = yes
- user = root
- server = /usr/sbin/in.tftpd
- server_args = -u nobody -s /tftpboot
- per_source = 11
- cps = 100 2
- flags = IPv4
- }
需要修改2个地方
server_args = -u nobody -s /tftpboot
disable = no
#cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
#vim /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
authoritative;
allow booting;
allow bootp;
subnet 10.80.11.0 netmask 255.255.255.0
{
option routers 10.80.11.1;
option subnet-mask 255.255.255.0;
option domain-name "zjhcsoft.com";
option domain-name-servers 202.101.172.35;
range dynamic-bootp 10.80.11.220 10.80.11.240;
default-lease-time 21600;
max-lease-time 43200;
next-server 10.80.11.206;
filename "/pxelinux.0";
}
ddns-update-style interim; /*dhcp支持的dns动态更新方式*/
ignore client-updates; /*忽略客户端DNS动态更新*/
authoritative;
/*授权*/
allow booting; /*支持PXE启动*/
allow bootp; /*支持boottp*/
subnet 10.80.11.0 netmask 255.255.255.0 /*作用域*/
option routers
10.80.11.1; 网关的IP地址
range dynamic-bootp 10.80.11.220 10.80.11.250; 分配给客户端的IP地址范围
default-lease-time 21600;
/*租期,秒数*/
max-lease-time 43200;
/*最大租期,秒数*/
next-server 10.80.11.206;
/*TFTPServer的IP*/
filename "/pxelinux.0";
/*Bootstrap文件*/
2.配置支持PXE
mkdir /disk
mount /dev/cdrom /media
cp �Crf /media/* /disk
vi /etc/exports
/disk *(ro,sync)
启动服务
service dhcpd start
service netfs start
service portmap start
service nfs start
service nfslock start
service nfslock start
mkdir /tftpboot
/*tftp的根目录
cp /usr/lib/syslinux/pxelinux.0 /tftpboot
cp /mnt/cdrom/images/pxeboot/initrd.img /tftpboot
cp /mnt/cdrom/images/pxeboot/vmlinux /tftpboot
cp /mnt/cdrom/isolinux/*.msg /tftpboot
mkdir /tftpboot/pxelinux.cfg
vim /tftpboot/pxelinux.cfg/default
- default linux
- prompt 1
- timeout 10
- display boot.msg
- F1 boot.msg
- F2 options.msg
- F3 general.msg
- F4 param.msg
- F5 rescue.msg
- label linux
- kernel vmlinuz
- append ks=nfs:10.80.11.206:/disk/ks.cfg initrdinitrd=initrd.img
- label text
- kernel vmlinuz
- append initrdinitrd=initrd.img text
- label ks
- kernel vmlinuz
- append ks initrdinitrd=initrd.img
- label local
- localboot 1
- label memtest86
- kernel memtest
- append �C
设置timeout 10 /*超时时间为10S */
3.生成ks.cfg安装配置文件
#yum install system-config-kickstart
#system-config-kickstart
图片太多,省略,参考下面的配置文件 :)
#cp /root/ks.cfg /disk/
#vim /disk/ks.cfg
- #platform=x86, AMD64, or Intel EM64T
- # System authorization information
- auth --useshadow --enablemd5
- #Skip Installation Number
key --skip
- # System bootloader configuration
- bootloader --location=mbr
- # Clear the Master Boot Record
- zerombr
- # Partition clearing information
- clearpart --all --initlabel
- # Use text mode install
- text
- # Firewall configuration
- firewall --disabled
- # Run the Setup Agent on first boot
- firstboot --disable
- # System keyboard
- keyboard us
- # System language
- lang en_US
- # Installation logging level
- logging --level=info
- # Use NFS installation media
- nfs --server=10.80.11.206 --dir=/disk
- # Network information
- network --bootproto=dhcp --device=eth0 --onboot=on
- # Reboot after installation
- reboot
- #Root password
- rootpw --iscrypted $1$LnetDcQO$MA84zAEokdi/GCEElcqI20
-
- # SELinux configuration
- selinux --disabled
- # System timezone
- timezone Asia/Shanghai
- # Install OS instead of upgrade
- install
- # X Window System configuration information
- xconfig --defaultdesktop=GNOME --depth=32 --resolution=1024x768 --startxonboot
- # Disk partitioning information
- part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
- part swap --bytes-per-inode=4096 --fstype="swap" --size=4000
- part / --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
-
- %packages
- @dialup
- @base
- @gnome-desktop
- @development-tools
- @chinese-support
- @base-x
- @admin-tools
- @legacy-software-development
- @legacy-software-support
- @editors
- @java
该文件如果从上面kickstart生成,不需要修改
clearpart --all �Cinitlabel
#如果ks.cfg脚本中不添加该语句,将不能实现自动化安装
nfs --server=NFS服务器的位置 --dir=光盘的位置 或 系统安装文件存放的位置
network --device eth0 --bootproto dhcp(使用DHCP来实现自动分配IP地址)
我们再开启一台客户机进行测试,按F12选择PXE安装方式进行安装,如果出现要求输入
Would you like to enter an installation number的对话框,要求输入Linux5的序列号,
直接选择skip跳过去就可以了,安装完成后,网卡地址修改成固定IP,会发现无法ping通域名,重启系统就可以了。