Introduction / Why This Is Needed
GRUB (Grand Unified Bootloader) is a bootloader that appears when you turn on your computer and allows you to select an operating system or kernel version. The GRUB configuration is automatically generated based on files in /boot and detected partitions. You need to update it when:
- You installed a new OS (like Windows or another Linux distribution) alongside Ubuntu.
- You removed an old kernel or updated your system.
- You changed disk partitioning (created/deleted partitions).
- The GRUB menu does not display the needed systems or shows errors.
This guide will help you correctly rebuild the GRUB configuration in just a few minutes so everything works stably.
Requirements / Preparation
Before starting, ensure that:
- You have terminal access to Ubuntu with administrator privileges (sudo).
- The system is booted and running in normal mode (not from a Live-USB, unless you are trying to repair an installed system).
- All disks that may contain other operating systems are connected (especially important for external HDD/SSD or if you changed SATA ports).
- The
os-proberpackage is installed for automatic detection of Windows/Linux (in some distributions it is included by default).
Step-by-Step Instructions
Step 1: Check and Install os-prober
The os-prober package is a script that scans disks for other OSes. In most cases, it is already installed.
sudo apt update
sudo apt install os-prober
If the package is already installed, the command will report it. Important: In Ubuntu 22.04 and newer, os-prober is disabled by default in the GRUB config for security reasons (to avoid accidentally adding an untrusted OS). If you want GRUB to search for other systems, proceed to the next step.
Step 2: Enable OS Search (If Needed)
Edit the main GRUB configuration file:
sudo nano /etc/default/grub
Find the line GRUB_DISABLE_OS_PROBER. If it doesn't exist, add it to the end of the file:
GRUB_DISABLE_OS_PROBER=false
If the line exists and is set to true, change it to false. Save the file (Ctrl+O, Enter) and close the editor (Ctrl+X).
💡 Tip: If you don't want GRUB to automatically add found OSes (e.g., for security), leave this setting as
trueand add menu entries manually via/etc/grub.d/40_custom.
Step 3: Run the GRUB Configuration Update
Now execute the main command. It will gather information about all Linux kernels in /boot and other OSes (if os-prober is active).
sudo update-grub
You will see output similar to this:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-78-generic
Found initrd image: /boot/initrd.img-5.15.0-78-generic
Found Windows Boot Manager on /dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
done
Here, Found Windows Boot Manager means Windows was successfully detected.
Step 4: Verify the Result (Optional)
After running the command, you can check what exactly made it into the configuration file:
grep -E "menuentry|submenu" /boot/grub/grub.cfg | head -n 10
This command will output the first 10 menu entries. Look for the names of your operating systems and kernel versions. If the needed OS (e.g., Windows) is missing, go back to Step 2 and verify that os-prober is correctly enabled.
Step 5: Reboot
Changes only take effect after a reboot, as GRUB reads the configuration when the computer starts.
sudo reboot
After rebooting, all detected systems should appear in the bootloader menu.
Verifying the Result
- When you turn on the computer, the GRUB menu will appear.
- The list should contain all installed operating systems (Ubuntu with different kernel versions, Windows, other Linux distributions).
- You can successfully boot into any of them.
- If you updated GRUB due to boot problems (e.g., "grub rescue>"), the system should now boot into normal mode without errors.
If the problem persists (e.g., Windows does not appear), proceed to the "Possible Issues" section.
Possible Issues
Issue: os-prober not found, or update-grub does not see Windows
Solution:
- Ensure the Windows partition is not disabled in UEFI/BIOS (e.g., via Fast Boot or Secure Boot).
- Check if the EFI partition is mounted (for UEFI systems). It is usually mounted at
/boot/efi. If not, mount it manually and runupdate-grubagain. - Manually add Windows to GRUB via the
/etc/grub.d/40_customfile. Example entry for UEFI:
Add at the end:sudo nano /etc/grub.d/40_custom
Then runmenuentry "Windows 11" { insmod part_gpt insmod fat insmod chain set root='(hd0,gpt1)' # Replace with your EFI partition, find it using `sudo fdisk -l` chainloader /EFI/Microsoft/Boot/bootmgfw.efi }sudo update-grubagain.
Issue: After updating GRUB, the system does not boot, grub rescue> appears
Solution: This means GRUB cannot find its modules or configuration. Boot from an Ubuntu Live-USB and mount the root partition of your system. Then chroot into the system and reinstall GRUB:
# Assuming the root partition is on /dev/sda2
sudo mount /dev/sda2 /mnt
sudo mount /dev/sda1 /mnt/boot/efi # If using UEFI
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt
grub-install /dev/sda # Install to MBR (for BIOS) or
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu # For UEFI
update-grub
exit
sudo reboot
Issue: Too many old kernels in the GRUB menu
Solution:
Remove old kernels via apt:
sudo apt autoremove --purge
Or manually, by viewing the list: dpkg --list | grep linux-image. Then run sudo update-grub again.
Issue: GRUB does not show the menu, boots Ubuntu immediately
Solution:
The menu entry might be hidden. Check the GRUB_TIMEOUT setting in /etc/default/grub. It should be greater than 0 (e.g., GRUB_TIMEOUT=10). After modifying the file, you must run sudo update-grub.