Tuesday, August 18, 2015

How to fix grub-efi Debian 8 after windows 10 upgrade

After and during upgrading your Windows (with EFI/GPT) into Windows 10, grub-efi will broken.
----------------------------
Symtom:
----------------------------
error: no such partition
Entering rescue mode...
grub rescue>

1. Find linux
grub rescue> ls
(hd0) (hd0,gpt7) (hd0,gpt6) (hd0,gpt5) (hd0,gpt4) (hd0,gpt3) (hd0,gpt2) (hd0,gpt1) (hd1)
grub rescue> ls (hd0,gpt6)
(hd0,gpt6): Filesystem is unknown.
grub rescue> ls (hd0,gpt7)
(hd0,gpt7): Filesystem is ext2.
2. It is mark as (hd0,gpt7) as ext2. We search boot directory
grub rescue> ls (hd0,gpt7)/boot
./ ../ ...... /grub ......
3. It is contains folder boot. Good! We set root and prefix for normal boot
grub rescue> set root=(hd0,gpt7)
grub rescue> set prefix=(hd0,gpt7)/boot/grub
grub rescue> insmod normal
grub rescue> normal
4. Finish your Windows installation or upgrade. You may need to repeat step no. 3, everytime Windows ask you to restart your computer.
5. Using step no. 3, we enter Debian OS to repair grub. We reinstall grub-efi-amd64, or run apt-get install without --reinstall to install grub-efi-amd64
apt-get install --reinstall grub-efi-amd64
6. Create directory /boot/efi
# mkdir /boot/efi
7. Search partition for EFI
# fdisk -l
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 2248606F-393A-467A-9527-D0649049F9E3
Device         Start       End   Sectors   Size Type
/dev/sda1       2048    616447    614400   300M Windows recovery environment
/dev/sda2     616448    821247    204800   100M EFI System
/dev/sda3     821248   1083391    262144   128M Microsoft reserved
/dev/sda4    1083392 244840447 243757056 116.2G Microsoft basic data
/dev/sda5  245762048 567171071 321409024 153.3G Microsoft basic data
/dev/sda6  567171072 582795263  15624192   7.5G Linux swap
/dev/sda7  582795264 976771071 393975808 187.9G Microsoft basic data
8. We found EFI partition at /dev/sda2. Mount partition EFI into /boot/efi
# mount /dev/sda2 /boot/efi/
9. We install grub into EFI partition
# grub-install /dev/sda
Installing for x86_64-efi platform.
Installation finished. No error reported.
10. Done, you may restart your Debian.

No comments:

Post a Comment