最近刚下载了rhel8,闲来无事写一写rhel8的pxe安装,有不当之处,多多指教。废话不多说,直接上干货。
为了方便随时离线使用,我在笔记本上先安装了一个vmare虚拟机,这样就可以随身携带了。
首先建议关闭防火墙和selinux,将虚拟机的ip地址配置为100.100.100.100/24
DNF/YUM源搭建
为了方便离线使用,我将rhel8.iso中的所有文件都copy到/var/ftp/rhel8cd路径下了。
然后修改/etc/yum.repo.d下的文件,将file://var/ftp/rhel8cd/BaseOS和file://var/ftp/rhel8cd/AppStream都加到仓库了。
这里要多说一句,相比较rhel6/7,rhel8的packages被分类放到了AppStream和BaseOS,所以我这里添加了2个路径。
pxe客户端安装的时候dnf/yum仓库也需要手动添加一下(我还没有发现怎么自动添加AppStream和BaseOS中的2个packages路径,欢迎大家留言指正)。
vi /etc/yum.repo.d/rhel-source-8.repo
[rhel8-Base]
name=Red Hat Enterprise Linux
baseurl=file:///var/ftp/rhel8cd/BaseOS
enabled=1
gpgcheck=0
[rhel8-APP]
name=Red Hat Enterprise Linux APP
baseurl=file:///var/ftp/rhel8cd/AppStream
enabled=1
gpgcheck=0
vsftp安装
dnf -y install vsftpd
打开自启动 systemctl enable vsftpd
rhel8的ftp匿名访问默认是关闭的,在这里我们需要打开匿名访问。
vi /etc/vsftpd/vsftpd.conf 修改匿名访问为YES anonymous_enable=YES
tftp安装
dnf -y install tftp
dnf -y install tftp-server
dnf -y install xinetd
vi /etc/xinetd.d/tftp
#default: off
#description: The tftp server serves files using the trivial file transfer \
#protocol. The tftp protocol is often used to boot diskless \
#workstations, download configuration files to network-aware printers, \
#and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
打开自启动 systemctl enable xinetd
tftp安装
dnf -y install dhcp-server
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;
allow booting;
allow bootp;
default-lease-time 6000;
max-lease-time 72000;
subnet 100.100.100.0 netmask 255.255.255.0 {
range 100.100.100.101 100.100.100.200;
option routers 100.100.100.100;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
next-server 100.100.100.100;
if option client-system-arch = 00:07 or option client-system-arch = 00:09 {
filename "uefi/BOOTX64.EFI";
} else {
filename "legacy/pxelinux.0";
}
}
}
打开自启动 systemctl enable dhcpd
legacy模式可以用,uefi的我还没有验证是否可用。
安装syslinux
dnf -y install syslinux
这个我忘了是否需要安装
安装legacy引导文件
cp /var/ftp/rhel8cd/images/pxeboot/vmlinuz /var/lib/tftpboot/legacy
cp /var/ftp/rhel8cd/images/pxeboot/initrd.img /var/lib/tftpboot/legacy
cp /var/ftp/rhel8cd/isolinux/ldlinux.c32 /var/lib/tftpboot/legacy
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/legacy
mkdir /var/lib/tftpboot/legacy/pxelinux.cfg
cp /var/ftp/rhel8cd/isolinux/isolinux.cfg /var/lib/tftpboot/legacy/pxelinux.cfg/default
vim /var/lib/tftpboot/legacy/pxelinux.cfg/default
default linux
prompt 0
timeout 600
display boot.msg
# Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title Red Hat Enterprise Linux 8.0.0
menu vshift 8
menu rows 18
menu margin 8
#menu hidden
menu helpmsgrow 15
menu tabmsgrow 13
# Border Area
menu color border * #00000000 #00000000 none
# Selected item
menu color sel 0 #ffffffff #00000000 none
# Title bar
menu color title 0 #ff7ba3d0 #00000000 none
# Press [Tab] message
menu color tabmsg 0 #ff3a6496 #00000000 none
# Unselected menu item
menu color unsel 0 #84b8ffff #00000000 none
# Selected hotkey
menu color hotsel 0 #84b8ffff #00000000 none
# Unselected hotkey
menu color hotkey 0 #ffffffff #00000000 none
# Help text
menu color help 0 #ffffffff #00000000 none
# A scrollbar of some type? Not sure.
menu color scrollbar 0 #ffffffff #ff355594 none
# Timeout msg
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none
# Command prompt text
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none
# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.
menu tabmsg Press Tab for full configuration options on menu items.
menu separator # insert an empty line
menu separator # insert an empty line
label linux
menu label ^Install Red Hat Enterprise Linux 8.0.0
kernel vmlinuz
append initrd=initrd.img inst.repo=ftp://100.100.100.100/rhel8cd inst.ks=ftp://100.100.100.100/rhel8cd/ks-8.cfg
label check
menu label Test this ^media & install Red Hat Enterprise Linux 8.0.0
menu default
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-8-0-0-BaseOS-x86_64 rd.live.check quiet
menu separator # insert an empty line
# utilities submenu
menu begin ^Troubleshooting
menu title Troubleshooting
label vesa
menu indent count 5
menu label Install Red Hat Enterprise Linux 8.0.0 in ^basic graphics mode
text help
Try this option out if you're having trouble installing
Red Hat Enterprise Linux 8.0.0.
endtext
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-8-0-0-BaseOS-x86_64 nomodeset quiet
label rescue
menu indent count 5
menu label ^Rescue a Red Hat Enterprise Linux system
text help
If the system will not boot, this lets you access files
and edit config files to try to get it booting again.
endtext
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-8-0-0-BaseOS-x86_64 rescue quiet
label memtest
menu label Run a ^memory test
text help
If your system is having issues, a problem with your
system's memory may be the cause. Use this utility to
see if the memory is working correctly.
endtext
kernel memtest
menu separator # insert an empty line
label local
menu label Boot from ^local drive
localboot 0xffff
menu separator # insert an empty line
menu separator # insert an empty line
label returntomain
menu label Return to ^main menu
menu exit
menu end
安装uefi引导文件
cp /var/ftp/rhel8cd/images/pxeboot/vmlinuz /var/lib/tftpboot/uefi
cp /var/ftp/rhel8cd/images/pxeboot/initrd.img /var/lib/tftpboot/uefi
cp /var/ftp/rhel8cd/EFI/BOOT/BOOTX64.EFI /var/lib/tftpboot/uefi
cp /var/ftp/rhel8cd/EFI/BOOT/grub.cfg /var/lib/tftpboot/uefi
cp /var/ftp/rhel8cd/EFI/BOOT/grubx64.efi /var/lib/tftpboot/uefi
vim /var/lib/tftpboot/uefi/grub.cfg
set default="0"
function load_video {
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
insmod all_video
}
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set timeout=6
### END /etc/grub.d/00_header ###
search --no-floppy --set=root -l 'RHEL-8-0-0-BaseOS-x86_64'
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Install Red Hat Enterprise Linux 8.0.0' --class fedora --class gnu-linux --class gnu --class os {
linuxefi uefi/vmlinuz inst.ks=ftp://100.100.100.100/rhel8cd/ks-8.cfg inst.repo=ftp://100.100.100.100/rhel8cd/
initrdefi uefi/initrd.img
}
menuentry 'Test this media & install Red Hat Enterprise Linux 8.0.0' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=RHEL-8-0-0-BaseOS-x86_64 rd.live.check quiet
initrdefi /images/pxeboot/initrd.img
}
submenu 'Troubleshooting -->' {
menuentry 'Install Red Hat Enterprise Linux 8.0.0 in basic graphics mode' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=RHEL-8-0-0-BaseOS-x86_64 nomodeset quiet
initrdefi /images/pxeboot/initrd.img
}
menuentry 'Rescue a Red Hat Enterprise Linux system' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=RHEL-8-0-0-BaseOS-x86_64 rescue quiet
initrdefi /images/pxeboot/initrd.img
}
}
生成KS.cfg文件
vi /var/ftp/rhel8cd/ks-8.cfg
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
#Install OS instead of upgrade
install
#Keyboard layouts
keyboard 'us'
#Root password
rootpw --plaintext 123456
#Use network installation
url --url="ftp://100.100.100.100/rhel8cd"
#System language
lang zh_CN
#System authorization information
auth --useshadow --passalgo=sha512
#Use graphical install
graphical
firstboot --disable
#SELinux configuration
selinux --disabled
#Firewall configuration
firewall --disabled
#Network information
network --bootproto=dhcp --device=eth0
#Reboot after installation
reboot
#System timezone
timezone Asia/Shanghai
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype="xfs" --ondisk=sda --size=1024
part /boot/efi --fstype="xfs" --ondisk=sda --size=1024
part swap --fstype="swap" --ondisk=sda --size=2000
part / --fstype="xfs" --grow --ondisk=sda --size=1
%packages
@base
@core
@desktop-debugging
@development
@dial-up
@file-server
@fonts
@ftp-server
@gnome-desktop
@guest-agents
@guest-desktop-agents
@hardware-monitoring
@infiniband
@input-methods
@internet-browser
@java-platform
@large-systems
@mainframe-access
@mariadb
@multimedia
@network-file-system-client
@performance
@postgresql
@print-client
@security-tools
@smart-card
samba
telnet
telnet-server
wireshark
boost-devel
postgresql-devel
openssl-devel
%end
%addon com_redhat_kdump --disable --reserve-mb='auto'
%end
重启rhel8就可以使用了。
文中所使用到的配置文件,我都打包上传共享了,https://download.csdn.net/download/maokan2008/11925298。
转载请说明原文出处。