Repairing GRUB boot stuck at initramfs prompt (on AWS)
/
55
From initramfs prompt: Mount the necessary filesystems and chroot into the new environment
mkdir -p /new_root
mount /dev/nvme0n1p2 /new_root
mount --bind /proc /new_root/proc
mount --bind /sys /new_root/sys
mount --bind /dev /new_root/dev
chroot /new_root
Once at bash prompt:
Step 1: Get the new PARTUUID for /dev/nvme0n1p2 using blkid
new_uuid=$(blkid -s PARTUUID -o value /dev/nvme0n1p2)
echo "New PARTUUID is: $new_uuid"
Step 2: Extract the old UUID from /boot/grub/grub.cfg
old_uuid=$(grep -oP 'set partuuid=\K([a-fA-F0-9\-]+)' /boot/grub/grub.cfg)
echo "Old PARTUUID is: $old_uuid"
Step 3: Replace all instances of the old UUID in grub.cfg with the new UUID
sed -i "s/$old_uuid/$new_uuid/g" /boot/grub/grub.cfg
echo "Replaced old PARTUUID with new PARTUUID in /boot/grub/grub.cfg"
Return to initramfs and reboot
exit
reboot -f