pxe无人值守安装linux
简要介绍:我这里使用的是 dhcp+tftp+ftp+kickstat使用的组合工具
yum -y install xinetd dhcpd tftpdtftp-server syslinux system-config-kickstart
# 运行system-config-kickstart命令然后保存ks.cfg文件
vim /etc/dhcp/dhcpd.conf
subnet 192.168.8.0 netmask 255.255.255.0 {
option routers 192.168.8.101;
range 192.168.8.103 192.168.8.200;
option domain-name-servers 192.168.8.101;
filename "pxelinux.0";
next-server 192.168.8.101;
default-lease-time 600;
max-lease-time 7200;
}
# 改完之后重新dhcpd
# 命令详解
# option routers dhcp路由地址
# range dhcp分配地址池
# default-lease-time dhcp默认时长
# filename pxe服务名称
# next-server pxe服务器地址
# allow members pxe最大值
vim /etc/xinetd.d/tftp
disable = no
# 将disable 改为no 改完之后重新瞬间守护进程
service xinetd restart
mount -t iso9660 /dev/sr0 /mnt
# 1. pxelinux.0, vesamenu.c32放到tftp根目录下 这个目录/var/lib/tftpboot/是默认的
cp/usr/share/syslinux/{pxelinux.0,vesamenu.c32} /var/lib/tftpboot/
# 2.创建pxelinux.cfg目录 ,该目录下准备存放default文件
mkdir /var/lib/tftpboot/pxelinux.cfg
# 3.创建要安装系统目录CentOS,拷贝initrd.imgvmlinuz至该目录
mkdir /var/lib/tftpboot/CentOS
cp /mnt/images/pxeboot/{initrd.img,vmlinuz}/var/lib/tftpboot/
cp /mnt/isolinux/isolinux.cfg/var/lib/tftpboot/pxelinux.cfg/default
cp ks.cfg /var/www/html/
vim /var/lib/tftpboot/pxelinux.cfg/default
default vesamenu.c32
#prompt 1
timeout 600
display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.8!
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 Centos 6.8
menu label ^Install Centos 6.8 system
menu defaule
kernel vmlinuz
append initrd=initrd.img ks=ftp://192.168.8.101/ks.cfg
#重新启动服务
service xinetd restart
service dhcpd restart
# ftp文件不需要做修改
# 使用命令system-config-kickstart
# 将命令生成的文件ks.cfg 复制到ftp目录下
cp /mnt /var/ftp/cdrom #将光盘整个打包放置ftp目录下
chmod 744 ks.cfg
# ks.cfg 文件如下
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url--url="ftp://ftpIP地址/cdrom"
# Root password
rootpw --iscrypted$1$JFkzkCM5$9AZseeDWKn2fxD5Ppw9ap/
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# System keyboard
keyboard us
# System language
lang zh_CN
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr--md5pass="$1$PLy03aLe$ljjfAzl5Igir7KBfr2q0J1"
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="ext4"--size=200
part swap --fstype="swap"--size=2000
part / --fstype="ext4" --grow--size=1
%post --interpreter=/bin/bash #这里在最后一步中我定义了脚本,yum源
rm -rf /etc/yum.repos.d/*
echo ‘[yum]
name=yum_rpm
baseurl=http://HTTP地址/yum_rpm/
enable=1
gpgcheck=0
[epel]
name=epel_rpm
baseurl=http://HTTP地址/epel_rpm/
enable=1
gpgcheck=0‘ > /etc/yum.repos.d/yum.repo
%end
%packages
@development
@system-management-snmp
%end
service vsftpd restart
service dhcpd restart
service xinetd restart
错误1: 使用system-config-kickstart命令之后无法选择软件
解决:必须在本地新建一个yum源 我这使用的是cd
[dvd]
name=dvd
baseurl=file:///var/ftp/cdrom
enabled=1
gpgcheck=0
错误2:CentOS时提示an error has occurred. - no valid devices were found
解决:更换光盘