PVE 引导损坏修复记录

前几星期支持了国产固态,买了致态 SC001。装上之后发现我 PVE 的引导丢失了,折腾了好久,发现其实也挺简单,就总结一下。因为懒没有第一时间记录,本文可能与实际有偏差。

根据官方的说法“Proxmox VE 安装程序在为以下选择的所有磁盘上创建3个分区安装。”我直接在安装 PVE 的固态分好三个区。一个 1 MB BIOS 引导分区和一个 512 MB 的 EFI 系统分区。直接用安装镜像的U盘选择 Install Proxmox VE(Debugmode) 进入系统。使用 proxmox-boot-tool 重新创建引导,参考https://pve.proxmox.com/wiki/Host_Bootloader#sysboot_proxmox_boot_tool

Setting up a new partition for use as synced ESP To format and initialize a partition as synced ESP, e.g., after replacing a failed vdev in an rpool, or when converting an existing system that pre-dates the sync mechanism, proxmox-boot-tool from pve-kernel-helpers can be used.

the format command will format the , make sure to pass in the right device/partition!
For example, to format an empty partition /dev/sda2 as ESP, run the following:

proxmox-boot-tool format /dev/sda2
To setup an existing, unmounted ESP located on /dev/sda2 for inclusion in Proxmox VE’s kernel update synchronization mechanism, use the following:

proxmox-boot-tool init /dev/sda2
Afterwards /etc/kernel/proxmox-boot-uuids should contain a new line with the UUID of the newly added partition. The init command will also automatically trigger a refresh of all configured ESPs.

Updating the configuration on all ESPs
To copy and configure all bootable kernels and keep all ESPs listed in /etc/kernel/proxmox-boot-uuids in sync you just need to run:

proxmox-boot-tool refresh
(The equivalent to running update-grub systems with ext4 or xfs on root).

This is necessary should you make changes to the kernel commandline, or want to sync all kernels and initrds.

Both update-initramfs and apt (when necessary) will automatically trigger a refresh.

如果屏幕显示grub rescue > 则参考https://pve.proxmox.com/wiki/Recover_From_Grub_Failure

ecover From Grub Failure During to the upgrade from 3.x to 4.x, I found myself without a working grub and unable to boot. Monitor shows:

grub rescue >
You can use Proxmox installation ISO in verison 5.4 or newer, and select debug mode. On the second prompt you'll have the full Linux tools, including LVM, ZFS, ..., available. If you exit that prompt you will come to the installation screens, simply hit abort there.

Alternatively, one can use a 64 bit version of Ubuntu or Debian Rescue CD.

Boot Proxmox VE in debug mode, or the Ubuntu/Debian off the ISO. We do not want to install Ubuntu/Debian, just run it live off the ISO/DVD.

First We need to activate LVM and mount the the root partition that is inside the LVM container.

sudo vgscan
sudo vgchange -ay
Mount all the filesystems that are already there so we can upgrade/install grub. Your paths may vary depending on your drive configuration.

sudo mkdir /media/RESCUE
sudo mount /dev/pve/root /media/RESCUE/
sudo mount /dev/sda1 /media/RESCUE/boot
sudo mount -t proc proc /media/RESCUE/proc
sudo mount -t sysfs sys /media/RESCUE/sys
sudo mount -o bind /dev /media/RESCUE/dev
sudo mount -o bind /run /media/RESCUE/run
Chroot into your proxmox install.

chroot /media/RESCUE
Then update grub and install it.

grub-install /dev/sda
If there are no error messages, you should be able to reboot now.

Credit: https://www.nerdoncoffee.com/operating-systems/re-install-grub-on-proxmox

不过以上方法我觉得麻烦,最后选择的是安装镜像修复。 最后会出现 Timed out waiting for device dev-disk-by\... 无法正常启动进入 grub,这是因为新建的 efi 分区,和之前的 id 不同导致的。直接

sudo blkid #查找 efi 分区的 id
sudo vi /etc/fstab

参考 https://unix.stackexchange.com/questions/471716/timed-out-waiting-for-device-dev-disk-by-x2duuid-c829-x2dc4c1-device