网络启动二:之PXE:CentOS6.9+TFTP+DHCP+BOIS+UEFI部署操作系统。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了网络启动二:之PXE:CentOS6.9+TFTP+DHCP+BOIS+UEFI部署操作系统。相关的知识,希望对你有一定的参考价值。
网络启动二:之PXE:CentOS7.4/6.9 +TFTP+DHCP+BOIS+UEFI部署操作系统
一、基础环境搭建:
CentOS 7.4 Min 172.16.30.59
安装略......。
TFTP+DHCP
yum install tftp-server dhcp xinetd
yum 源修改自行百度。
配置tftp、dhcp
3.1 修改tftp
sed -i '/disable/s/yes/no/' /etc/xinetd.d/tftp
在防火墙中允许
tftp
服务的进入连接:firewall-cmd --add-service=tftp
3.2 修改dhcp配置
vi /etc/dhcp/dhcpd.conf
--------------------
option space PXE;
option PXE.mtftp-ip code 1 = ip-address;
option PXE.mtftp-cport code 2 = unsigned integer 16;
option PXE.mtftp-sport code 3 = unsigned integer 16;
option PXE.mtftp-tmout code 4 = unsigned integer 8;
option PXE.mtftp-delay code 5 = unsigned integer 8;
option client-system-arch code 93 = unsigned integer 16;
#option domain-name-servers 8.8.8.8, 195.235.96.90;
allow booting;
allow bootp;
default-lease-time 600;
max-lease-time 7200;
#ddns-update-style interim;
subnet 172.16.30.0 netmask 255.255.255.0 {
range 172.16.30.50 172.16.30.70;
option routers 172.16.30.59;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
next-server 172.16.30.59;
if option client-system-arch = 00:07 or option client-system-arch = 00:09 {
filename "uefi/shim.efi";
} else {
filename "pxelinux/pxelinux.0";
}
}
#next-server 172.16.30.100;
}
--------------------------
systemctl start dhcp
systemctl start tftp
systemctl start xinetd
二、安装配置PXElinux
安装syslinux包
现在需要完整安装 DVD 的 ISO 映像文件中 SYSLINUX 软件包中的 pxelinux.0 文件。
挂载光盘或者通过yum源安装syslinux
wget http://172.16.30.121/centos7.4/Packages/{syslinux-4.05-13.el7.x86_64.rpm,shim-x64-12-1.el7.centos.x86_64.rpm,grub2-efi-x64-2.02-0.64.el7.centos.x86_64.rpm} -P /usr/local/src
提取软件包:
rpm2cpio syslinux-4.05-13.el7.x86_64.rpm |cpio -dimv
下面软件为UEFI使用。
rpm2cpio shim-x64-12-1.el7.centos.x86_64.rpm |cpio -dimv
rpm2cpio grub2-efi-x64-2.02-0.64.el7.centos.x86_64.rpm |cpio -dimv
在 tftpboot 中创建 pxelinux 目录,并将 pxelinux.0 复制到该目录中:
mkdir -p /var/lib/tftpboot/pxelinux/{centos6,centos7.4,pxelinux.cfg,esxi6,ubuntu16,win}
cp ./usr/share/syslinux/{pxelinux.0,vesamenu.c32,memdisk} /var/lib/tftpboot/pxelinux
cp ./usr/share/syslinux/memdisk /var/lib/tftpboot/uefi
cp ./boot/efi/EFI/centos/shim.efi /var/lib/tftpboot/uefi
cp ./boot/efi/EFI/centos/grubx64.efi /var/lib/tftpboot/uefi
具体内核放置目录自行规划
wget http://172.16.30.121/centos7.4/isolinux/{initrd.img,vmlinuz} -P /var/lib/tftpboot/pxelinux/centos7.4
wget http://172.16.30.121/centos6.9/isolinux/{initrd.img,vmlinuz} -P /var/lib/tftpboot/pxelinux/centos6
在 pxelinux.cfg/ 目录中添加名为 default 的配置文件。
vi pxelinux.cfg/default
----------------------------
UI vesamenu.c32
prompt 1
timeout 600
menu title Install Linux and Windows by PXE
label linux
menu label ^Install Centos7.4 Min
menu default
kernel centos7.4/vmlinuz
append initrd=centos7.4/initrd.img ip=dhcp inst.repo=http://172.16.30.121/centos7.4 inst.ks=http://172.16.30.121/kickstarts/Centos-7.x-min.cfg
############ centos6.x ks=http://xxxxx don't inst.ks=http
label linux
menu label ^Install Centos6.x Min
kernel centos6/vmlinuz
append initrd=centos6/initrd.img ip=dhcp repo=nfs:nfsvers=4:172.16.30.121:/opt/nfsdata/linux-iso/centos6.9 ks=http://172.16.30.121/kickstarts/Centos-6.x-min.cfg ksdevice=eth1
label linux
menu label ^Install Windows 10
kernel memdisk raw iso
append initrd=win/W10X32_CN_PE.iso
label vesa
menu label Install system with ^basic video driver
kernel centos7.4/vmlinuz
append initrd=centos7.4/initrd.img ip=dhcp inst.xdriver=vesa nomodeset inst.repo=http://172.16.30.121/centos7.4
label local
menu label Boot from ^local drive
localboot 0xffff
----------------------------
systemctl start dhcpd xinetd
上面的default配置文件为通过kickstarts配置文件自动安装系统,如果对配置文件不熟悉,请去掉ks文件参数,手动安装即可。
此上面配置为通过BOIS引导启动,centos6/7 ubuntu14/16 esxi6/6.5 windows等都可以正常引导启动。
=========================================================================
=========================================================================
如果使用UEFI,需要做以下修改。
创建uefi/grub.cfg
------------------
set timeout=60
### END /etc/grub.d/00_header ###
#search --no-floppy --set=root -l 'CentOS 7 x86_64'
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Install CentOS 7 Min UEFI' {
linuxefi /uefi/centos7.4/vmlinuz ip=dhcp inst.repo=http://172.16.30.121/centos7.4 inst.ks=http://172.16.30.121/kickstarts/Centos-7.x-min.cfg
initrdefi /uefi/centos7.4/initrd.img
}
menuentry 'Install CentOS 6 Min UEFI' {
linuxefi /uefi/centos6/vmlinuz ip=dhcp repo=http://172.16.30.121/centos6.9 ks=http://172.16.30.121/kickstarts/Centos-6.x-min.cfg
initrdefi /uefi/centos6/initrd.img
}
menuentry 'Ubuntu 16.04 amd64' {
set isofile="/uefi/ubuntu16/ubuntu-16.04.iso"
loopback loop $isofile
linuxefi (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile liveimg noprompt noeject quiet splash --
initrdefi (loop)/casper/initrd.lz
menuentry 'Install Windows 10 UEFI' {
linuxefi /uefi/memdisk raw iso
initrdefi /uefi/win/W10X32_CN_PE.iso
}
menuentry 'Test this media & install CentOS 7' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet
initrdefi /images/pxeboot/initrd.img
}
submenu 'Troubleshooting -->' {
menuentry 'Install CentOS 7 in basic graphics mode' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 xdriver=vesa nomodeset quiet
initrdefi /images/pxeboot/initrd.img
}
menuentry 'Rescue a CentOS system' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rescue quiet
initrdefi /images/pxeboot/initrd.img
}
}
---------------------
2.创建内核链接
cd /var/lib/tftpboot/uefi
ln -s ../pxelinux/centos6 .
ln -s ../pxelinux/centos7.4 .
ln -s ../pxelinux/win .
UEFI配置完毕,centos7 uefi 测试成功,centos6.9和windows10提示内核太老,无法引导。
===========================================================================================
===========================================================================================
如果使用UEFI 启动centos6、centos7、windows或其它操作系统,建议使用centos6.9里面的BOOTX64.efi
cd /var/lib/tftpboot/uefi
wget http://172.16.30.121/centos6.9/EFI/BOOT/{BOOTX64.efi,splash.xpm.gz} .
注意centos6.9 EFI配置文件名称为efidefault,与BOOTX64.efi同目录即可。
创建efidefault文件
------------
#debug --graphics
default=0
splashimage=(nd)/splash.xpm.gz
timeout 5
hiddenmenu
title CentOS 6.9 UEFI
root (nd)
kernel /centos6/vmlinuz ip=dhcp ks=http://172.16.30.121/kickstarts/Centos-6.x-min.cfg repo=http://172.16.30.121/centos6.9 ksdevice=eth1
initrd /centos6/initrd.img
title CentOS 7.4 UEFI
root (nd)
kernel /centos7.4/vmlinuz ip=dhcp ks=http://172.16.30.121/kickstarts/Centos-7.x-min.cfg repo=http://172.16.30.121/centos7.4
initrd /centos7.4/initrd.img
title Install system with basic video driver
kernel /images/pxeboot/vmlinuz nomodeset askmethod
initrd /images/pxeboot/initrd.img
title rescue
kernel /images/pxeboot/vmlinuz rescue askmethod
initrd /images/pxeboot/initrd.img
----------------------
测试可以正常的通过UEFI 启动引导。
以上是关于网络启动二:之PXE:CentOS6.9+TFTP+DHCP+BOIS+UEFI部署操作系统。的主要内容,如果未能解决你的问题,请参考以下文章