As I was messing with making my EFI partition larger, I managed to corrupt the system. My best guess was that my new partition sizes weren't properly (re)loaded before I formated them. Thus, even though both boot
and EFI
partitions had all files properly restored, during boot I would end up dropped into the Grub prompt.
While I do not often end up in such situation, I already know grub from my Surface Go adventures. So I did what I had done many times before (gpt2
is my boot partition):
set root=(hd0,gpt2)
linux /vmlinuz-6.8.0-28-generic
initrd /initrd.img-6.8.0-28-generic
This moved needle a bit by dumped me into the initramfs prompt. At least here it did helpfully indicate that the issue was (corrupted disk). However, it was obvious something was still wrong as my root ZFS partition was nowhere to be found. Thus, no fsck to fix the issue.
Initial thought was to just load ZFS filesystem:
zpool import Tank/System
zfs mount Tank/System
exit
Well, this actually caused the system to crash as filesystem wasn't properly overlaid. So I had to figure out either how to reload the root partition from the initramfs prompt or to go back to the drawing board.
Thankfully, Looking at my other computer's Grub configuration, I noticed the way forward. There, I saw that linux
command has an extra ZFS-related argument. Thus, I adjusted my grub commands accordingly (the example below assumes the root dataset is Tank/System
):
set root=(hd0,gpt2)
linux /vmlinuz-6.8.0-28-generic root=ZFS=Tank/System
initrd /initrd.img-6.8.0-28-generic
boot
And this brought my system back to its bootable self.
PS: Since the boot file system was actually readable, I decided to simply copy files to a temporary location, format both boot
and EFI
partitions, and then copy the data back.
mkdir /mnt/{efi,boot}-copy
rsync -avxAHWX /boot/efi/ /mnt/efi-copy/
rsync -avxAHWX /boot/ /mnt/boot-copy/
umount /boot/efi
umount /boot
DISK1=</dev/disk/by-id/...>
yes | mkfs.ext4 $DISK1-part2
mkfs.vfat -F 32 -n EFI -i 4d65646f $DISK1-part1
mount /boot
mount /boot/efi
rsync -avxAHWX /mnt/boot-copy/ /boot/
rsync -avxAHWX /mnt/efi-copy/ /boot/efi/
rm -rf /mnt/{boot,efi}-copy
[2024-10-05] If you didn't copy all permissions for files, you might need to reapply grub too:
grub-install --target=x86_64-efi --efi-directory=/boot/efi \
--bootloader-id=Ubuntu --recheck --no-floppy