需求:
1、legacy启动
2、/boot分区1G,剩余给/,lvm分区
3、创建root密码和一个普通用户user,密码Hello@2024
4、服务器安装(选上development、legacy-unix、security-tools)
5、关闭firewalld、selinux
操作
1、本地虚拟机安装openEuler2203SP3
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/
yum -y install createrepo genisoimage isomd5sum rsync
/usr/bin/rsync -a /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-SP3-x86_64 quiet|append initrd=initrd.img inst.stage2=hd:LABEL=openEuler-22.03-LTS-SP3-x86_64 inst.ks=hd:LABEL=openEuler-22.03-LTS-SP3-x86_64:/isolinux/ks.cfg quiet|' /ISO/isolinux/isolinux.cfg
sed -i -e '/menu default/d' -e '/menu label ^Install openEuler 22.03-LTS-SP3/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-SP3-x86_64
5、复制ks并修改
cp /root/anaconda-ks.cfg /ISO/isolinux/ks.cfg
5.1 graphical修改为text
5.2格式化重新分区(boot分区1G,剩余给跟)
clearpart --all --initlabel --drives=sda
# Disk partitioning information
part biosboot --fstype="biosboot" --ondisk=sda --size=2
part pv.1001 --fstype="lvmpv" --ondisk=sda --size=1 --grow
part /boot --fstype="xfs" --ondisk=sda --size=512
volgroup openeuler --pesize=4096 pv.1001
logvol / --fstype="xfs" --size=1 --grow --name=root --vgname=openeuler
logvol swap --fstype="swap" --size=2048 --name=swap --vgname=openeuler
5.3基础环境
selinux --disabled
firewall --disabled
reboot
# Generated by Anaconda 36.16.5
# Generated by pykickstart v3.47
#version=DEVEL
# Use graphical install
graphical
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8
# Use hard drive installation media
#harddrive --dir= --partition=LABEL=openEuler-22.03-LTS-SP3-x86_64
cdrom
%packages
@^server-product-environment
@development
@legacy-unix
@security-tools
%end
# Run the Setup Agent on first boot
firstboot --enable
# Generated using Blivet version 3.4.2
ignoredisk --only-use=sda
# Partition clearing information
#clearpart --none --initlabel
clearpart --all --initlabel --drives=sda
# Disk partitioning information
part biosboot --fstype="biosboot" --ondisk=sda --size=2
part pv.1001 --fstype="lvmpv" --ondisk=sda --size=1 --grow
part /boot --fstype="xfs" --ondisk=sda --size=512
volgroup openeuler --pesize=4096 pv.1001
logvol / --fstype="xfs" --size=1 --grow --name=root --vgname=openeuler
logvol swap --fstype="swap" --size=2048 --name=swap --vgname=openeuler
# 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
selinux --disabled
firewall --disabled
reboot
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-SP3-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盘刻录