DHCP+TFTP+PXE自动网络引导Linux+NFS/FTP/HTTP Push多个Linux操作系统
原理:
1)客户端PXE网卡启动
2)从DHCP服务器获得IP
3)从TFTP服务器上下载pxelinux.0、default
4)根据配置文件default指定的vmlinuz、initrd.img启动系统内核,并下载指定的ks.cfg文件
5)跟据ks.cfg去(HTTP/FTP/NFS)服务器下载RPM包并安装系统
6)完成安装
·DHCP:
-
[root@rhel6 ~]# cat /etc/dhcp/dhcpd.conf
-
ddns-update-style none;
-
option routers 192.168.1.119;
-
option subnet-mask 255.255.255.0;
-
option domain-name "xfcy.org";
-
option domain-name-servers 192.168.1.119;
-
default-lease-time 21600;
-
max-lease-time 43200;
-
subnet 192.168.1.0 netmask 255.255.255.0 {
-
range 192.168.1.101 192.168.1.200;
-
# TFTP Server
-
filename "pxelinux.0";
-
next-server rhel6.xfcy.org;
-
host vm.xfcy.org {
-
hardware ethernet 00:0c:29:c0:a7:99;
-
fixed-address 192.168.1.19;
-
}
-
}
-
[root@rhel6 tftpboot]# /etc/init.d/dhcpd restart
-
Shutting down dhcpd: [ OK ]
-
Starting dhcpd: [ OK ]
·TFPT:
-
[root@rhel6 ~]# rpm -qa | egrep 'tftp|xinetd'
-
tftp-0.49-7.el6.x86_64
-
xinetd-2.3.14-33.el6.x86_64
-
tftp-server-0.49-7.el6.x86_64
-
[root@rhel6 ~]# cat /etc/xinetd.d/tftp
-
# default: off
-
service tftp
-
{
-
socket_type = dgram
-
protocol = udp
-
wait = yes
-
user = root
-
server = /usr/sbin/in.tftpd
-
server_args = -s /var/lib/tftpboot
-
disable = no
-
per_source = 11
-
cps = 100 2
-
flags = IPv4
-
}
-
[root@rhel6 ~]# chkconfig xinetd on
-
[root@rhel6 ~]# /etc/init.d/xinetd restart
-
Stopping xinetd: [ OK ]
-
Starting xinetd: [ OK ]
-
[root@rhel6 ~]# netstat -lnup | grep :69
-
udp 0 0 0.0.0.0:69 0.0.0.0:* 2751/xinetd
-
[root@rhel6 ~]# yum -y install syslinux
-
[root@rhel6 ~]# mkdir -p /var/lib/tftpboot/pxelinux.cfg/
-
[root@rhel6 ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
-
[root@rhel6 ~]# cp /media/isolinux/initrd.img /var/lib/tftpboot/
-
[root@rhel6 ~]# cp /media/isolinux/vmlinuz /var/lib/tftpboot/
-
[root@rhel6 ~]# cp /media/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
-
[root@rhel6 ~]# ls -R /var/lib/tftpboot/
-
/var/lib/tftpboot/:
-
boot.msg initrd.img pxelinux.0 pxelinux.cfg vmlinuz
-
/var/lib/tftpboot/pxelinux.cfg:
-
default
-
[root@rhel6 ~]# vi /var/lib/tftpboot/pxelinux.cfg/default
-
default rhel6_nfs
-
prompt 1 #显示"boot: " 提示进行选择以下lable
-
timeout 100 #10s 的超时后进入default所定义的lable
-
display boot.msg #以boot.msg进行文本提示(与以下的*.msg文件结合,非必选项)
-
F1 boot.msg
-
F2 options.msg
-
F3 general.msg
-
F4 param.msg
-
F5 rescue.msg
-
#可通过以下3种方式下载ks.cfg文件,通过default定义lable或在timeout时间之内选择lable即可
-
label rhel6_nfs #通过NFS方式
-
kernel vmlinuz
-
append ksdevice=eth0 load_ramdisk=1 initrd=initrd.img network ks=nfs:192.168.1.119:/var/ftp/pub/ks.cfg
-
label rhel6_ftp #通过FTP方式
-
kernel vmlinuz
-
append ksdevice=eth0 load_ramdisk=1 initrd=initrd.img network ks=ftp://192.168.1.119/pub/ks.cfg
-
label rhel6_http #通过HTTP方式
-
kernel vmlinuz
-
append ksdevice=eth0 load_ramdisk=1 initrd=initrd.img network ks=http://192.168.1.119/pub/ks.cfg
-
label rescue #用于rescue模式
-
kernel vmlinuz
-
append load_ramdisk=1 initrd=initrd.img rescue
·NFS:
-
[root@rhel6 ~]# ls /var/ftp/pub/
-
images ks.cf Packages repodata Server
-
[root@rhel6 ~]# cat /etc/exports
-
/var/ftp/pub 192.168.1.0/24(rw,sync,no_root_squash) #共享路径必须与default文件定义的ks.cfg路径一致
-
[root@rhel6 ~]# /etc/init.d/rpcbind status
-
rpcbind (pid 1418) is running...
-
[root@rhel6 ~]# /etc/init.d/nfs start
-
Starting NFS services: [ OK ]
-
Starting NFS quotas: [ OK ]
-
Starting NFS daemon: [ OK ]
-
Starting NFS mountd: [ OK ]
-
[root@rhel6 ~]# showmount -e
-
Export list for rhel6.xfcy.org:
-
/var/ftp/pub 192.168.1.0/24
·HTTS:
-
[root@rhel6 ~]# cat /etc/httpd/conf/httpd.conf | grep DocumentRoot
-
DocumentRoot "/var/ftp"#共享路径必须与default文件定义的ks.cfg路径一致
-
[root@rhel6 ~]# /etc/init.d/httpd start
-
Starting httpd: [ OK ]
·Kickstart
使用红帽的Kickstart配置程序可以通过图形界面创建或直接修改Kickstart文件。
# yum install system-config-kickstart
该配置程序主要包含11个模块:
基本设置、安装方式、引导器设置、分区信息、网络配置、认证、防火墙配置、显示配置、软件包、Pre脚本、Post脚本
关于Kickstart文件的配置内容请看:http://missedyou.blog.51cto.com/2014866/1091631
本文转自Vnimos51CTO博客,原文链接:http://blog.51cto.com/vnimos/1063154,如需转载请自行联系原作者