Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement PXE+Kickstart unattended installation operating system under CentOS

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to realize the unattended installation operating system of PXE+Kickstart under CentOS". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I. brief introduction

1.1 what is pxe

Pxe (pre-boot execution environment, pre-boot execution environment) is the latest technology developed by intel, which works in the network mode of client/server. It supports workstations to download images from remote servers through the network, and thus supports booting the operating system through the network. During the startup process, the terminal requires the server to assign an ip address. Then use tftp (trivial file transfer protocol) or mtftp (multicast trivial file transfer protocol) protocol to download a startup package into local memory for execution, and the startup package completes the terminal basic software settings, thus booting the terminal operating system pre-installed in the server.

Strictly speaking, pxe is not an installation method, but a boot mode. The necessary condition for pxe installation is that a pxe-supported network card (nic) must be included in the computer to be installed, that is, there must be pxe client in the network card. The pxe protocol enables computers to start over the network. This protocol is divided into client side and server side, while pxe client is in the rom of the network card. When the computer boots, bios calls the pxe client into memory for execution, and then pxe client downloads the files placed at the remote end to run locally through the network. Running the pxe protocol requires setting up a dhcp server and a tftp server. The dhcp server assigns an ip address to the pxe client (the host on which the system will be installed), and since the ip address is assigned to the pxe client, you need to add the corresponding pxe settings when configuring the dhcp server. In addition, tftp client already exists in pxe client's rom, so it can download the required files to tftp server through the tftp protocol.

The working process of pxe:

1. Pxe client starts from its own pxe network card and asks for ip from the dhcp server in this network

2. The dhcp server returns the ip assigned to the client and the location of the pxe file (this file is usually placed on a tftp server)

3. Pxe client requests pxelinux.0 files from tftp servers in this network

4. Execute the pxelinux.0 file after pxe client obtains the file

5. According to the execution result of pxelinux.0, the kernel and file system are loaded through the tftp server

6. Enter the installation screen, and you can install it by selecting one of http, ftp or nfs methods.

For detailed workflow, please refer to the following figure:

1.2 what is kickstart

Kickstart is an unattended installation. It works by recording various parameters that typically require human intervention during installation and generating a file called ks.cfg. If parameters are to be filled in during the installation process (not limited to the machine that generates the kickstart installation files), the installer will first look for the files generated by kickstart, and if it finds the right parameters, it will use the parameters found; if the appropriate parameters are not found, the installer will need to intervene manually. So, if the kickstart file covers all the parameters that may need to be filled in during the installation process, then the installer can just tell the installer where to get the ks.cfg file and go about his own business. When the installation is complete, the installer will restart the system according to the settings in ks.cfg and finish the installation.

The complete process of pxe+kickstart unattended installation of the operating system is as follows:

II. System environment

Lab environment: vmware workstation 10

System platform: centos release 6.4 (minimized installation)

Network mode: nat mode (ip address of shared host)

Dhcp / tftp ip:192.168.111.130

Http / ftp / nfs ip:192.168.111.130

The firewall is turned off / iptables: firewall is not running.

Selinux=disabled

III. Preparatory work

The system-config-kickstart tool is needed to generate the ks.cfg file, and this tool depends on x windows, so we need to install x windows and desktop and restart the system, as follows:

# yum groupinstall "x window system" # yum groupinstall desktop# reboot

Configure the installation mode of http

The installation method of the system can choose http, ftp, nfs, we introduce the installation of http here, the other two ways of installation, you can own Baidu.

4.1 install and configure http

# yum install httpd-y # rpm-qa | grep httpd

Turn on the service and set the boot

# / etc/init.d/httpd start# chkconfig-- level 35 httpd on

4.2 load iso image

Set the load iso image in the virtual machine.

Mount the iso file to / mnt/cdrom.

4.3 copy all the contents of the CD to the root directory / var/www/html/ of http

# cp-r / mnt/cdrom/ / var/www/html/

The http part is set up.

5. Configure tftp

5.1 install tftp-server

# yum install tftp-server-y

5.2 enable tftp service

# vi / etc/xinetd.d/tftpservice 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}

Set disable to no

5.3 start the tftp service

Because the tftp service is mounted under the super process xinetd, start the tftp service by starting xinetd.

# / etc/init.d/xinetd restart

Set up the boot xinetd

# chkconfig xinetd on

Configure the startup program that supports pxe

6.1 copy the pxelinux.0 file to the / var/lib/tftpboot/ folder

# cp / usr/share/syslinux/pxelinux.0 / var/lib/tftpboot/

Description: syslinux is a powerful boot loader and compatible with a variety of media. More specifically: syslinux is a small linux operating system designed to simplify the time it takes to install linux for the first time and to create a boot disk for repair or other special purposes.

6.2 copy the / image/pxeboot/initrd.img and vmlinux in the iso image to the / var/lib/tftpboot/ folder

# cp / var/www/html/cdrom/images/pxeboot/ {initrd.img,vmlinuz} / var/lib/tftpboot/

