[root@dream ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)
[root@dream ~]# mount rhel-server-7.6-x86_64-dvd.iso /media/
[root@dream ~]# yum -y install createrepo mkisofs isomd5sum rsync
[root@dream ~]# rsync -a --exclude=Packages/ --exclude=repodata/ /media/ /ISO/ ###exclude:不复制此目录
[root@dream ~]# mkdir -p /ISO/{Packages,repodata}
如果不确定安装包,可以都直接复制过去,这里演示安装所需要安装包的方法
[root@dream ~]# rpm -qa >> /root/install.log ###获取已经安装包
### 复制包到/ISO/Packages,如果第三方包通过yun安装的话,也可以直接放进去
[root@dream ~]# awk '{print $0}' /root/install.log |xargs -i cp /media/Packages/{}.rpm /ISO/Packages/
inst.stage2=hd:LABEL=
rhel7
: rhel7后面生成镜像时候使用(genisoimage的参数-V)
inst.ks=cdrom:/isolinux/ks.cfg
: 指定通过此ks进行自动安装,如果把这条删除就会手动进行安装
menu default
: 设置为默认启动
[root@dream ISO]# pwd
/ISO
[root@dream ISO]# chmod 755 isolinux/isolinux.cfg
[root@dream ISO]# vim isolinux/isolinux.cfg
61 label linux
62 menu label ^Install Red Hat Enterprise Linux 7.6
63 menu default
64 kernel vmlinuz
65 append initrd=initrd.img inst.stage2=hd:LABEL=rhel7 inst.ks=cdrom:/isolinux/ks.cfg quiet
66
67 label check
68 menu label Test this ^media & install Red Hat Enterprise Linux 7.6
69 kernel vmlinuz
70 append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.6\x20Server.x86_64 rd.live.check quiet
[root@dream ISO]# chmod 444 isolinux/isolinux.cfg
[root@dream ISO]# vim isolinux/ks.cfg
install
# Keyboard layouts
keyboard us
# Root password
rootpw --iscrypted $1$nD88pFjh$H9Kd9/Zp2J3jR.dxP9JBv0
# (Required) Wrapper around the authconfig command CCE-14063-2 (row 80)
authconfig --enableshadow --passalgo=sha512
# System language
lang en_US.UTF-8
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use text mode install
text
# Run the Setup Agent on first boot
firstboot --disable
ignoredisk --only-use=sda
logging --level=info
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Network information
network --bootproto=dhcp --device=em1 --onboot=on
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --location=mbr --driveorder=sda --append=""
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
part biosboot --fstype=biosboot --size=1
part /boot --fstype=ext4 --ondisk=sda --size=500
part pv.01 --grow --ondisk=sda --size=1
volgroup OS_vg pv.01
logvol / --fstype=ext4 --vgname=OS_vg --size=102400 --name=lv_root
logvol /home --fstype=ext4 --vgname=OS_vg --size=51200 --name=lv_home
logvol swap --vgname=OS_vg --size=40960 --name=lv_swap
%post --nochroot
#!/bin/sh
set -x -v
exec 1>/mnt/sysimage/root/kickstart-stage1.log 2>&1
echo "==> copying files from media to install drive..."
cp -r /run/install/repo/postinstall /mnt/sysimage/root
%end
%post
#!/bin/sh
set -x -v
exec 1>/root/kickstart-stage2.log 2>&1
cd /root/postinstall
chmod 755 *.sh
sh install.sh
%end
%packages
@base
@compat-libraries
@development
@java-platform
@x11
@kde-desktop
%end
[root@dream ISO]# mkdir -p postinstall/mysoft ###里面放入lsscsi-0.30r148.tgz
[root@dream ISO]# vim postinstall/install.sh ###添加自定义安装内容
#!/bin/bash
mkdir -p /opt/soft
mv /root/postinstall/mysoft/lsscsi-0.30r148.tgz /opt/soft/
cd /opt/soft/
tar -xvzf lsscsi-0.30r148.tgz
cd /opt/soft/lsscsi-0.30r148/
./configure
make & make install
[root@dream ISO]# cp /media/repodata/*-comps-Server.x86_64.xml /ISO/repodata/comps.xml
[root@dream ISO]# createrepo -g repodata/comps.xml ./
[root@dream ISO]# genisoimage -joliet-long -V rhel7 -o rhel-server-7.6-storage-x86_64-dvd.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -cache-inodes -T -eltorito-alt-boot -e images/efiboot.img -no-emul-boot /ISO
[root@dream ISO]# implantisomd5 /ISO/rhel-server-7.6-storage-x86_64-dvd.iso
Inserting md5sum into iso image...
md5 = 05864a5dff022db2c9ff8d634625ef67
Inserting fragment md5sums into iso image...
fragmd5 = d5ace274175fcf1e561f8b6f44c9bec1d9af11dbb924aa158b45522f32c7
frags = 20
Setting supported flag to 0
服务器
-->>虚拟控制台预览处点击启动
虚拟控制台
" -->>设置"插件类型
“为”HTML5
"虚拟介质
-->>映射 CD/DVD
中点击选择文件
-->>找到镜像 -->> 点击映射设备
设置
" -->>第一个引导设备
设置为虚拟 CD/DVD/ISO
并勾选引导一次
-->>点击应用
即可[root@dream ~]# rm -rf /ISO/*
[root@dream ~]# mkdir /rhel7
[root@dream ~]# mount rhel-server-7.6-storage-x86_64-dvd.iso /rhel7
[root@dream ~]# cp -rp /rhel7/* /ISO
如果不更新,可能包会装不上
[root@dream ISO]# rm -rf /ISO/repodata/*
[root@dream ISO]# cp /media/repodata/*-comps-Server.x86_64.xml /ISO/repodata/comps.xml
[root@dream ISO]# createrepo -g repodata/comps.xml ./
[root@dream ISO]# genisoimage -joliet-long -V rhel7 -o rhel-server-7.6-storage-x86_64-dvd.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -cache-inodes -T -eltorito-alt-boot -e images/efiboot.img -no-emul-boot /ISO