PXE+dhcp+tftp+ftp+kickStart无人值守安装系统
系统环境:
rhel6.3selinux disabled,iptables stopped
需要的软件:
dhcp
system-config-kickstart
tftp-server
KickStart:
yum install system-config-kickstart
图形化的配置,完成后的配置文件dhcp_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.122.1/pub/rhel6.3/"
# Root password
rootpw --iscrypted $1$0Mbf.MfR$mNrMDi3hgUlx8mUVL7bSC1
# System authorization information
auth --useshadow --passalgo=md5
# Use graphical install
graphical
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# System timezone
timezone --isUtc Asia/Shanghai
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="ext4" --size=200
part swap --fstype="swap" --size=500
part / --fstype="ext4" --grow --size=1
%post
/bin/echo "alias vi='vim'" >> /root/.bashrc
/bin/mkdir /root/.ssh
/bin/chmod 700 /root/.ssh/
/usr/bin/wget ftp://192.168.122.1/pub/setting/ssh/* -P /root/.ssh/
/bin/chmod 600 /root/.ssh/id_rsa
/bin/rm -fr /etc/yum.repos.d/rhel-source.repo
/usr/bin/wget ftp://192.168.122.1/pub/setting/localYum.repo -P /etc/yum.repos.d/
/usr/bin/yum install lftp -y
%end
%packages
@base
%end
DHCP:
yum install dhcp -y
cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample dhcpd.conf
vi /etc/dhcp/dhcpd.conf
option domain-name "example.com";
option domain-name-servers rhel;
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
authoritative;
log-facility local7;
filename "pxelinux.0";
next-server 192.168.122.2;#tftp server的IP地址
subnet 192.168.122.0 netmask 255.255.255.0 {
range 192.168.122.15 192.168.122.20;#分配的IP地址段
option routers 192.168.122.1;#分配的网关
}
/etc/init.d/dhcpd start#启动dhcp服务
chkconfig dhcpd on#加入开机自启动
TFTP:
yum install tftp-server -y
vi /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot#tftp服务器的目录
disable = no#yes改为no,随xinetd启动
per_source = 11
cps = 100 2
flags = IPv4
}
cp dir/rhel6.3/isolinux/* /var/lib/tftpboot/
yum search pxelinux
syslinux.x86_64 : Simple kernel loader which boots from a FAT filesystem
pxelinux.0由syslinux提供
yum install syslinux -y
cd /var/lib/tftpboot
cp /usr/share/syslinux/pxelinux.0 ./
mkdir pxelinux.cfg
cp isolinux.cfg pxelinux.cfg/default
vi pxelinux.cfg/default
...
...
label linux
menu label ^Install or upgrade an existing system
menu default
kernel vmlinuz
append initrd=initrd.img ks=ftp://192.168.122.1/pub/kickstart/dhcp_ks.cfg#指明kickstart位置即可
...
...
/etc/init.d/xinetd start#tftp随xinetd启动而启动
SUCCESS
本文出自 “VnlyZhang的博客” 博客,转载请与作者联系!