6.3 copy / isolinux/*.msg in the iso image to / var/lib/tftpboot/ folder

# cp / var/www/html/cdrom/isolinux/*.msg / var/lib/tftpboot/

6.4 create a new pxelinux.cfg directory in / var/lib/tftpboot/

# mkdir / var/lib/tftpboot/pxelinux.cfg

6.5 copy the isolinux.cfg in the / isolinux directory in the iso image to the pxelinux.cfg directory and change the file name to default

# cp / var/www/html/cdrom/isolinux/isolinux.cfg / var/lib/tftpboot/pxelinux.cfg/default

6.6 modify the default file

# vi / var/lib/tftpboot/pxelinux.cfg/defaultdefault ks # starts by default with the boot kernel prompt 1 # marked in label ks' showing the prompt 'boot:'. When'0' is not prompted, the content specified in the 'default' parameter will be started directly. The timeout of timeout 6 # before user input, in units of 1 to 10 seconds. Display boot.msg # displays the contents of a file. Note the path to the file. The default is in the / var/lib/tftpboot/ directory. It can also refer to locating a path + file name like'/ install/boot.msg'. F1 boot.msg # the file that is displayed after pressing a key such as'F1'. F2 options.msg f3 general.msg f4 param.msg f5 rescue.msg label linux # 'label' specifies the keywords you enter at the' boot:' prompt, such as boot: linux [enter], which launches the kernel and initrd.img files marked under 'label linux'. The kernel vmlinuz # kernel parameter specifies the kernel to boot. Append initrd=initrd.img # append specifies parameters appended to the kernel, and parameters appended to the kernel that can be used in grub can also be used here. Label text kernel vmlinuz append initrd=initrd.img text label ks kernel vmlinuz append ks= http://192.168.111.130/ks.cfg initrd=initrd.img # tells the system where to get the ks.cfg file label local localboot 1 label memtest86 kernel memtest append-

7. Configure dhcp

7.1 install the dhcp service

# yum-y install dhcp

7.2 copy the configuration template file to the configuration directory of dhcp

# cp- f / usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample / etc/dhcp/dhcpd.conf

7.3 modify the / etc/dhcp/dhcpd.conf configuration file as follows:

Ddns-update-style interim; ignore client-updates; filename "pxelinux.0"; # pxelinux startup file location; next-server 192.168.111.130; ip address of # tftp server; subnet 192.168.111.0 netmask 255.255.255.0 {option routers 192.168.111.130; option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.111.100 192.168.111.100 192.168.111.200; default-lease-time 21600 Max-lease-time 43200;}

7.4 start the dhcp service

# / etc/init.d/dhcpd start

8. Generate ks.cfg files

8.1 install kickstart

# yum install system-config-kickstart

8.2 configure kickstart in a desktop environment

Start the x windows environment

# startx

Configure kickstart

# system-config-kickstart

a. Set language, keyboard, time zone, root password, restart after installation, etc.

b. Set the installation mode, this article introduces the installation of http mode, so choose http

c. Install mbr

d. Set Partition

e. Zone overview

f. Configure the network

g. Authentication configuration

H. Selinux and firewall configuration

i. Graphic environment configuration

j. Package installation selection

k. Preview

l. Generate a ks.cfg file and save it in the / var/www/html/ folder

We can open the / var/www/html/ks.cfg file to view it and make changes.

Platform=x86, amd64 Or intel em64t # version=devel # firewall configuration firewall-- disabled # install os instead of upgrade install # use network installation url-- url= http://192.168.111.130/cdrom/ # this option tells the installer to look for installation media # root password rootpw-iscrypted $1$ vsvtp./e$6pvmnfjd.shq2lgfjjyfa1 # system authorization information auth-useshadow-enablemd5 # use graphical install graphical firstboot-disable # system keyboard in the cdrom folder under the server 192.168.111.130 Keyboard us # system language lang en_us # selinux configuration selinux-disabled # installation logging level logging-level=info # reboot after installation reboot # system timezone timezone-isutc asia/shanghai # network information network-bootproto=dhcp-device=eth0-onboot=on # system bootloader configuration key-skip bootloader-append= "rhgb quiet"-location=mbr-driveorder=sda # clear the master boot record zerombr # partition clearing information clearpart-all-initlabel # disk partitioning information part / fstype= "ext4"-size=8192 part swap-fstype= "swap"- -size=1024 part / home-- fstype= "ext4"-- size=2048%packages @ base%end

Note: key-- skip if it is a red hat system, this option can skip the process of entering a serial number; if it is a centos series, you can not keep this content

Reboot this option must exist and the location must be set in the text, otherwise kickstart displays a message and waits for the user to press any key before rebooting

Clearpart-- all-- initlabel this command must be added, otherwise the system will let the user manually choose whether to clear all data, which will require human intervention, resulting in the failure of the automation process.

9. Test the installation

After the automatic installation system is configured, a new machine is started for testing, and the network connection mode chooses nat mode.

Create a new virtual machine and select Custom (Advanced)

Select "install operating system later"

Select the client operating system type

Named virtual machine

Set the memory of this virtual machine

Set the network type

Select the iUniver controller type

Select disk type

Select disk

Specify the disk size. In the ks.cfg file, we define the / size as 8GB, the swap partition is 1GB, and the home partition is 2gb, so the disk size here should be at least 12gb.

Also, be sure to check "allocate all disk space now", otherwise there will be no disk space when you install it later.

Specify disk file

Virtual machine overview

The disk is being created, the process will be slow, and the virtual machine needs to generate a 20gb file.

Start the virtual machine, choose to boot from the network card, and the dhcp server is assigning an ip address to the client.

Start downloading vmlinuz and initrd.img

Installation process.

Installation process.

Installation process.

After installation and reboot, the login interface is displayed.

Log in to the system to see that the disk partition is the same as we set in the ks.cfg file.

Pxe+kickstart unattended installation operating system environment has been set up.

This is the end of the content of "how to implement the PXE+Kickstart unattended installation operating system under CentOS". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report