PXE batch auto-deploy Linux system environment

Source: Internet
Author: User

1, basic network construction and build DHCP service

1) Configure the static IP address and restart the NIC

cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=Eth0type=ethernetonboot =yesnm_controlled=Yesbootproto=staticipaddr=10.0. 0.4 NETMASK=255.255. 255.0 GATEWAY=10.0. 0.2/etc/init.d/network restartifconfig eth0

2) Install the configuration DHCP service

Yum-YInstallDhcpvim/etc/dhcp/Dhcpd.confdefault-lease- Time  -; Max-lease- Time 7200;DD NS-update-style none;option domain-name-servers202.106.0.20; #DNS地址可配置2个用逗号分隔ignore Client-updates;subnet10.0.0.0Netmask255.255.255.0{Range10.0.0.100 10.0.0.150; #宣告获取地址段 option Subnet-mask255.255.255.0; #子网 option Routers10.0.0.2; #获取网关地址 Next-server10.0.0.4; #重点配置PEX地址 filename"pxelinux.0"; #内核文件名

#配置开机自启动
Chkconfig--add DHCPD
Chkconfig DHCPD on
Chkconfig--list DHCPD
#查看DHCP监听端口好UDP 67
Netstat-lntup|grep 67

2. Build TFTP service

Yum-y Install Tftp-server TFTP

vim/etc/xinetd.d/tftp# Configuring TFTP profiles: Service tftp{Socket_type=Dgram Protocol=UDPwait=Yes user=Root server=/usr/sbin/inch. TFTPD Server_args=-S/tftpboot #修改TFTP服务目录 Disable=no #修改为no, start tftp per_source= OneCPS= - 2Flags=IPv4}

#配置自启动
Chkconfig TFTP on
Chkconfig--list TFTP
Chkconfig--list xinetd
#重启动xinetd服务, TFTP is run by the XINETD service.
/etc/init.d/xinetd restart
Netstat-lntup|grep; Netstat-a|grep tftp
UDP 0 0 0.0.0.0:69 0.0.0.0:* 1877/xinetd
UDP 0 0 *:tftp
#TFTP端口号为UDP的69
#测试下载
Mkdir/tftpboot
cd/tftpboot/
Touch Test.txt
Ls
Test.txt
Cd..
TFTP 10.0.0.4-c get Test.txt
LS #下载成功!
Test.txt

3. Build HTTP Service

Yum-y Install httpd
#配置自启动
Chkconfig--add httpd
Chkconfig httpd on
Chkconfig--list httpd
#启动http服务
/ETC/INIT.D/HTTPD start
Netstat-lntup|grep 80

#使用浏览器测试
http://10.0.0.4

4. Build PXE service environment

1) Install the Syslinux package
yum-y install syslinux
#如不安装syslinux包就没有pxelinux. 0 file
Find/-type f-name "pxelinux.0"
/ usr/share/syslinux/pxelinux.0
#将pxelinux. 0 Copy to TFTP service directory
cp/usr/share/syslinux/pxelinux.0/tftpboot/
# Create the Pxelinux.cfg directory under the TFTP service directory
Mkdir/tftpboot/pxelinux.cfg-p
2) Mount the Linux system disk, copy the Linux kernel, initialize the image file
Mkdir-p/media /cdrom
mount-t iso9660-o loop/dev/sr0/media/cdrom
cd/media/cdrom/images/pxeboot
CP vmlinuz initrd.img/ tftpboot/
cd/tftpboot/
ls
initrd.img pxelinux.0 pxelinux.cfg vmlinuz
#配置启动菜单文件, Copy the boot file from the system to the TFTP directory and rename it to
Cp/media/cdrom/isolinux/isolinux.cfg/tftpboot/pxelinux.cfg/default
#修改启动菜单文件

Cat default default Auto    0        #为0时不选择自动按默认安装, select the option to install label Auto     #配置选项auto  kernel vmlinuz   #指定内核  Append initrd = When 1 is available Initrd.img ks=http://10.0.0.4/ks.cfg devfs=nomount ramdisk_size=8192   #指定自动安装文件ks. CFG label Linux text  kernel vmlinuz  append initrd=initrd.img devfs=nomount ramdisk_size=8192  label Rescue  kernel vmlinuz  append initrd=initrd.img rescue# Restart TFTP service load configuration / etc/init.d/xinetd restart

5. Create a Kickstart file

1) Install System-config-kickstart
Yum-y Install System-config-kickstart
#注意安装桌面服务才能启动KICKSTART, create a startup file
/usr/bin/system-config-kickstart

CatKs.cfg#platform=x86, AMD64, or Intel em64t#version=devel# Firewall configuration to shut down the firewall Firewall--disabled# Install OS instead of upgrade installation systemInstall# Use Network installation, configure HTTP to get the installation package URL--url="http://192.168.146.128/"Key--skip# root Password configuration root password rootpw--iscrypted $1$jIsDXG 2f$egt. vaheblz/ww9gnoto7.# System Authorization Information Licensing information auth--useshadow--passalgo=md5# Use graphicalInstallGraphical installation graphical# system keyboard Configuring the keyboard keyboard us# system language Configuring the systems Language lang en_us# SELinux configuration off Selinuxseli Nux--disabled# do not configure the X Window system does not install the graphical interface skipx# installation logging level installation system logging levels logging--level=Info# Reboot After installation install reboot reboot# System timezone #配置时区timezone Asia/shanghai# Network Information configuring networks for automatic access--bootproto=dhcp--device=eth0--onboot=on# System bootloader Configuration boot program bootloader--location=mbr# clear the master boot record clears master boot records zerombr# Partition clearing information partition information Clearpart--All # Disk Partitioning information specify partition size part swap--fstype="Swap"--size=2048 Part/boot--fstype="Ext4"--size= $ Part/--fstype="Ext4"--grow--size=1%Packages@base@compat-libraries@debugging@development%end

#将应答脚本拷贝到http目录, and give permission
CP ks.cfg/var/www/html/
Chown apache.apache/var/www/html/ks.cfg

6. Start the client Installation

Note: The client needs to be in the same LAN as the server
If you are experimenting with VMware, you need to turn off VMware's own DHCP capabilities

Troubleshooting ideas:
1) Whether the client obtains an IP address to view the network and DHCP service
2) Check if the link tftp is normal
If the link is normal after acquiring the IP address, it will display:
TFTP prefix:
Trying to load:pxelinux.cfg/default OK
Then load the kernel:
Loading Vmlinuz ...
Loading initrd.img .....
3) After loading the kernel will be linked to download installation system files, such as Tfp,http get

PXE batch auto-deploy Linux system environment

Related Article

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.