mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-18 20:39:14 +08:00
ubuntu: 安装大厂内核
This commit is contained in:
parent
347cd9ccc8
commit
15de1ac098
19
trans.sh
19
trans.sh
@ -1307,6 +1307,23 @@ install_redhat_ubuntu() {
|
||||
download $iso /os/installer/ubuntu.iso
|
||||
console_cmdline=$(get_ttys console=)
|
||||
|
||||
apk add dmidecode
|
||||
dmi=$(dmidecode)
|
||||
# https://github.com/systemd/systemd/blob/main/src/basic/virt.c
|
||||
# https://github.com/canonical/cloud-init/blob/main/tools/ds-identify
|
||||
# http://git.annexia.org/?p=virt-what.git;a=blob;f=virt-what.in;hb=HEAD
|
||||
if echo "$dmi" | grep -Eiw "amazon|ec2"; then
|
||||
kernel=aws
|
||||
elif echo "$dmi" | grep -Eiw "Google Compute Engine|GoogleCloud"; then
|
||||
kernel=gcp
|
||||
elif echo "$dmi" | grep -Eiw "OracleCloud"; then
|
||||
kernel=oracle
|
||||
elif echo "$dmi" | grep -Eiw "7783-7084-3265-9085-8269-3286-77"; then
|
||||
kernel=azure
|
||||
else
|
||||
kernel=generic
|
||||
fi
|
||||
|
||||
# 正常写法应该是 ds="nocloud-net;s=https://xxx/" 但是甲骨文云的ds更优先,自己的ds根本无访问记录
|
||||
# $seed 是 https://xxx/
|
||||
cat <<EOF >$grub_cfg
|
||||
@ -1316,7 +1333,7 @@ install_redhat_ubuntu() {
|
||||
# rmmod tpm
|
||||
search --no-floppy --label --set=root installer
|
||||
loopback loop /ubuntu.iso
|
||||
linux (loop)/casper/vmlinuz iso-scan/filename=/ubuntu.iso autoinstall noprompt noeject cloud-config-url=$ks $extra_cmdline --- $console_cmdline
|
||||
linux (loop)/casper/vmlinuz iso-scan/filename=/ubuntu.iso autoinstall noprompt noeject cloud-config-url=$ks $extra_cmdline extra.kernel=$kernel --- $console_cmdline
|
||||
initrd (loop)/casper/initrd
|
||||
}
|
||||
EOF
|
||||
|
15
ubuntu.yaml
15
ubuntu.yaml
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user