Repair grub - encrypted and unencrypted systems

Post your tutorials and howtos here.
User avatar
ilu
Posts: 2160
Joined: 09 Oct 2013 12:45

Repair grub - encrypted and unencrypted systems

Postby ilu » 07 Feb 2019 00:39

I'm posting here Arjen's explanation on how to repair grub using the SolydXK live system from another thread:
-------------------------------------------------------------------------------------------------------------------------------------------------------
For anybody who doesn't know how to do that. Here follows a short description of the steps to take to restore boot with a SolydXK live session:

Mount root partition:

Code: Select all

$ live-chroot /dev/sda2
In chroot: compare mounted partitions in fstab and blkid to get /boot partition(s)

Code: Select all

# cat /etc/fstab
# sudo blkid
In my case I have a separate /boot and /boot/efi partition:

Code: Select all

# mount /dev/sda4 /boot
# mount /dev/sda1 /boot/efi
Install Grub2:

Code: Select all

# grub-install /dev/sda
Ignore the "GUID Partition Table Header signature" errors. You're in a chrooted session. The last line matters, though: "Installation finished. No error reported."

Update Grub2:

Code: Select all

# update-grub
Unmount /boot partition(s) and exit.

Code: Select all

# umount /boot/efi /boot
# exit
Now, reboot and cross your fingers.

User avatar
ilu
Posts: 2160
Joined: 09 Oct 2013 12:45

Re: Repair grub - encrypted and unencrypted systems

Postby ilu » 07 Feb 2019 00:47

If the system is encrypted, this is the way to go:

Become root:

Code: Select all

sudo -i
Decrypt and mount /root - check which exact partition holds /root.

Code: Select all

root@solydxk:~# cryptsetup luksOpen /dev/sdaX linux
Enter passphrase for /dev/sdaX: 
root@solydxk:~# live-chroot /dev/mapper/linux
/etc/live-installer-3/live-installer-3.conf: line 10: --assume-yes: command not found
/etc/live-installer-3/live-installer-3.conf: line 11: --quiet: command not found
Use configured target: /target
Create directory /target
Mounting /dev/mapper/linux on /target
Chrooting into /target
Reinstall and update grub - check which exact partition to mount.

Code: Select all

root@solydxk:/# mount /dev/sdaX /boot
root@solydxk:/# mount /dev/sda1 /boot/efi
root@solydxk:/# grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
root@solydxk:/# update-grub
Generating grub configuration file ...
Found background image: .background_cache.png
Found linux image: ...
done
You might check the situation with

Code: Select all

root@solydxk:/# bootinfoscript

User avatar
ilu
Posts: 2160
Joined: 09 Oct 2013 12:45

Re: Repair grub - encrypted and unencrypted systems

Postby ilu » 08 Feb 2019 00:02

If you have a multiboot EFI system and it refuses to boot into the right grub environment, check which one it loads with:

Code: Select all

sudo efibootmgr
efibootmgr --help
to see the options. You can change the boot order there. If you need to clean up be careful not to touch anything from Microsoft, the entry named "boot" belongs to Windows. More explanation here: https://www.dedoimedo.com/computers/gru ... overy.html and here https://www.dedoimedo.com/computers/gru ... overy.html.


Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 1 guest