PXE+Kickstart

PXE+Kickstart service program for unattended installation service
PXE+Kickstart

Configure the DHCP server

The DHCP service program is used to assign an available IP address to the client host, the basis for file transfer between the server and the client host
Note: Turn off its own DHCP service in the virtual network editor of the virtual machine

##安装DHCP服务程序软件包
yum install dhcp
##允许BOOTP引导程序协议,在让局域网内暂时没有操作系统的主机也能获取静态IP地址;
在配置文件的最下面加载了引导驱动文件pxelinux.0,让客户端主机获取到IP地址后主动获取引导驱动文件
vim /etc/dhcp/dhcpd.conf
    allow booting;
    allow bootp;
    ddns-update-style interim;
    ignore client-updates;
    subnet 192.168.10.0 netmask 255.255.255.0 {
                    option subnet-mask      255.255.255.0;
                    option domain-name-servers  192.168.10.10;
                    range dynamic-bootp 192.168.10.100 192.168.10.200;
                    default-lease-time      21600;
                    max-lease-time          43200;
                    next-server             192.168.10.10;
                    filename                "pxelinux.0"; }
##重启服务
systemctl restart dhcpd
systemctl enable dhcpd

Configure the TFTP service program

As a simple file transfer protocol based on the UDP protocol, TFTP can obtain the required file resources without user authentication,
configure the TFTP service program, and provide boot and drive files for the client host. Transfer the complete CD image file through the vsftpd service program

##安装TFTP服务程序软件包
yum install tftp-server
vim /etc/xinetd.d/tftp
##TFTP运行和关闭是由xinetd网络守护进程服务来管理的
##xinetd服务程序会同时监听系统的多个端口,根据用户请求的端口号调取相应的服务程序来响应用户的请求
##开启TFTP服务程序,在xinetd服务程序的配置文件中把disable参数改成no
##保存配置文件并退出,重启xinetd服务程序,并将其加入到开机启动项中
    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

systemctl restart xinetd
systemctl enable xinetd

##TFTP服务程序默认使用的是UDP协议,占用的端口号为69,firewalld防火墙管理工具中写入使其永久生效的允许策略
firewall-cmd --permanent --add-port=69/udp
firewall-cmd --reload 

Configure the SYSLinux service program

SYSLinux is used to provide boot-loaded service programs and boot files. Boot file location: /usr/share/syslinux

##安装syslinux服务程序软件包
yum install syslinux
##把SYSLinux提供的引导文件复制到TFTP服务程序的默认目录
##将光盘镜像中自带的一些引导文件也复制到TFTP服务程序的默认目录
cd /var/lib/tftpboot
cp /usr/share/syslinux/pxelinux.0 .
cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} .
cp /media/cdrom/isolinux/{vesamenu.c32,boot.msg} .
##TFTP服务程序的目录中新建pxelinux.cfg目录
##将系统光盘中的开机选项菜单复制到该目录中,default文件就是开机时的选项菜单
mkdir pxelinux.cfg
cp /media/cdrom/isolinux/isolinux.cfg pxelinux.cfg/default
##将默认的光盘镜像安装方式修改成FTP文件传输方式,
##指定光盘镜像的获取网址以及Kickstart应答文件的获取路径
vim pxelinux.cfg/default
    default linux
    timeout 600
    display boot.msg
    \# Clear the screen when exiting the menu, instead of leaving the menu displa yed.
    \# For vesamenu, this means the graphical background is still displayed witho ut
    \# the menu itself for as long as the screen remains in graphics mode.
    menu clear
    menu background splash.png
    menu title Red Hat Enterprise Linux 7.0
    menu vshift 8
    menu rows 18
    menu margin 8
    #menu hidden
    \menu helpmsgrow 15
    \menu tabmsgrow 13
    \# Border Area
    menu color border * #00000000 #00000000 none
    \# Selected item
    \menu color sel 0 #ffffffff #00000000 none
    \# Title bar
    \menu color title 0 #ff7ba3d0 #00000000 none
    \# Press [Tab] message
    \menu color tabmsg 0 #ff3a6496 #00000000 none
    \# Unselected menu item
    menu color unsel 0 #84b8ffff #00000000 none
    \# Selected hotkey
    \menu color hotsel 0 #84b8ffff #00000000 none
    \# Unselected hotkey
    \menu color hotkey 0 #ffffffff #00000000 none
    \# Help text
    \menu color help 0 #ffffffff #00000000 none 
    \# A scrollbar of some type? Not sure.
    \menu color scrollbar 0 #ffffffff #ff355594 none
    \# Timeout msg
    \menu color timeout 0 #ffffffff #00000000 none
    \menu color timeout_msg 0 #ffffffff #00000000 none 
    \# Command prompt text
    menu color cmdmark 0 #84b8ffff #00000000 none
    menu color cmdline 0 #ffffffff #00000000 none 
    \# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message. 
    menu tabmsg Press Tab for full configuration options on menu items. 
    menu separator # insert an empty line
    menu separator # insert an empty line
    menu separator # insert an empty line
    label linux
    menu label ^Install Red Hat Enterprise Linux 7.0
    kernel vmlinuz
    append initrd=initrd.img inst.stage2=ftp://192.168.10.10 ks=ftp://192.168.10.10/pub/ks.cfg quiet

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

