需求:
1、legacy启动
2、/boot分区1G,剩余给/
3、创建root密码和一个普通用户user,密码Hello@2024
4、最小化安装(选上development、legacy-unix、security-tools、standard)
5、关闭firewalld、selinux
6、增加安装vim、ntpdate、iptables、expect
操作
1、本地虚拟机安装openEuler2203SP1
2、挂载本地yum源
mkdir -p /media/cdrom
mount /dev/cdrom /media/cdrom
cd /etc/yum.repos.d/
mkdir tmp
mv *.repo tmp/
cat > local.repo <<EOF
[BaseOS]
cachedir=/var/cache/dnf
keepcache=1
name=BaseOS
baseurl=file:///media/cdrom/
enabled=1
gpgcheck=0
EOF
sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf
cat >> /etc/fstab <<EOF
/dev/cdrom /media/cdrom iso9660 defaults 0 0
EOF
cat /etc/fstab
3、创建自定义镜像目录及工具下载
mkdir -p /ISO/Packages
rpm -qa > /root/install.log
awk '{print $0}' /root/install.log |xargs -i cp /media/cdrom/Packages/{}.rpm /ISO/Packages/
yum -y install createrepo genisoimage isomd5sum rsync
/usr/bin/rsync -a --exclude=Packages/ /media/cdrom/ /ISO/
4、修改isolinux.cfg文件
4.1 倒计时60秒修改成5s
4.2 默认启动从Test this ^media & install修改为^Install【第一个启动】
4.3 修改ks配置【inst.ks=cdrom:/isolinux/ks.cfg】
sed -i -e 's|append initrd=initrd.img inst.stage2=hd:LABEL=openEuler-22.03-LTS-SP1-x86_64 quiet|append initrd=initrd.img inst.stage2=hd:LABEL=openEuler-22.03-LTS-SP1-x86_64 inst.ks=hd:LABEL=openEuler-22.03-LTS-SP1-x86_64:/isolinux/ks.cfg quiet|' /ISO/isolinux/isolinux.cfg
sed -i -e '/menu default/d' -e '/menu label ^Install openEuler 22.03-LTS-SP1/a\ menu default' -e 's/timeout 600/timeout 50/' /ISO/isolinux/isolinux.cfg
PS
inst.stage2为安装介质位置
inst.ks为ks.cfg文件位置
Inst.repo为安装系统时指定安装源
hd:LABEL为介质标签,openEuler-22.03-LT1-SP2-x86_64
5、复制ks并修改
cp /root/anaconda-ks.cfg /ISO/isolinux/ks.cfg
5.1 graphical修改为text
5.2格式化重新分区(boot分区1G,剩余给跟)
#clearpart --all --initlabel
clearpart --all --initlabel --drives=sda
part /boot --fstype="ext4" --ondisk=sda --size=1024
part / --fstype="ext4" --ondisk=sda --grow
5.3基础环境
selinux --disabled
firewall --disabled
reboot
# Generated by Anaconda 36.16.5
# Generated by pykickstart v3.34
#version=DEVEL
# Reboot after installation
reboot
# Use text mode install
text
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Firewall configuration
firewall --disabled
#harddrive --dir= --partition=LABEL=openEuler-22.03-LTS-SP1-x86_64
# Use CDROM installation media
cdrom
%packages
@^minimal-environment
@development
@legacy-unix
@security-tools
@standard
expect
iptables
ntpdate
vim
%end
# SELinux configuration
selinux --disabled
# Run the Setup Agent on first boot
firstboot --enable
# Do not configure the X Window System
skipx
# Generated using Blivet version 3.4.2
ignoredisk --only-use=sda
# Partition clearing information
clearpart --all --initlabel --drives=sda
# Disk partitioning information
part /boot --fstype="ext4" --ondisk=sda --size=1024
part / --fstype="ext4" --ondisk=sda --grow
# System timezone
timezone Asia/Shanghai --utc
# Root password
rootpw --iscrypted $6$sCxDdp9qTLWUXFjh$.wrvPnlNP0w0vXTuwZ41D4QA0PGSYJeH2EyVSoBXGNuknmezU0apq9QFM8xHbL0z1x1Fu9wnfdE3ygeNOebGz1
user --groups=wheel --name=user --password=$6$GxZA4o5IcppEnNJ2$Q0ZtaBX9ORpKIZHuQVHgyA3n.3Ha1iGbk.X/jvlCXMoi.06q9zgr7vOlrMB45VrHJ79roHmHS35AWn0am6KZt. --iscrypted --uid=1000 --gecos="user" --gid=1000
PS:密码加密
[root@localhost ISO]# python3 -c 'import crypt; print(crypt.crypt("Hello@2024"))'
$6$sCxDdp9qTLWUXFjh$.wrvPnlNP0w0vXTuwZ41D4QA0PGSYJeH2EyVSoBXGNuknmezU0apq9QFM8xHbL0z1x1Fu9wnfdE3ygeNOebGz1
[root@localhost ISO]# python3 -c 'import crypt; print(crypt.crypt("Hello@2024"))'
$6$GxZA4o5IcppEnNJ2$Q0ZtaBX9ORpKIZHuQVHgyA3n.3Ha1iGbk.X/jvlCXMoi.06q9zgr7vOlrMB45VrHJ79roHmHS35AWn0am6KZt.
6、生成镜像
cd /ISO
genisoimage -joliet-long -V openEuler-22.03-LTS-SP1-x86_64 -o /root/openEuler-22.03.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
implantisomd5 /root/openEuler-22.03.iso
7、导出镜像,U盘刻录