re-initialize bootable mirror

brainsoft

Member
Jun 25, 2024
31
2
8
Hi everyone,
I think I know exactly what caused the problem, and have some general idea of the process to restore, but there's something I am missing here.

Short story, I was relocating my boot drive to a set of mirrored drives. Clone partition table, randomize IDs, format, initialize, add mirror to zpool. rinse and repeat.

I did this without any issues on the second machine, but when I did the first machine, I definately missed the "init" step in the process. I obviously rebooted several times without incident, but but now it appears it completely forgot how to boot.

I can get to console with the proxmox install usb, and can import the zfs rpool without issue and see both drives .part3 in the pool, but I just need some help to re-build the EFI/boot partitions so it will boot from bios again.

Of course being direct on the machine instead of via ssh will make copy/paste anything a bit more complicated for the process but I really appreciate the help!

I feel like I need to mount the rpool resources and redirect the live environment to it so that proxmox-boot-tool will act on the proper files because proxmox-boot-tool status says that /et/kernel/proxmox-boot-uuids does not exist, so I think this sould be a pretty simple fix that I just haven't built the skills for yet.

Any help is appreciated!
 
There may be a more streamlined way to do this built in that I'm not aware of, but I would follow these general steps in your situation:

*Don't blanket copy paste any of the command examples, make sure you are looking through what you are doing at each step.
  1. From Proxmox installer USB, Import/mount your rpool
    1. zpool import -f rpool
    2. zfs list #to find dataset path, assuming rpool/root/pve for rest of instructions
    3. zfs mount rpool/root/pve
  2. Confirm partition layout and note the devices
    1. lsblk or similar
  3. Format ESP partitions
    1. mkfs.vfat -F 32 /dev/sdXXXXXXXXXXX
    2. mkfs.vfat -F 32 /dev/sdyyyyyyyyyyy
  4. Mount root filesystem and get your chroot ready
    1. mount -t zfs rpool/root/pve /mnt
    2. mount --rbind /dev /mnt/dev
    3. mount --rbind /proc /mnt/proc
    4. mount --rbind /sys /mnt/sys
  5. Chroot in
    1. chroot /mnt /bin/bash
  6. Init the boot partitions wit hthe proxmox-boot-tool
    1. proxmox-boot-tool init /dev/sdxxxxxxxx
    2. proxmox-boot-tool init /dev/sdyyyyyyyy
  7. Refresh with the proxmox-boot-tool
    1. proxmox-boot-tool refresh
  8. Update grub (If the boot tool fails to create for some reason,
    1. update-grub
  9. Verify both ESPs showing
    1. proxmox-boot-tool status
  10. Reboot
 
I'll check it out but this feels like what I was expecting and read somewhere else but didn't want to dive without some more information.

Just to check, mkfs.vfat be pointing to the part2, same as init?

When I did the original mirror/migration, I used proxmox-boot-tool format... and proxmox-boot-tool init..., both on -part2, and then attached -part3 to the zpool.
 
Worked through, couple issues and lots of learning lessons along the way.

need to rebind /run as well or the grub executable isn't available! (Thanks Google ai)

And mounting the zpool to /mnt directly during import simplified things. (Also thanks Google ai)

Never blindly copy and paste for sure, but handy non-the-less.
 
I'll check it out but this feels like what I was expecting and read somewhere else but didn't want to dive without some more information.

Just to check, mkfs.vfat be pointing to the part2, same as init?

When I did the original mirror/migration, I used proxmox-boot-tool format... and proxmox-boot-tool init..., both on -part2, and then attached -part3 to the zpool.
Gotcha, yes you want to confirm you're doing these steps on the right partition. Obviously your device names will differ but should be able to verify with similar methodology.

gdisk -l /dev/sdxxxxx
Look for the partition marked as EF00 (EFI System Partition) - That's the one you need to format and init

For example, on my live Proxmox node if I was doing a similar exercise...

Bash:
root@proxmox1:~# gdisk -l /dev/nvme0n1 | tail -n 4
Number  Start (sector)    End (sector)  Size       Code  Name
   1              34            2047   1007.0 KiB  EF02 
   [B]2            2048         2099199   1024.0 MiB  EF00  <------- This is the ESP[/B]
   3         2099200      1000215182   475.9 GiB   8E00


Code:
# Format the ESP partitions
mkfs.vfat -F 32 /dev/nvme0n1p2
mkfs.vfat -F 32 /dev/nvme1n1p2 

# Init the boot partitions
proxmox-boot-tool init /dev/nvme0n1p2
proxmox-boot-tool init /dev/nvme1n1p2
 
Here's was my process for anyone in the future. Did everything by-id instead of shortcuts but it worked great and I learned a lot along the way.

------------

#Mount pool to temporary location
zpool import -f -R /mnt rpool

#prepare chroot environment
mount -R /dev /mnt/dev
mount -R /proc /mnt/proc
mount -R /sys /mnt/sys
mount -R /run /mnt/run
chroot /mnt /bin/bash

#format EFI partitions
proxmox-boot-tool format /dev/disk/by-id/ata-Netac_SSD_120GB_YS581296399139783932-part2
proxmox-boot-tool format /dev/disk/by-id/ata-Netac_SSD_120GB_YS581296399139784728-part2

#init EFI partitions
proxmox-boot-tool init /dev/disk/by-id/ata-Netac_SSD_120GB_YS581296399139783932-part2
proxmox-boot-tool init /dev/disk/by-id/ata-Netac_SSD_120GB_YS581296399139784728-part2

#Clean /etc/kernel/proxmox-boot-uuids of old entries
proxmox-boot-tool status
proxmox-boot-tool refresh
proxmox-boot-tool clean

#REBOOT!
#initramfs may be unhappy as rpool was seeing other boot environments, but...
initramfs> zpool import -f rpool
 
  • Like
Reactions: UdoB and sva
Great work! Glad you were able to take it, run with it, and have a fun learning experience along the way.

Good catch on /mnt/run and using the by-id's is a good call.