Friday, June 26, 2026

Sparky-aptus-upgrade on Sparky Linux 2026 06 instance in UEFI mode

One of the most recent  sparky-aptus-upgrade wipes out old boot-loader and prompts you to install new boot-loader . It suggests the options vda,vda2 (/boot ext4),vda3 ("/" btrfs) , neither one of options suggested is correct due to /boot/efi is mounted on /dev/vda1.  The workaround is to reject install new boot-loader and wait until  sparky-aptus-upgrade would exit warning you that boot-loader is missing. Then initiate ssh session to instance of Sparky Linux and issue 

$ sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=sparky --recheck && \
sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --removable && \
sudo update-grub

$ sudo reboot  

This step is important for successful executing of disaster  recovery procedure on Sparky Linux 2026 06 instance with "/" on BTRFS . All commands below are supposed to run in Sparky Live Instance environment against Sparky instance been crashed on vda device (VENV simulation)  

*****************************************************            Phase 1 ( in general, standard step utilizing of low level btrfs CLI )  

***************************************************** 

# 1. Create mount anchors
mkdir -p /mnt/btrfs-top   /mnt/system-root
 
# 2. Mount top-level BTRFS volume
mount -o subvolid=5 /dev/vda3   /mnt/btrfs-top
 
# 3. Move broken subvolume out of the way
mv /mnt/btrfs-top/@     /mnt/btrfs-top/@_broken
 
# 4. Clone snapshot to target @ (Verify your exact Timeshift folder path here)
btrfs subvolume snapshot /mnt/btrfs-top/timeshift-btrfs/snapshots/YYYY-MM-DD_HH-MM-SS/@  /mnt/btrfs-top/@
 
******************************************** 
Phase 2 ( /boot/efi recovery  proposed by Google AI )
*************************************************
 # 5. Mount newly restored root subvolume
mount -o subvol=@ /dev/vda3 /mnt/system-root
 
# 6. Mount dedicated boot partition
mount /dev/vda2 /mnt/system-root/boot
 
# 7. Wipe and re-create the corrupted FAT32 EFI partition
mkfs.vfat -F32 /dev/vda1
 
# 8. Mount the freshly formatted EFI partition
mount /dev/vda1 /mnt/system-root/boot/efi
 
# 9. Bind-mount required virtual filesystems
for i in /dev /dev/pts /proc /sys /run; do mount -B $i /mnt/system-root$i; done
 
# 10. AUTOMATIC FSTAB REPAIR: Fixed regex for FAT32 UUID matching
NEW_UUID=$(blkid -s UUID -o value /dev/vda1)
sed -i -E "s/UUID=\S+(.*\/boot\/efi)/UUID=$NEW_UUID\1/" /mnt/system-root/etc/fstab
 
# 11. Enter the restored operating system jail and restore both EFI targets
chroot /mnt/system-root /bin/bash -c "
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=sparky --recheck && \
grub-install --target=x86_64-efi --efi-directory=/boot/efi --removable && \
update-grub
"
 # 12. Clean up and restart
cd /
umount -R /mnt/system-root
umount -R /mnt/btrfs-top
poweroff
 


No comments:

Post a Comment