Reactivation of debian grub on efi dual-boot machine
2016-05-20 at 20:35:03 | categories: tips, linuxTwo years ago I got hands on a brand new Lenovo Z500 laptop with pre-installed Windows 8. It came with UEFI booting system. Following some advices on the Internet I installed a Debian Linux as the main system and Windows as a second choice.
When system started I was greeted by grub where I could select "debian" and all was nice. To start Windows I used F12 key at boot time and choose "windows" from a menu there. Worked like a charm.
A few days ago during standard update of packages I reinstalled grub and problems started.
First of all it did not boot anymore. It just stopped at (grub-rescue). And I already forgot all the steps needed to make it work again. It took me few evenings to figure that out (again), so I decided to write it down here - for myself (for a next time) and maybe for someone else who run into similar troubles.
Steps to recovery
Get something to start with
Step 1. Get Debian Install CD and write if (dd
) to USB stick.
Make sure BIOS settings are OK
Step 2. In BIOS make sure you have the system using UEFI mode. This is needed for efitools like efibootmgr and of course for Linux kernel.
Step 3. In BIOS disable safe mode - it prevented me to start using USB stick.
Step 4. In BIOS enable booting from USB in EFI mode.
Start system from GRUB of the Linux CD/USB
Step 5. Start the system with USB stick with Linux on it.
Step 6. Go to grub options - "C".
Step 7. At grub prompt you can list your partitions (ls
) - you should see your root
partition there. In my case it was not there because I used lvm. So at grub
prompt I needed insmod lvm
. Then ls
showed me my partition (in my case
(lvm/debian-root)
).
Step 8. Start your system from grub:
set root=(lvm/debian-root) // or wherever your root partition is linux /vmlinuz root=/dev/mapper/root initrd /initrd.img boot
All that assumes that on root level of your root partition you have vmlinuz and initrd.img files. You need to point to those.
Make changes permanent
Your system should boot as before. To make changes stick I followed https://wiki.debian.org/GrubEFIReinstall with some extra remarks - keep reading :-).
Step 9. Find out where is your efi partition. In my case it was /dev/sda2.
Step 10. Remove /sys/firmware/efi/efivars/dump*. I had to do that to make space. Without that step changes to NVRAM failed for me and I was unable to boot.
Step 11. Follow the steps from the link above: mount efi partition at /boot/efi,
install grub-efi
, install grub to /dev/sda and call update-grub
.
Step 12. Then check if your debian
is visible via efibootmgr
. It was not the case
for me until I did step 10.
It works again!
After all that it works again. I hope I will find this description when it happens again.