Preface:
When you install more than tens or hundreds of Linux operating system, one that we can not manually install a go, so laborious and time-consuming, then we need a batch method and no operating system to install, and Linux in the unattended kickstart installation service provides such functionality, of course, there are many ways to achieve this function, this chapter will explain the method kickstart.
1, kickstart server environment
1) server IP address: 192.168.26.102
2) Operating System:
[root@vms002 /]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.1 (Maipo)
3) kickstart need to install Service
service |
Features |
dhcp |
Information provided to the client IP information, and tftp server |
tftp-server |
Store boot program, provided to the client download |
ftp or http or nfs |
Sharing operating system |
2, DHCP installation and configuration
1) yum install dhcp service
[root@vms002 /]# yum -y install dhcp [root@vms002 /]# rpm -qa dhcp dhcp-4.2.5-36.el7.x86_64
2) edit the DHCP configuration file
# Find the DHCP configuration file
[root@vms002 /]# rpm -qc dhcp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd6.conf /etc/openldap/schema/dhcp.schema /etc/sysconfig/dhcpd /var/lib/dhcpd/dhcpd.leases /var/lib/dhcpd/dhcpd6.leases
# Edit the DHCP configuration file
[root @ vms002 /] # cd / etc / dhcp / [root @ vms002 dhcp] # LS dhclient.d dhcpd6.conf dhcpd.conf # dhcpd.conf backup configuration file [root @ vms002 dhcp] # cp dhcpd.conf dhcpd. conf.back [root @ vms002 dhcp] CAT the dhcpd.conf # # # the dHCP Server the Configuration File. # See /usr/share/doc/dhcp*/dhcpd.conf.example # See the dhcpd.conf (5) man Page # [ DHCP @ vms002 the root] # CP / usr / Share / DOC / DHC dhclient-4.2.5 / 4.2.5-DHCP / DHCP-4.2.5-Common / [the root @ vms002 DHCP] CP # / usr / Share / DOC / 4.2.5-dhcp / dhcpd.conf.example ./dhcpd.conf cp: overwrite "./dhcpd.conf"? Y # dhcpd.conf Edit Profile [@ vms002 the root DHCP] # Vim dhcpd.conf Subnet # {192.168.26.0 255.255.255.0 Netmask segment Range 192.168.26.10 192.168.26.60; # assigned IP address pool option domain-name-servers 192.168.26.2; #dns address ; the Option "example.com" Domain-name the Option Routers 192.168.26.2; # gateway address option broadcast-address 192.168 .26.255; # broadcast address next-server 192.168.26.102; #tftp server IP address filename "/pxelinux.0"; # tell the client to download files from the boot program pxelinux.0 tftp server root directory default-lease-time 600; Lease Time-7200-max; }
3) start dhcp service and set boot from the start
# Start Service dhcpd [@ vms002 the root DHCP] Start # systemctl dhcpd [@ vms002 the root DHCP] # dhcpd systemctl IS-Active Active # boot from the start dhcpd service provided [@ vms002 the root DHCP] # systemctl enable dhcpd LN -s' / usr /lib/systemd/system/dhcpd.service '' /etc/systemd/system/multi-user.target.wants/dhcpd.service ' [@ vms002 the root DHCP] # dhcpd systemctl IS-Enabled Enabled
3, install tftp-server service
1) yum install tftp-server service
[root@vms002 dhcp]# yum -y install tftp-server
2) edit the configuration file tftp
#查询tftp配置文件 [root@vms002 dhcp]# rpm -qc tftp-server /etc/xinetd.d/tftp [root@vms002 dhcp]# cd /etc/xinetd.d/ [root@vms002 xinetd.d]# ls chargen-dgram daytime-stream echo-dgram tftp chargen-stream discard-dgram echo-stream time-dgram daytime-dgram discard-stream tcpmux-server time-stream #备份tftp配置文件 [root@vms002 xinetd.d]# cp tftp tftp.back #编辑tftp配置文件 [root@vms002 xinetd.d]# vim tftp # default: off # description: The tftp server serves files using the trivial file transfer \ # protocol. The tftp protocol is often used to boot diskless \ # workstations, download configuration files to network-aware printers, \ # and to start the installation process for some operating systems. service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /var/lib/tftpboot disable = no #默认是yes,改为no per_source = 11 cps = 100 2 flags = IPv4 }
3) Start tftp service and set the boot from the start
# Service xinetd start [root @ vms002 xinetd.d] # systemctl Start xinetd [root @ vms002 xinetd.d] # IS-systemctl the Active xinetd the Active # Set boot from the start xinetd service [root @ vms002 xinetd.d] # systemctl enable xinetd [root @ vms002 xinetd.d] # systemctl xinetd IS-Enabled Enabled
4. Copy the boot loader and kernel network boot file to the root directory of the tftp service
#tftp root directory path
[root@vms002 xinetd.d]# ls /var/lib/tftpboot/
1) inquiries and installation pxelinux.0 boot program, the boot program to the next copy pxelinux.0 root tftp
# Inquiry pxelinux.0 boot program
[root@vms002 xinetd.d]# yum whatprovides */pxelinux.0 已加载插件:langpacks, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. dvd/filelists_db | 3.1 MB 00:00 syslinux-4.05-12.el7.x86_64 : Simple kernel loader which boots from a FAT : filesystem 源 :dvd 匹配来源: 文件名 :/usr/share/syslinux/pxelinux.0
# Install the boot loader pxelinux.0
[root@vms002 xinetd.d]# yum -y install syslinux-4.05-12.el7.x86_64
# Pxelinux.0 boot program to the next copy tftp root directory
[root@vms002 xinetd.d]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ [root@vms002 xinetd.d]# ls /var/lib/tftpboot/ pxelinux.0
2) mount to the disc loading /rhel-7.1 directory, copying kernel network boot files {vmlinuz, initrd.img} under the root directory tftp
# Create a directory /rhel-7.1
[root@vms002 xinetd.d]# mkdir /rhel-7.1
Mount #mount
[root @ vms002 xinetd.d] # Mount / dev / cdrom /rhel-7.1/ Mount: / dev / SR0 write protection, will be mounted read-only [root @ vms002 xinetd.d] # ls /rhel-7.1/ RPM-GPG ImagesRF Royalty Free Packages Standard Package addons-KEY-RedHat-Release EFI-the isolinux Release Notes TRANS.TBL the EULA LiveOS repodata the GPL media.repo RPM-GPG-KEY-RedHat-Beta
# Copy network boot kernel file {vmlinuz, initrd.img} tftp root directory to
[root@vms002 xinetd.d]# cp /rhel-7.1/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/ [root@vms002 xinetd.d]# ls /var/lib/tftpboot/ initrd.img pxelinux.0 vmlinuz
3) according to their own operating system kernel boot program and renaming files in directory tftp, in order to distinguish
[root@vms002 xinetd.d]# cd /var/lib/tftpboot/ [root@vms002 tftpboot]# ls initrd.img pxelinux.0 vmlinuz [root@vms002 tftpboot]# mv initrd.img initrd_7.1.img [root@vms002 tftpboot]# mv pxelinux.0 pxelinux_7.1.0 [root@vms002 tftpboot]# mv vmlinuz vmlinuz_7.1 [root@vms002 tftpboot]# ls initrd_7.1.img pxelinux_7.1.0 vmlinuz_7.1
5, the installation and start the vsftpd service
1) yum install vsftpd service
[root@vms002 /]# yum -y install vsftpd
2) Start and set the boot from the start vsftpd service
# Start vsftpd service [@ vms002 the root /] # systemctl Start vsftpd [@ vms002 the root /] # systemctl IS-vsftpd Active Active # boot from the start vsftpd service provided [@ vms002 the root /] # systemctl enable vsftpd LN -s' / usr /lib/systemd/system/vsftpd.service '' /etc/systemd/system/multi-user.target.wants/vsftpd.service ' [@ vms002 the root /] # systemctl the vsftpd IS-Enabled Enabled
6, system-config-kickstart installation kit, kickstart configuration editor program generating answer file rhel-7.1.cfg
1) Modify yum source name
[@ vms002 the root /] # Vim /etc/yum.repos.d/aa.repo [Development] # modify the name name = DVD BaseURL = FTP: //192.168.26.101/dvd Enabled. 1 = gpgcheck = 0 [the root @ vms002 /] # yum clean all
2) Installation yum system-config-kickstart Kit
[root@vms002 /]# yum -y install system-config-kickstart
3) Edit kickstart configuration program generating rhel-7.1.cfg answer file, and stored at vsftpd root directory (/ var / ftp /)
[root@vms002 /]# system-config-kickstart &
# After editing stored under / var / ftp directory
4) Check the answer file is generated successfully
[root@vms002 /]# ls /var/ftp/ pub rhel-7.1.cfg
7, copy and edit the configuration file PXE
1) Copy the PXE configuration file
# Create a directory under the tftp directory pxelinux.cfg
[root@vms002 tftpboot]# pwd /var/lib/tftpboot [root@vms002 tftpboot]# mkdir pxelinux.cfg [root@vms002 tftpboot]# ls initrd_7.1.img pxelinux_7.1.0 pxelinux.cfg vmlinuz_7.1
# Copy the PXE configuration file to pxelinux.cfg directory and file name for the default
[root@vms002 tftpboot]# cp /rhel-7.1/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default [root@vms002 tftpboot]# ls /var/lib/tftpboot/pxelinux.cfg default
2) Edit PXE configuration file
# Default backup file
[root@vms002 tftpboot]# cd /var/lib/tftpboot/pxelinux.cfg/ [root@vms002 pxelinux.cfg]# cp default default.back [root@vms002 pxelinux.cfg]# ls default default.back
#赋予default文件写入权限
[root@vms002 pxelinux.cfg]# chmod u+w default [root@vms002 pxelinux.cfg]# ls -l default -rw-r--r--. 1 root root 3166 6月 3 15:56 default
#编辑文件
[@ vms002 the pxelinux.cfg the root] # Vim default RHEL 7.1 # default-default startup is "label rhel-7.1" core labeled start timeout 600 # timeout period before user input, seconds display prompt 0 # ' boot 'prompt, without prompting 0, specified by default boot kernel starts .................. omitted .............. ..... label RHEL-7.1 the MENU label ^ the Install Red Hat Enterprise Linux 7.1 kernel vmlinuz_7.1 # Like the kernel files in the tftp directory append initrd = initrd_7.1.img inst.ks = ftp: //192.168.26.102 quiet /rhel-7.1.cfg .................. omitted ...................
3) Restart tftp service
[root@vms002 pxelinux.cfg]# systemctl restart xinetd
8, test
With VMware Workstation virtual machine, create a new virtual machine, do not specify the use of the ISO image file, and the network adapter to kickstart server is the same network segment.