mirror of
https://github.com/bin456789/reinstall.git
synced 2025-06-08 05:19:57 +00:00
ubuntu: 修复 do-release-upgrade 时 grub 报错
This commit is contained in:
parent
f3d8694567
commit
84c893150f
35
trans.sh
35
trans.sh
@ -3884,15 +3884,17 @@ chroot_apt_remove() {
|
|||||||
|
|
||||||
# 不能用 apt remove --purge -y xxx yyy
|
# 不能用 apt remove --purge -y xxx yyy
|
||||||
# 因为如果索引里没有其中一个,会报错,另一个也不会删除
|
# 因为如果索引里没有其中一个,会报错,另一个也不会删除
|
||||||
# 因此需要分开删除
|
local pkgs=
|
||||||
for package in "$@"; do
|
for pkg in "$@"; do
|
||||||
# apt list 会提示 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
|
# apt list 会提示 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
|
||||||
# 但又不能用 apt-get list
|
# 但又不能用 apt-get list
|
||||||
if chroot $os_dir apt list --installed "$package" | grep -q installed; then
|
if chroot $os_dir apt list --installed "$pkg" | grep -q installed; then
|
||||||
# 删除 resolvconf 时会弹出建议重启,因此添加 noninteractive
|
pkgs="$pkgs $pkg"
|
||||||
DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get remove --purge -y "$package"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# 删除 resolvconf 时会弹出建议重启,因此添加 noninteractive
|
||||||
|
DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get remove --purge --allow-remove-essential -y $pkgs
|
||||||
}
|
}
|
||||||
|
|
||||||
chroot_apt_autoremove() {
|
chroot_apt_autoremove() {
|
||||||
@ -4360,6 +4362,24 @@ configfile \$prefix/grub.cfg
|
|||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 避免 do-release-upgrade 时自动执行 dpkg-reconfigure grub-xx 但是 efi/biosgrub 分区不存在而导致报错
|
||||||
|
# shellcheck disable=SC2046
|
||||||
|
chroot_apt_remove $os_dir $(is_efi && echo 'grub-pc' || echo 'grub-efi*' 'shim*')
|
||||||
|
chroot_apt_autoremove $os_dir
|
||||||
|
|
||||||
|
# 安装 mbr
|
||||||
|
if ! is_efi; then
|
||||||
|
if false; then
|
||||||
|
# debconf-show grub-pc
|
||||||
|
# 每次开机硬盘名字可能不一样,但是 debian netboot 安装后也是设置了 grub-pc/install_devices
|
||||||
|
echo grub-pc grub-pc/install_devices multiselect /dev/$xda | chroot $os_dir debconf-set-selections # 22.04
|
||||||
|
echo grub-pc grub-pc/cloud_style_installation boolean true | chroot $os_dir debconf-set-selections # 24.04
|
||||||
|
chroot $os_dir dpkg-reconfigure -f noninteractive grub-pc
|
||||||
|
else
|
||||||
|
chroot $os_dir grub-install /dev/$xda
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# 自带内核:
|
# 自带内核:
|
||||||
# 常规版本 generic
|
# 常规版本 generic
|
||||||
# minimal 20.04/22.04 kvm # 后台 vnc 无显示
|
# minimal 20.04/22.04 kvm # 后台 vnc 无显示
|
||||||
@ -4442,11 +4462,6 @@ EOF
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 安装 bios 引导
|
|
||||||
if ! is_efi; then
|
|
||||||
chroot $os_dir grub-install /dev/$xda
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 更改 efi 目录的 grub.cfg 写死的 fsuuid
|
# 更改 efi 目录的 grub.cfg 写死的 fsuuid
|
||||||
# 因为 24.04 fsuuid 对应 boot 分区
|
# 因为 24.04 fsuuid 对应 boot 分区
|
||||||
efi_grub_cfg=$os_dir/boot/efi/EFI/ubuntu/grub.cfg
|
efi_grub_cfg=$os_dir/boot/efi/EFI/ubuntu/grub.cfg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user