I have installed a debian based distribution on my drive. When I installed it, the / mountpoint was btrfs on a logical partition (/dev/sda7) with a mount point for /boot/efi on a fat32 logical partition (/dev/sda6).
I since wanted to use the savedefault feature of grub, which doesn't work on btrfs. So I booted up a live image with gparted and shrunk /boot/efi (/dev/sda6) added an ext4 partition /dev/sda8.
After that I adjusted /etc/fstab
to use the new mount point and then followed the steps to repair grub.
- mount the root file system
mkdir /tmp/rootfs && mount /dev/sda7 /tmp/rootfs
- mount the boot drive on the mounted file system
mount /dev/sda8 /tmp/rootfs/@/boot
- mount the efi partition
mount /dev/sda6 /tmp/rootfs/@/boot/efi
- mount sys
mount --bind /sys /tmp/rootfs/@/sys
- mount dev
mount --bind /dev /tmp/rootfs/@/dev
- mount proc
mount --bind /proc /tmp/rootfs/@/proc
- for good measure mount home
mount --bind /tmp/rootfs/@home /tmp/rootfs/@/home
- chroot into the rootfs
chroot /tmp/rootfs
- repair grub, apparently
To repair grub I used this command:
grub-install /dev/sda
And it says it's successful. However when I then try to boot the system I get this error:
GRUB loading...
Welcome to GRUB!
error: file `/@/boot/grub/i386-pc/normal.mod´ not found.
grub rescue>
Of course it can't find it there because it's not in /@/boot/ anymore. I think this is an error with the stage 1 bootloader in the MBR. How do I fix that? I use an msdos partition table.
I have also managed to boot the system from grub loaded from a USB drive with this command
set root=(hd1,msdos8)
linux /vmlinuz root=LABEL=LinuxRoot rootflags=subvol=@ quiet splash rw
initrd /initrd
boot
I have tried to reinstall grub from there as well, with no success. I have also tried this command, which also didn't work (says successful, but same error appears on reboot).
grub-install --bootloader-id=grub --target=x86_64-efi --efi-directory=/boot/efi --no-nvram /dev/sda
I was able to resolve this properly by converting my msdos partition table to a gpt partition table. I did that by booting a live cd and running
Afterwards I had to reinstall the windows bootloader with a live medium and open a command prompt. Then run this sequence of commands to install a new bootloader to the EFI partition.
After that I just had to reinstall grub (target x86_64-efi). os-probe didn't detect windows, so I had to add it manually by adding it a new file
/etc/grub.d/42-windows
file like soAfter that run
sudo update-grub
and everything works fine.I was able to fix it by booting into the system as described above and then running
After reboot, run:
At this point everything is working as before. I just don't know why.