pxe+kickstart自動化安裝
阿新 • • 發佈:2017-09-13
環境 通過 ogg ask inf 壓縮 not x86_64 timeout
Kickstart是一種無人值守的安裝方式。它的工作原理是在安裝過程中記錄典型的需要人工幹預填寫的各種參數,並生成一個名為ks.cfg的
文件。如果在安裝過程中(不只局限於生成Kickstart安裝文件的機器)出現要填寫參數的情況,安裝程序首先會去查找Kickstart生成的
文件,如果找到合適的參數,就采用所找到的參數;如果沒有找到合適的參數,便需要安裝者手工幹預了。所以,如果Kickstart文件涵蓋
了安裝過程中可能出現的所有需要填寫的參數,那麽安裝者完全可以只告訴安裝程序從何處取ks.cfg文件,然後就去忙自己的事情。等安
裝完畢,安裝程序會根據ks.cfg中的設置重啟系統,並結束安裝。
什麽是PXE?
PXE(Pre-boot Execution Environment,預啟動執行環境)是Intel公司開發的最新技術,工作於Client/Server模式。PXE是一種遠程引導方式,要求計算機網卡支持PXE協議,即網卡ROM中有PXEClient。計算機引導時,BIOS將PXEClient調入內存,PXEClient其實主要包括DHCPClient和TFTPClient兩部分,PXEClient請求DHCP服務器分配IP,然後請求TFTP服務器下載引導文件和內核。
PXE的工作流程
pxelinux.0:引導程序,類似GRUB,pxelinux.0默認讀取/var/lib/tftpboot/pxelinux.cfg/default配置文件 pxelinux.cfg/default:存儲啟動菜單、vmlinuz、initrd.img位置、ks文件下載地址 vmlinuz:壓縮過的內核 initrd.img:將部分內存虛擬成磁盤,供內核使用 kickstart文件:存放安裝應答選項、鏡像下載地址什麽是Kickstart
DHCP配置
[[email protected] ~]# cat /etc/redhat-release CentOS release 6.6 (Final) [[email protected] ~]# uname -rm 2.6.32-504.el6.x86_64 x86_64 [[email protected] ~]# yum install -y dhcp [[email protected] ~]# vim /etc/dhcp/dhcpd.conf log-facility local7; subnet 172.16.1.0 netmask 255.255.255.0 { range 172.16.1.200 172.16.1.220; default-lease-time 600; max-lease-time 7200; next-server 172.16.1.88; filename "pxelinux.0"; } [[email protected] ~]# /etc/init.d/dhcpd start [[email protected] ~]# chkconfig dhcpd on [[email protected] ~]# netstat -nutlp | grep dhcp udp 0 0 0.0.0.0:67 0.0.0.0:* 24960/dhcpd
TFTP配置
[[email protected] ~]# yum install -y tftp-server xinetd [[email protected] ~]# vim /etc/xinetd.d/tftp 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 } [[email protected] ~]# yum install -y syslinux // 通過安裝該軟件包獲得引導文件 [[email protected] ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ [[email protected] ~]# mount /dev/cdrom /opt/ [[email protected] ~]# cp /opt/isolinux/* /var/lib/tftpboot/ [[email protected] ~]# mkdir /var/lib/tftpboot/pxelinux.cfg [[email protected] ~]# cp /opt/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default [[email protected] ~]# chmod 644 /var/lib/tftpboot/pxelinux.cfg/default [[email protected] ~]# vim /var/lib/tftpboot/pxelinux.cfg/default default vesamenu.c32 timeout 60 display boot.msg ...... label linux // 每一個label定義了一個啟動菜單項目 menu label ^Install CentOS 6 menu default kernel vmlinuz append initrd=initrd.img inst.ks=ftp://172.16.1.88/ks.cfg ip=dhcp quiet label check menu label Test this ^media & install CentOS 6 kernel vmlinuz append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet [[email protected] ~]# /etc/init.d/xinetd start [[email protected] ~]# chkconfig xinetd on [[email protected] ~]# netstat -nutlp | grep xinetd udp 0 0 0.0.0.0:69 0.0.0.0:* 25209/xinetd
FTP配置
[[email protected] ~]# yum install -y vsftpd [[email protected] ~]# yum install -y system-config-kickstart #使用 system-config-kickstart 工具生成kickstart文件,需要圖形界面 [[email protected] ~]# cp /tmp/ks.cfg /var/ftp/ks.cfg [[email protected] ~]# ksvalidator /var/ftp/ks.cfg // 檢查ks文件語法 [[email protected] ~]# umount /opt/ [[email protected] ~]# mount /dev/cdrom /var/ftp/pub/ mount: /dev/sr0 is write-protected, mounting read-only [[email protected] ~]# /etc/init.d/vsftpd start [[email protected] ~]# chkconfig vsftpd on
system-config-kickstart配置
kickstart文件
#platform=x86, AMD64, or Intel EM64T #version=DEVEL # Firewall configuration firewall --disabled # Install OS instead of upgrade install # Use network installation url --url="ftp://172.16.1.88/pub" # Root password rootpw --iscrypted $1$j2xUB1S7$9MW5sEYgcn3P/dqgF0/8L. # System authorization information auth --useshadow --passalgo=sha512 # Use graphical install graphical # System keyboard keyboard us # System language lang en_US # SELinux configuration selinux --disabled # Do not configure the X Window System skipx # Installation logging level logging --level=info # Reboot after installation reboot # System timezone timezone Asia/Shanghai # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part /boot --asprimary --fstype="ext4" --size=200 part swap --asprimary --fstype="swap" --size=1024 part / --asprimary --fstype="ext4" --grow --size=1 %packages @base @compat-libraries @debugging @development %end
pxe+kickstart自動化安裝