Unattended installation script kickstart under Linux

1. The role of kickstart automatic installation script

1. Problems faced when installing multiple operating systems in an enterprise

When installing the Linux operating system, the installation process will need to answer a lot of questions about settings. These questions must be manually selected, otherwise the installation cannot be performed.
When only one Linux system is installed, manual selection and setting workload is relatively easy. When installing multiple Linux systems, These settings need to be repeated several times. These repetitive actions are operations with lower efficiency.

2. How to solve the above problems?

Use files to record the answers to all questions during the installation process, and let all hosts that need to be installed automatically read them

3. kickstart action

In the above solution, the file that records the answers to all the questions in China during the system installation process is called the kickstart script

2. Experimental environment

1. Host name: westos_node1
2. IP: 172.25.254.20
3. Firewall, selinux is turned off
4. httpd service is turned on
5. The configuration software warehouse can work normally

Three, the production of kickstart automatic installation script

Provide the kickstart production method of graphics in the rhel7 system.
The graphics tools have been cancelled
in rhel8 and added to the rhn network . If you can’t make kickstarts through the rhn network in rhel8, you can use the template to generate

Generate the kickstart file from the template. In the
installed rhel8, /root/anaconda-ks.cfg is the answer to all the questions answered when the current system is installed.
This file is the template of the kickstart file

  • Steps
##1.共享资源
dnf install httpd -y
systemctl enable --now httpd
systemctl disable --now firewalld
setenforce 0 ##selinux模式调整为警告模式
mkdir /var/www/html/westos
mount /dev/cdrom /var/www/html/westos 
##2.kickstart 脚本编辑
  • test:

1. Generate ks file and share to httpd

  • /root/anaconda-ks.cfg ##Record the answers to the questions when installing the host
  • mkdir / var / www / html / ks
  • cp /root/anaconda-ks.cfg /var/www/html/ks/westos.org
    ##Copy the script automatically generated during the installation process
    Insert picture description here

Insert picture description here

2. Edit the ks file

vim /var/www/html/ks/westos.cfg

  • clearpart --all --initlabal ##Clean up all devices

  • #graphcial text ##Do not open graphical installation, open text interface

  • url --url="http://192.168.1.118/westos" ##Network installation path

  • --Onboot=on ##boot network boot

  • repo --name=“
    AppStream --baseurl=http://192.168.1.118/westos/AppStream ##The software park is changed to the network source

  • rootpw --plaintext westos ##root user password plain text westos

    • 1) openssl passwd -6 ##Generate encrypted string
    • 2) –plaintest westos plain text
  • #xconfig --startxonboot ##Do not open graphics when booting

  • service --disable=“chronyd” ##(Add as needed) Service start: custom

  • ##Time zone selection: Asia shanghai

  • part / --fstype=“xfs” --grow --size=8 ##The root partition is full of hard disks, grow in front

  • %packages ##System installation software

    • 1)httpd ##Single software
    • 2)@base ##Install components

(All subsequent sentences can be deleted)

  • reboot ##Automatically restart after system installation

  • %post ## Autonomously perform operations after system installation

  • Grammar detection:

    • dnf whatprovides */ksvalidator ##Find a package that can install this software
    • dnf search kickstart ##Find related software
    • dnf install “XXXXX” ksvalidator
      Insert picture description here
  • /var/www/html/westos.cfg ##Install the software to detect the syntax problem of the written script file
    Insert picture description here

Insert picture description here
Insert picture description here

3. Set ks file permissions

  • chmod 644 /var/www/html/westos.cfg ##Access with permission
    Insert picture description here

4.test Test the ks file with the virtual machine installation script

  • extra-args “ks=http://192.168.1.118/ks/westos.cfg” ##Specify ks script
  • ! ##ks file content is set incorrectly
  • Check whether adding information after %post is executed
    Insert picture description here

Insert picture description here
The script content is correct

View %post information

Guess you like

Origin blog.csdn.net/weixin_44632711/article/details/113377332