ubuntu: 安装大厂内核

This commit is contained in:
bin456789
2023-08-28 19:33:53 +08:00
parent 347cd9ccc8
commit 15de1ac098
2 changed files with 29 additions and 5 deletions

View File

@ -7,6 +7,8 @@ autoinstall:
source:
id: ubuntu-server-minimal
search_drivers: false
kernel:
package: linux-generic
timezone: Asia/Shanghai
ssh:
allow-pw: true
@ -18,7 +20,7 @@ autoinstall:
# https://askubuntu.com/questions/1302392/ubuntu-server-20-04-setup-stuck-at-block-probing-did-not-discover-any-disks
mount | grep /isodevice && { losetup -d /dev/loop0; umount -l /isodevice; } || true
# 提取 extra.confhome
# 提取 extra.confhome extra.kernel
prefix=extra
for var in $(grep -o "\b$prefix\.[^ ]*" /proc/cmdline | xargs); do
eval "$(echo $var | sed -E "s/$prefix\.([^=]*)=(.*)/\1='\2'/")"
@ -27,18 +29,23 @@ autoinstall:
# 生成分区信息
curl -L $confhome/ubuntu-storage-early.sh | bash -s
# 内核风味
# https://bugs.launchpad.net/subiquity/+bug/1989353
sed -i "s/generic/$kernel/" /run/kernel-meta-package
sed -i "/package:/s/generic/$kernel/" /autoinstall.yaml
# 禁用 DNS 强制离线安装内核和跳过最后的更新
# 但安装器会配置时区和写入最近的mirror到/etc/apt/sources.list 所以要提前解析
# dig会显示cname结果cname会以.结尾grep -v '\.$' 表示去除 cname 结果
echo $(dig +short geoip.ubuntu.com | grep -v '\.$' | head -1) geoip.ubuntu.com >>/etc/hosts
sed -i -E 's/(^nameserver )/#\1/' /etc/resolv.conf
# echo $(dig +short geoip.ubuntu.com | grep -v '\.$' | head -1) geoip.ubuntu.com >>/etc/hosts
# sed -i -E 's/(^nameserver )/#\1/' /etc/resolv.conf
late-commands:
- |
# root ssh 登录
echo "PermitRootLogin yes" >/target/etc/ssh/sshd_config.d/01-permitrootlogin.conf
# 还原 DNS
sed -i -E 's/^#(nameserver )/\1/' /etc/resolv.conf
# sed -i -E 's/^#(nameserver )/\1/' /etc/resolv.conf
# 提取 extra.confhome
prefix=extra