Sometimes when dual-booting Windows or while tinkering/updating Linux bootloader gets broken. Luckily
repairing it does not requires reinstalling Linux. There are number of methods of repairing it:
This method requires little technical abilities; it's good starting point.
- Boot to live environment created from Ubuntu Desktop 24.04
- Select Try Ubuntu
- Open terminal window
- Add PPA for boot-repair; it's unofficial user repository designed for Ubuntu specifically by yannubuntu:
sudo add-apt-repository ppa:yannubuntu/boot-repair
- Update APT cache. This does not install or update any package:
sudo apt update
- Install boot-repair package
sudo apt install -y boot-repair
- Start boot-repair
boot-repair
- Follow on-screen instructions. You might be asked to execute some commands in terminal. boot-repair will
inform you when it ends, and whether it assumes GRUB was repaired.
This method requires that you understand layout of your filesystem. Mistake will result in loss of data.
- Boot to live environment created from Ubuntu Server 24.04
- Open TTY2 (by pressing Ctrl+Alt+F2)
- Start tmux session
- Confirm layout and names of disk devices
lsblk
- Only if root or boot is on LVM: scan for LVM partitions
sudo pvscan
- Only if root or boot is on LVM: activate LVM partition
sudo vgchange -ay /dev/ubuntu-vg/ubuntu-lv
- Create temporary root mount point (if you change this or any further path correct them yourself)
mkdir /root/root/
- Mount root device to temporary root mount point
sudo mount /dev/ubuntu-vg/ubuntu-lv
- Only if boot is on different device: create temporary boot mount point within mounted root device
sudo mkdir /root/root/bootpart
- Only if boot is on different device: mount boot device to temporary boot mount point within mounted root
device
sudo mount /dev/sda2 /root/root/bootpart
- Mount necessary special devices within temporary root mount point
sudo mount --bind /dev /root/root/dev
sudo mount --bind /sys /root/root/sys
sudo mount --bind /proc /root/root/proc
- Chroot into temporary root mount point
sudo chroot /root/root
- Confirm layout and names of disk devices within chroot
lsblk
- Install GRUB
sudo grub-install --boot-directory=/bootpart /dev/sda
- Update GRUB
sudo update-grub
- Exit and reboot
Last update: 2024-05-20