GRUB config missing: fix 'error: no such partition' on boot
Your PC boots to a black screen with 'error: no such partition' after a kernel update or partition resize. The fix is rebuilding GRUB from a live USB.
You boot your Linux machine one morning, and instead of the familiar GRUB menu, you get a black screen with error: no such partition. Then it drops you to a grub> prompt. Nothing works. You can't type boot or exit. This usually happens right after you resized a partition with GParted, or after a kernel update that rewrote GRUB's config.
The real cause is simple: GRUB's configuration file (usually /boot/grub/grub.cfg) points to a partition number that doesn't match reality. For example, your root partition used to be (hd0,msdos5), but after resizing, it moved to (hd0,msdos6). GRUB uses the old number, and it can't find the files it needs to boot.
You can fix this without reinstalling your OS. The trick is to boot from a live USB, mount your system, and run a few commands to regenerate the GRUB config. Here's exactly how.
What you'll need
- A live USB with Ubuntu, Debian, or any Linux distro (same architecture, 64-bit or 32-bit).
- About 10 minutes.
- Basic comfort with a terminal.
Step-by-step fix
-
Boot from the live USB.
Plug the USB in, restart your machine, and press the key to enter the boot menu (F12, F2, Del, or Esc — it depends on your motherboard). Choose your USB drive. After a minute or two, you'll see the live desktop.
Expected outcome: You're sitting at a normal desktop with a terminal you can open.
-
Open a terminal.
In most distros, you can press
Ctrl+Alt+T. Or find Terminal in the applications menu. -
Find your Linux partition.
Run
sudo fdisk -l. You'll see a list of drives. Look for your main Linux partition — it's usually ext4 or btrfs, and it's probably the largest one. Mine is/dev/sda2. Write yours down.sudo fdisk -lExpected outcome: A list like
/dev/sda1(EFI or boot),/dev/sda2(root),/dev/sda3(swap). -
Mount your root partition.
Replace
/dev/sda2with your actual partition.sudo mount /dev/sda2 /mntExpected outcome: No output means it worked. If you get an error like "mount: wrong fs type", you might have the wrong partition. Double-check with
lsblk -f. -
Mount the boot and EFI partitions (if you have them).
If you have a separate
/bootpartition (check withlsblk), mount it:sudo mount /dev/sda1 /mnt/bootIf you have an EFI partition (usually FAT32, labeled
EFI System), mount it too:sudo mount /dev/sda1 /mnt/boot/efiExpected outcome: Both should mount silently. If you get "mount point does not exist", create it with
sudo mkdir -p /mnt/boot/efithen try again. -
Chroot into your system.
This makes the terminal act like you're inside your installed Linux, not the live USB.
sudo chroot /mntExpected outcome: The prompt changes to something like
root@host:/#. You're now inside your system. -
Reinstall GRUB to the drive's MBR or EFI.
For BIOS/MBR systems (older style):
grub-install /dev/sdaFor UEFI systems (newer style):
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUBExpected outcome: You should see "Installation finished. No error reported." If you get an error about
grub-install: error: cannot find a device for /boot/efi, your EFI partition isn't mounted. Go back to step 5. -
Regenerate the GRUB configuration file.
This is the key step. It creates a fresh
grub.cfgthat uses the current partition numbers.update-grubIf that command isn't found (some distros use
grub-mkconfig), try:grub-mkconfig -o /boot/grub/grub.cfgExpected outcome: You'll see lines like "Found linux image: /boot/vmlinuz-5.10.0-21-amd64" and "Found initrd image: /boot/initrd.img-5.10.0-21-amd64". If you see nothing or an error, your
/bootmight be empty — that's a different problem. -
Exit chroot and unmount.
Type
exitto leave the chroot environment. Then unmount everything:sudo umount /mnt/boot/efi sudo umount /mnt/boot sudo umount /mntExpected outcome: No errors.
-
Reboot.
Remove the live USB and restart:
sudo reboot.Expected outcome: You should see the GRUB menu, and your system should boot normally.
If it still fails
Check these things in order:
- Partition order changed again? Sometimes after a resize, the partition numbers shift. Run
sudo fdisk -lfrom the live USB and compare to what you mounted. If the root partition changed from/dev/sda2to/dev/sda3, mount the new number and repeat steps 4–10. - Boot flag missing? Use
sudo fdisk /dev/sda, then pressaand choose the partition you want to mark as bootable (usually the same as your root partition if you don't have a separate/boot). Then write changes withw. - UEFI vs BIOS mismatch? If your system was installed in UEFI mode and you tried to install GRUB for BIOS, it won't work. Check your firmware settings (F2 at boot) — if it says "UEFI" or "Legacy", make sure you use the matching command in step 7.
- Boot partition is full? If
/bootis 100% full,update-grubwill fail. From the chroot, rundf -h /boot. If it's over 90%, delete old kernels withapt autoremoveor manually delete files in/boot(keep the current ones!). - Filesystem corruption? Run
sudo fsck /dev/sda2from the live USB (unmount it first). If it finds errors, run it again with-yto auto-fix them.
This fix has saved me more times than I can count. The trick is always the same: chroot, reinstall, update-grub. Don't skip the update-grub step — that's where the magic happens.
Was this solution helpful?