用grub引导netinstall安装Centos系统
没有DHCP 没有PXE 也没有netboot , IPMI又卡, 之前的老办法.
ks脚本需要提前准备一下
wget -c http://mirror.centos.org/centos/6/os/x86_64/isolinux/vmlinuz -O /boot/vmlinuz wget -c http://mirror.centos.org/centos/6/os/x86_64/isolinux/initrd.img -O /boot/initrd.img
wget -c http://mirror.centos.org/centos/7/os/x86_64/isolinux/vmlinuz -O /boot/vmlinuz wget -c http://mirror.centos.org/centos/7/os/x86_64/isolinux/initrd.img -O /boot/initrd.img
预先准备获取信息
yum install net-tools -y getETH=`ip -4 route list 0/0 |awk '{ print $5 }'` getGATEWAY=`ip -4 route list 0/0 |awk '{ print $3 }'` getNETMASK=`ifconfig $getETH | awk '/mask /{ print $4;}'` getIPADDR=`ifconfig $getETH | awk '/inet /{ print $2;}'`
Centos6下的grub
title CentOS 6 Install root (hd0,0) kernel /vmlinuz ro ks=http://dl.kvm.la/ks/centos6.ks headless noipv6 ip=$getIPADDR netmask=$getNETMASK gateway=$getGATEWAY dns=8.8.8.8 hostname=localhost ksdevice=eth0 keymap=us initrd /initrd.img
title CentOS7 Install root (hd0,0) kernel /vmlinuz ks=http://XX.XX.XX.XX/kickstart.php/rh?end=1ðworkaround=1 net.ifnames=0 biosdevname=0 crashkernel=auto ip=$getIPADDR netmask=$getNETMASK gateway=$getGATEWAY nameserver=8.8.8.8 ksdevice=eth0 keymap=us initrd /initrd.img
centos7后的grub2引导
cat>>/etc/grub.d/40_custom<<EOF menuentry 'Netinstall' { load_video set gfxpayload=keep insmod gzio insmod part_gpt insmod xfs set root='hd0,gpt2' linux16 /vmlinuz ro ks='http://103.xxx.xxx.xxx/kickstart.php/rh?end=1ðworkaround=1' net.ifnames=0 biosdevname=0 crashkernel=auto gateway=$getGATEWAY ip=$getIPADDR nameserver=8.8.8.8 ksdevice=eth0 netmask=$getNETMASK initrd16 /initrd.img } EOF
ksdevice=eth0可以改成ksdevice=$getMAC (这个没写, 其实自己手动判断一下)
iPXE启动脚本
#!ipxe kernel http://$server/proxy.php/images/pxeboot/vmlinuz vga=normal ks=http://$server/kickstart.php/rh?end=1ðworkaround=1 ip=$ip::$gateway:$netmask::eth0:none ifname=eth0:$mac ksdevice=$mac initrd http://$server/proxy.php/images/pxeboot/initrd.img boot
net.ifnames=0 biosdevname=0 是让网卡命名改回ethX的方式.