本文采用VMware进行CentOS7最小化封装,定制部分安装包。
前提:虚拟机安装好CentOS7,具体可参考:虚拟机安装CentOS7
一、基础环境准备
规划:
将/root/iso做为定制镜像制作目录;
将/root/MISO作为挂载镜像的目录。
[root@linux01 ~]# cd /root/
[root@linux01 ~]# mkdir iso MISO
## 挂载镜像;并将/MISO目录下的所有内容copy到镜像制作目录;
[root@linux01 ~]# mount -o loop,rw /dev/cdrom MISO
[root@linux01 ~]# cp -a MISO/* /root/iso/
安装镜像制作所需工具
[root@linux01 ~]# yum install -y createrepo mkisofs isomd5sum squashfs-tools
修改/root/iso/isolinux/isolinux.cfg文件,修改如下内容
[root@linux01 ~]# vim /root/iso/isolinux/isolinux.cfg
default vesamenu.c32
timeout 300 ##安装系统时的默认引导时间,修改为30秒
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 ###安装系统背景图片;更换背景界面;替换为需要的图片,保持文件名不变,图片大小640x480
menu title Haier Minimal CentOS 7 ##可以定制欢迎标题
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 Haier Minimal CentOS 7.8 ###定制系统标题
menu default # 指定其为默认引导项
kernel vmlinuz
append initrd=initrd.img ks=cdrom:/isolinux/ks.cfg inst.stage2=hd:LABEL=CentOS7.8 quiet net.ifnames=0 biosdevname=0
##ks=cdrom:/isolinux/ks.cfg :指定自动化安装配置ks文件;可以用系统默认生成的anaconda-ks.cfg文件。
##inst.stage2=hd:LABEL= :为安装介质位置,hd:LABEL为介质标签,例如:CentOS##net.ifnames=0 biosdevname=0 :使用这个参数将网卡名改为ethX
###可以将这个标签选项注销。
label check
menu label Test this ^media & install CentOS 7
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_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 CentOS 7 in ^basic graphics mode
text help
Try this option out if you're having trouble installing
CentOS 7.
endtext
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 xdriver=vesa nomodeset quiet
label rescue
menu indent count 5
menu label ^Rescue a CentOS 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=CentOS\x207\x20x86_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
提前创建需要导入系统自定义软件和文件存放目录
[root@linux01 ~]# mkdir /root/iso/software
[root@linux01 ~]# cd /root/iso/software
上传需要导入的安装包和文件到此目录,此处根据需要上传即可,没有可以不传。
编辑isolinux/ks.cfg文件;也可以用/root/anaconda-ks.cfg,此处采用修改anaconda-ks.cfg方式配置
[root@linux01 ~]# cp -a /root/anaconda-ks.cfg /root/iso/isolinux/ks.cfg
[root@linux01 ~]# vim /root/iso/isolinux/ks.cfg
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8
# Network information
network --bootproto=dhcp --onboot=yes --activate
network --hostname=haier
# Root password
rootpw --iscrypted $6$ZDuWuuLZGuBLgq77$9wAUf2C.A.rWG6AD8wVJ224mBo6pONUo9oJK0dksPYIZhGKAoyioFnuUXHf0UPGn4lMWf5xbNmPN1VIXscASA0
# System services
services --enabled="chronyd"
# 关闭 SELinux
selinux --disabled
# 关闭防火墙
firewall --disabled
# 系统服务开机自启
services --enabled="sshd"
# System timezone
timezone Asia/Shanghai --isUtc
# X Window System configuration information
xconfig --startxonboot
# System bootloader configuration
bootlo