PXE(preboot execute environment)网络自动安装
Centos 6.4系统的自动安装
需要ftp服务器、tftp 服务器 、dhcp server 及system-config-kickstart 工具
[root@localhost ~]# mount /dev/cdrom/mnt/cdrom
[root@localhost ~]# vim /etc/yum.repos.d/CentOS-Media.repo
[media]
name=CentOS-media
baseurl=file:///mnt/cdrom/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
~
[root@localhost ~]# yum install dhcp
[root@localhost ~]# yum install tftp
[root@localhost ~]# yum install tftp-server
[root@localhost ~]# yum install vsftpd
[root@localhost ~]# mkdir /tftpboot/
[root@localhost ~]# mkdir /tftpboot/pxelinux.cfg/
[root@localhost ~]# cp /mnt/cdrom/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
引导菜单
[root@localhost ~]# vim /tftpboot/pxelinux.cfg/default
default linux
#prompt 1
timeout 3
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 initrd=initrd.img ks=ftp://192.168.1.1/ks.cfg
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img xdriver=vesa nomodeset
label rescue
menu label ^Rescue installed system
kernel vmlinuz
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff
label memtest86
menu label ^Memory test
kernel memtest
append �C
[root@localhost ~]# cp /mnt/cdrom/images/pxeboot/vmlinuz /tftpboot/
[root@localhost ~]# cp /mnt/cdrom/images/pxeboot/initrd.img /tftpboot/
[root@localhost ~]# cp/usr/share/syslinux/pxelinux.0 /tftpboot/
vmlinuz 内核、initrd.img 内核驱动、pxelinux.0 pxe专用启动文件(在syslinux包中)
[root@localhost ~]# vim /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves filesusing the trivial file transfer \
# protocol. The tftp protocol isoften 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 /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
# A slightly different configuration for aninternal subnet.
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.2 192.168.1.100;
option routers 192.168.1.1;
filename "/pxelinux.0";
next-server 192.168.1.1;
default-lease-time 600;
max-lease-time 7200;
}
[root@localhost ~]# yum installsystem-config-kickstart
产生ks.cfg文件
[root@localhost ~]# vim /var/ftp/ks.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url--url="ftp://192.168.1.1/pub"
# Root password
rootpw --iscrypted$1$K9XvRXLA$yctwyy0BHpSRP5FMJdRHD0
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang zh_CN
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# System timezone
timezone Asia/Shanghai
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="ext4"--size=200
part / --fstype="ext4"--size=10000
part swap --fstype="swap"--size=512
%packages
@chinese-support
@core
@server-policy
%end
reboot
[root@localhost ~]# service iptables stop
[root@localhost ~]# setenforce 0
[root@localhost ~]# service dhcpd restart
[root@localhost ~]# service xinetd restart
[root@localhost ~]# service vsftpd restart
[root@localhost ~]# mount /dev/cdrom/var/ftp/pub/
本文出自 “我爱技术” 博客,转载请与作者联系!