mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-18 20:39:14 +08:00
128 lines
3.6 KiB
INI
128 lines
3.6 KiB
INI
|
# shellcheck disable=2148,2215
|
|||
|
# 设置
|
|||
|
keyboard --vckeymap=us --xlayouts='us'
|
|||
|
lang en_US.UTF-8
|
|||
|
timezone Asia/Shanghai --utc
|
|||
|
rootpw --plaintext 1
|
|||
|
text
|
|||
|
reboot
|
|||
|
%include /tmp/include-url-command
|
|||
|
|
|||
|
# 分区
|
|||
|
ignoredisk --only-use="hda|sda|vda|nvme0n1"
|
|||
|
bootloader # 甲骨文x86输出到控制台添加 --append="console=ttyS0,9600"
|
|||
|
clearpart --all --initlabel
|
|||
|
reqpart # 如果需要,自动创建 efi 或 biosboot 分区
|
|||
|
part / --fstype=ext4 --grow # 不用 xfs 因为不能缩小容量
|
|||
|
|
|||
|
# 软件
|
|||
|
%packages --ignoremissing # el9 minimal.iso fedora Server repo/iso 没有 tuned
|
|||
|
@^Minimal Install
|
|||
|
tuned
|
|||
|
%include /tmp/include-packages-for-resize
|
|||
|
|
|||
|
# 不删除usb相关的包,因为甲骨文云有usb设备,作用未知
|
|||
|
# -usb_modeswitch
|
|||
|
# -usbutils
|
|||
|
|
|||
|
# 无线
|
|||
|
-iw
|
|||
|
-crda
|
|||
|
-rfkill
|
|||
|
# shellcheck disable=2211
|
|||
|
-iwl*-firmware
|
|||
|
|
|||
|
# 虚拟机用不上
|
|||
|
-irqbalance # 多核+直通设备可能有用?
|
|||
|
-microcode_ctl
|
|||
|
-smartmontools
|
|||
|
-aic94xx-firmware
|
|||
|
-alsa-firmware
|
|||
|
-ivtv-firmware
|
|||
|
# -linux-firmware # 去除后安装centos 8会报错
|
|||
|
|
|||
|
%end
|
|||
|
|
|||
|
# 禁用防火墙
|
|||
|
# firewall --disabled
|
|||
|
|
|||
|
# 禁用 selinux
|
|||
|
selinux --disabled
|
|||
|
|
|||
|
# 禁用 kdump
|
|||
|
%addon com_redhat_kdump --disable
|
|||
|
%end
|
|||
|
|
|||
|
##############################################
|
|||
|
%pre
|
|||
|
touch /tmp/include-packages-for-resize
|
|||
|
# 有 installer 分区,表示用了两步安装
|
|||
|
if [ -e /dev/disk/by-label/installer ]; then
|
|||
|
# 1g内存下,安装器默认开启了zram ,但安装f38还是不够内存,所以还要开启swap
|
|||
|
mkdir /installer
|
|||
|
mount /dev/disk/by-label/installer /installer
|
|||
|
mount /dev/disk/by-label/installer /installer -o remount,rw
|
|||
|
swapfile=/installer/swapfile
|
|||
|
if -v fallocate; then
|
|||
|
fallocate -l 1GiB $swapfile
|
|||
|
else
|
|||
|
dd if=/dev/zero of=$swapfile bs=1MiB count=1024
|
|||
|
fi
|
|||
|
chmod 0600 $swapfile
|
|||
|
mkswap $swapfile
|
|||
|
swapon $swapfile
|
|||
|
|
|||
|
# 两步安装最后扩容要用的软件
|
|||
|
# feroda 默认不包含 cronie
|
|||
|
# cloud-utils-growpart 需要用到 gdisk 处理 gpt 分区
|
|||
|
cat <<EOF >/tmp/include-packages-for-resize
|
|||
|
cronie
|
|||
|
cloud-utils-growpart
|
|||
|
gdisk
|
|||
|
EOF
|
|||
|
fi
|
|||
|
|
|||
|
# 重新整理 extra,因为grub会处理掉引号,要重新添加引号
|
|||
|
# 提取 extra.localtest extra.confhome extra.mirrorlist
|
|||
|
for var in $(grep -o '\bextra\.[^ ]*' /proc/cmdline | xargs); do
|
|||
|
eval " $(echo $var | sed -E "s/extra\.([^=]*)=(.*)/\1='\2'/")"
|
|||
|
done
|
|||
|
|
|||
|
# 设置安装源
|
|||
|
include=/tmp/include-url-command
|
|||
|
distro=$(awk -F: '{ print $3 }' </etc/system-release-cpe)
|
|||
|
releasever=$(awk -F: '{ print $5 }' </etc/system-release-cpe)
|
|||
|
# shellcheck disable=SC2154
|
|||
|
if [ "$localtest" = 1 ]; then
|
|||
|
echo "url --url=$confhome/$releasever/" >$include
|
|||
|
# echo cdrom >$include
|
|||
|
else
|
|||
|
echo "url --mirrorlist=$mirrorlist" >$include
|
|||
|
# 对于el7/fedora, 添加了 updates repo 才会安装最新的包
|
|||
|
if [ "$releasever" = "7" ] || [ "$distro" = "fedoraproject" ]; then
|
|||
|
echo "repo --name=updates" >>$include
|
|||
|
fi
|
|||
|
fi
|
|||
|
%end
|
|||
|
|
|||
|
##############################################
|
|||
|
%post
|
|||
|
# el9/fedora 需手动开启 root ssh 密码登录
|
|||
|
# rootpw --allow-ssh 9.1 以上才支持
|
|||
|
distro=$(awk -F: '{ print $3 }' </etc/system-release-cpe)
|
|||
|
releasever=$(awk -F: '{ print $5 }' </etc/system-release-cpe)
|
|||
|
if [ "$releasever" = "9" ] || [ "$distro" = "fedoraproject" ]; then
|
|||
|
echo "PermitRootLogin yes" >/etc/ssh/sshd_config.d/01-permitrootlogin.conf
|
|||
|
fi
|
|||
|
|
|||
|
# 分步安装的系统,要将最后一个分区(installer)合并到系统分区
|
|||
|
if [ -e /dev/disk/by-label/installer ]; then
|
|||
|
# 提取 extra.confhome
|
|||
|
eval "$(grep -o '\bextra\.[^ ]*' /proc/cmdline | sed 's/\bextra.//')"
|
|||
|
|
|||
|
cd /
|
|||
|
curl -O $confhome/resize.sh
|
|||
|
echo '@reboot root bash /resize.sh' >/etc/cron.d/resize
|
|||
|
fi
|
|||
|
%end
|