Configure the VSFtpd service program

Note: After the configuration file is modified correctly, add the corresponding service program to the startup items

##安装vsfrpd服务程序软件包
yum install vsftpd
systemctl restart vsftpd
systemctl enable vsftpd
##系统光盘镜像已经正常挂载到/media/cdrom目录后,
##把目录中的光盘镜像文件全部复制到vsftpd服务程序的工作目录中
cp -r /media/cdrom/* /var/ftp
##firewalld防火墙管理工具中使FTP协议永久生效,SELinux中放行FTP传输
firewall-cmd --permanent --add-service=ftp
firewall-cmd --reload 
setsebool -P ftpd_connect_all_unreserved=on

Create a KickStart answer file

##anaconda-ks.cfg的文件复制到vsftpd服务程序的工作目录中
##使用chmod命令设置该文件的权限
cp ~/anaconda-ks.cfg /var/ftp/pub/ks.cfg
chmod +r /var/ftp/pub/ks.cfg
##Kickstart应答文件
vim /var/ftp/pub/ks.cfg 
     #version=RHEL7
     \# System authorization information
     auth --enableshadow --passalgo=sha512
     \# Use CDROM installation media
     url --url=ftp://192.168.10.10
     \# Run the Setup Agent on first boot
     firstboot --enable
     ignoredisk --only-use=sda
     \# Keyboard layouts
     keyboard --vckeymap=us --xlayouts='us'
     \# System language
     lang en_US.UTF-8 
     \# Network information
     network --bootproto=dhcp --device=eno16777728 --onboot=off --ipv6=auto
     network --hostname=localhost.localdomain
     \# Root password
     rootpw --iscrypted $6$pDjJf42g8C6pL069$iI.PX/yFaqpo0ENw2pa7MomkjLyoae2zjMz2UZJ7b H3UO4oWtR1.Wk/hxZ3XIGmzGJPcs/MgpYssoi8hPCt8b/
     \# System timezone
     timezone Asia/Shanghai --isUtc
     user --name=linuxprobe --password=$6$a9v3InSTNbweIR7D$JegfYWbCdoOokj9sodEccdO.zL F4oSH2AZ2ss2R05B6Lz2A0v2K.RjwsBALL2FeKQVgf640oa/tok6J.7GUtO/ --iscrypted --gecos ="linuxprobe"
     \# X Window System configuration information
     xconfig --startxonboot
     \# System bootloader configuration
     bootloader --location=mbr --boot-drive=sda
     autopart --type=lvm
     \# Partition clearing information
     clearpart --all --initlabel 
     %packages
     @base
     @core
     @desktop-debugging
     @dial-up
     @fonts
     @gnome-desktop
     @guest-agents
     @guest-desktop-agents
     @input-methods
     @internet-browser
     @multimedia
     @print-client
     @x11 
     %end

The system-config-kickstart package can be installed from the Yum repository.
The graphical Kickstart answer file generation tool can generate custom answer files according to your own needs, and then put the generated files in the /var/ftp/pub directory and change the name to ks.cfg

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325354546&siteId=291194637