How to Use PXE to automatically install Linux

Source: Internet
Author: User

Recently, I have studied pxe for automatic installation in my company, and I have also referred to a lot of information on the Internet. Here I have made some simple work and I have little skills in text expression, don't shoot bricks.

Preparation:
1. A CentOS63 (CentOS6.4 system, IP: 192.168.202.131) is installed in VMware)
2. A CentOS65 (empty machine, operating system not installed) is created in VMware)
3. The CentOS image file is mounted to the/media/CentOS_6.4_Final location of CentOS 63.


Procedure:


1. Configure DHCP


1. Install dhcpd
Yum install dhcp

2. Modify the dhcp configuration file/etc/dhcp/dhcpd. conf.
Ddns-update-style interim;
Ignore client-updates;
Allow booting;
Allow bootp;
Subnet 192.168.202.0 netmask 255.255.255.0 {
Range 192.168.202.200 192.168.202.220;
Option routers 192.168.202.131;
Option subnet-mask limit 255.0;
Default-lease-time 21600;
Max-lease-time 43200;
Next-server 192.168.202.131;
Filename "pxelinux.0 ";
}
 
3. Start dhcpd
Chkconfig -- add dhcpd
Service dhcpd start

The command shows that dhcpd is bound to multiple ports.
[Root @ localhost init. d] # netstat-anp | grep dhcpd
Udp 0 0 0.0.0.0: 67 0.0.0.0: * 3266/dhcpd
Raw 0 0 0.0.0.0: 1 0.0.0.0: * 7 3266/dhcpd
Unix 2 [] DGRAM 18034 3266/dhcpd
Note: Line 1 raw indicates that it is bound to the ICMP protocol and the Protocol number is 1.

2. Configure TFTP

4. Install TFTP
Yum install tftp-server

5. Modify the tftpd configuration file/etc/xinetd. d/tftp. the ftp root directory is/var/lib/tftpboot.
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
CPIs = 100 2
Flags = IPv4
}


6. Start the tftp service (port 69)
/Etc/init. d/xinetd restart


3. Configure the boot Kernel


7. Download the pxe boot configuration file
Yum install syslinux
Cp 'rpm-ql syslinux | grep'/pxelinux.0 '/var/lib/tftpboot


8. Copy the Kernel File started from the network.
Cp/media/CentOS_6.4_Final/images/pxeboot/{vmlinuz, initrd. img}/var/lib/tftpboot
Mkdir/var/lib/tftpboot/pxelinux. cfg
Cp/media/CentOS_6.4_Final/isolinux. cfg/var/lib/tftpboot/pxelinux. cfg/default

Modify the default file:

Default linux
Prompt 1
Timeout 60


Display boot. msg


Menu background splash.jpg
Menu title Welcome to CentOS 6.4!
Menu color border 0 # ffffffff #00000000
Menu color sel 7 # ffffffff # ff000000
Menu color title 0 # ffffffff #00000000
Menu color tabmsg 0 # ffffffff #00000000
Menu color unsel 0 # ffffffff #00000000
Menu color hotsel 0 # ff000000 # ffffffff
Menu color hotkey 7 # ffffffff # ff000000
Menu color scrollbar 0 # ffffffff #00000000


Label linux
Menu label ^ Install or upgrade an existing system
Menu default
Kernel vmlinuz
Append ks = http: // 192.168.202.131/ks. cfg initrd = initrd. img

 


4. Configure kickstart
 
9. Install nginx, root directory/usr/local/nginx/html
Yum install nginx
Chkconfig -- add nginx
Service nginx start

10. Copy the operating system source file
Mkdir/usr/local/nginx/html/dvd
Cp-R/media/CentOS_6.4_Final/*/usr/local/nginx/html/dvd/

11. Download kickstart
Yum install system-config-kickstart
Cp/root/anaconda-ks.cfg/usr/local/nginx/html/ks. cfg
Chmod 755/usr/local/nginx/html/ks. cfg)

Modify ks. cfg:
# Platform = x86, AMD64, or Intel EM64T
# Version = DEVEL


# Firewall configuration
Firewall -- disabled


# Install OS instead of upgrade
Install


# Use text install
Text


# Use network installation
Url -- url = "http: // 192.168.202.131/dvd"


# Root password
Rootpw -- iscrypted $1 $. IvWB. Gl $ E4fI4Ez4Z8HyHRCZW5Btr0


# System authorization information
Auth -- useshadow -- passalgo = sha512


# Run the Setup Agent on first boot
Firstboot -- reconfig


# System keyboard
Keyboard us


# System language
Lang zh_CN.UTF-8


# SELinux configuration
Selinux -- enforcing


# Installation logging level
Logging -- level = info


# System timezone
Timezone Asia/Shanghai


# Network information
Network -- bootproto = dhcp -- device = eth0 -- onboot = yes


# System bootloader configuration
Bootloader -- location = mbr


# Clear the Master Boot Record
Zerombr


# Partition clearing information
Clearpart -- all


# Disk partitioning information
Part/boot -- fstype = "ext4" -- size = 200
Part swap -- fstype = "swap" -- size = 1000
Part/-- fstype = "ext4" -- grow -- size = 1


# Reboot after installation
Reboot


% Packages
@ Base
@ Core
Gcc
% End


5. Verification


12. Modify the CentOS65 virtual configuration file CentOS65.vmx and add a line of bios. bootDelay = "10000", which means that the bios will be started for 10 seconds (otherwise you will have no time to press any key)
Power up CentOS65 and Press Esc to start from Network

Good luck !!!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.