这两天在重做无磁盘系统,想把之前的Centos5.2的无盘系统升级到Centos6.3。发现在之前的Centos5.2有盘系统上无法直接用yum+chroot的方式安装一个chroot的Centos6.3系统。所以只能自己搞一个pxe先安装一台有盘的6.3系统了。虽然用pxe+kickstart 安装centos已经是老生长谈的事情了。但在实现安装过程中还是碰到了问题:我的有盘的机器IBM HS21除了自已带了一块136G的磁盘外,还通过SAN外挂了5块50G磁盘。在安装中,发现之前的kickstart的文件安装会有问题,会安装到SAN外挂磁盘上。
顺便说一下PXE安装的过程:1、在BIOS中设置使用网卡的PXE启动--2、网卡根据自己的MAC地址到DHCP获得指定的IP地址、tftp server的地址、主机名、DNS Server地址--3、从tftp server下载到gpxelinux.0这个bootloader--4、通过gpxelinux.0这个bootloader及MAC地址对应的PXE配置获取centos安装用的kernel、initrd.img文件及kickstart安装配置文件--5、根据kickstart安装配置文件完成系统安装
首先把PXE的相关dhcpd.conf和tftpd及syslinux的配置帖一下,备忘。顺便说一下,真得发现老了,自己搞的东东不记录下来的话,过两天就忘记了。
dhcpd.conf的配置,我比较喜欢用host 方式指定MAC地址。
[root@pxe01 centos63_64_install]# less /etc/dhcpd.conf
ddns-update-style ad-hoc;
default-lease-time 302400;
max-lease-time 604800;
allow bootp;
allow booting;
next-server 10.127.xx.xx;
filename “gpxelinux.0”;
subnet 10.127.x.0 netmask 255.255.255.0 {
option domain-name-servers 10.127.x.x;
range 10.127.x.216 10.127.x.219;
}
#我比较喜欢用host 方式指定MAC地址
host APP17{
hardware ethernet 00:00:6C:1E:00:04;
fixed-address 10.127.x.xx;
option host-name “APP17”;
filename “gpxelinux.0”;
next-server 10.127.x.xxx;
}
在xinetd中打开tftp:
[root@pxe01 ~]# vi /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /opt/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
pxe 的配置:
[root@pxe01 ~]# cat /tftpboot/pxelinux.cfg/DISK_CentOS6.3
DEFAULT installcent63
PROMPT 0
TIMEOUT 5
label installcent63
kernel http://10.127.x.xxx/image/centos63_64_install/images/pxeboot/vmlinuz
APPEND ksdevice=eth0 load_ramdisk=1 initrd=http://10.127.x.xxx/image/centos63_64_install/images/pxeboot/initrd.img ks=http://10.127.x.xxx/image/centos63_64_install/centos63.cfg
###做个软链接,把MAC地址指向上面的DISK_CentOS6.3,把机器的MAC与PXE文件关连起来
[root@pxe01 ~]# ll /tftpboot/pxelinux.cfg/ | grep 01-00-00-6c-1e-00-04
lrwxrwxrwx 1 root root 14 Dec 25 11:57 01-00-00-6c-1e-00-04 -> DISK_CentOS6.3
kickstart 的配置(指定分区在sda上,而不使用存储上的盘):
[root@pxe01 ~]# cat /data/pxe/image/centos63_64_install/centos63.cfg
Kickstart file automatically generated by anaconda.
#version=DEVEL
install
url –url=http://10.127.x.xxx/image/centos63_64_install/
lang en_US.UTF-8
keyboard us
network –onboot yes –device eth0 –mtu=1500 –bootproto dhcp
network –onboot yes –device eth1 –bootproto dhcp
rootpw –iscrypted $1$wNh6Xn8V$wpKo/vtBnVZOqmRwkHCYZ/
Reboot after installation
reboot
firewall –disabled
authconfig –enableshadow –enablemd5
selinux –disabled
timezone Asia/Shanghai
bootloader –location=mbr –driveorder=sda –append=”crashkernel=auto nodmraid nompath rhgb quiet”
The following is the partition information you requested
Note that any partitions you deleted are not expressed
here so unless you clear all partitions first, this is
not guaranteed to work
zerombr yes
bootloader –location=mbr
###只清空sda上的数据
clearpart –drives=sda –all
###不在下面的磁盘上安装系统
ignoredisk –drives=sdb,sdc,sdd,sde,sdf,sdg,sdh,sdi,sdj,sdk,sdl,sdm
###用ondisk option指定分区在sda上
part /boot –fstype=ext4 –ondisk=sda –size=100 –asprimary
part / –fstype=ext4 –ondisk=sda –size=4096
part /var –fstype=ext4 –ondisk=sda –size=4096
part swap –ondisk=sda –size=4096
part /opt –ondisk=sda –fstype=ext4 –grow –size=8196
#repo –name=”CentOS” –baseurl=http://pxe/os/centos/6.3/os/x86_64 –cost=100
repo –name=”CentOS” –baseurl=http://10.127.x.xxx/image/centos63_64_install/ –cost=100
selinux –disabled
%packages
@Base
@Core
@base
%end
%post
#############################SSH###############################
#############################YUM##############################
##############################YUM##############################
rm -fr /etc/yum.repos.d/*
mkdir -p /opt/yum/conf
cat >> /opt/yum/conf/base.repo << EOF
[base]
name = “centos \$releasever \$basearch - Base”
baseurl=http://pxe/os/centos/\$releasever/os/\$basearch
gpgcheck=0
enable=1
EOF
ln -fs /opt/yum/conf/base.repo /etc/yum.repos.d/
############################ZABBIX##############################
yum install -y zabbix-agent
cat > /etc/zabbix/zabbix_agentd.conf <> /etc/rc.local
/bin/echo “hwclock –systohc” >> /etc/rc.local
/usr/sbin/zabbix_agentd /etc/zabbix/zabbix_agentd.conf
cat > /etc/zabbix/crontab.root << EOF
/5 ntpdate dir
/5 /etc/zabbix/system_check.sh
EOF
最后给一个kickstart的option链接,里面可以解决所有kickstart相关的问题,比如如何把系统安装在LVM逻辑卷上。
kickstart opions