From c03a9a96b2bca4a741f83bc327ca12f530fdc18b Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sat, 30 Nov 2024 23:34:56 +0800 Subject: [PATCH] =?UTF-8?q?alpine:=20=E4=BF=AE=E5=A4=8D=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=9B=BA=E4=BB=B6=E5=BE=AE=E7=A0=81=E6=97=B6=20grub-probe=20?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit link #209 --- trans.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/trans.sh b/trans.sh index 564e22a..44296ff 100644 --- a/trans.sh +++ b/trans.sh @@ -1215,6 +1215,9 @@ install_alpine() { export BOOTLOADER="grub" setup-disk -m sys -k $kernel_flavor /os + # 删除 setup-disk 时自动安装的包 + apk del e2fsprogs dosfstools efibootmgr grub* + # 安装到硬盘后才安装各种应用 # 避免占用 Live OS 内存 @@ -1246,6 +1249,13 @@ install_alpine() { chroot /os setup-timezone -i Asia/Shanghai chroot /os setup-ntp chrony || true + # 安装固件微码会触发 grub-probe + # 如果没挂载会报错 + # Executing grub-2.12-r5.trigger + # /usr/sbin/grub-probe: error: failed to get canonical path of `/dev/vda1'. + # ERROR: grub-2.12-r5.trigger: script exited with error 1 + mount_pseudo_fs /os + # 安装固件微码 # shellcheck disable=SC2046 if is_need_ucode_firmware; then @@ -1254,20 +1264,11 @@ install_alpine() { # 3.19 或以上,非 efi 需要手动安装 grub if ! is_efi; then - grub-install --boot-directory=/os/boot --target=i386-pc /dev/$xda + chroot /os grub-install --target=i386-pc /dev/$xda fi # efi grub 添加 fwsetup 条目 - if is_efi; then - mount_pseudo_fs /os - chroot /os update-grub - fi - - # 删除 chroot 历史记录 - rm -rf /os/root/.ash_history - - # 关闭 swap 前删除应用,避免占用内存 - apk del e2fsprogs dosfstools grub* + chroot /os update-grub # 是否保留 swap if [ -e /os/swapfile ]; then