PCsuggest

  • Quick tip
  • SECURITY
  • NETWORKING
  • OpenWrt
  • HARDWARE

How to fix GRUB error no such device on Linux

Updated - September 14, 2018 by Arnab Satapathi

Sometime you may encounter error messages like Error: no such device: xxxxx-xxxx-xxxx-xxxx-xxxxx  right after powering up the PC.

Such problems are caused by misconfigured GRUB, unable to load any operating system.

Usually happens when you resize, rename or shrink the disk partitions. Or may be even if you transfer a perfectly working hard drive from one PC to another.

But there's an easy solution to deal with such problems, and here we'll discuss about it.

Contents

  • Why this is happening?
  • How to fix the Error no such device GRUB rescue ?
  • Conclusion

Why this is happening?

This grub no such device problem usually happens when the boot drive's UUID is changed somehow.

Like if you convert a disk drive with MBR partition table to GPT partition table. Another reason of UUID change is if you resize, merge, shrink or extend the linux root partition.

Here GRUB is present as bootloader, but it can't find the proper modules and configuration file due to changed partition UUID.

How to fix the Error no such device GRUB rescue ?

To fix this problem, you've to determine three things.

First which one is the linux root( / ) partition, second how the system is booted, i.e. in UEFI mode or in legacy BIOS mode.

Third, if it's booted in UEFI mode, then which is the EFI system partition?

amazon prime logo
Try AmazonPrime for free
Enjoy free shipping and One-Day delivery, cancel any time.

You can use the parted command to determine the ESP partition, which is a FAT32 filesystem of around 100MB.

sudo parted /dev/sda print

Now the actual steps to fix the error no such device problem.

  1. Use the ls command on the grub rescue prompt to list all the partitions.
  2. Then you can use the ls command again to check the contents of each partitions to be sure.
    ls (hd0,1)/

    The linux root partition will contain /bin , /boot, /lib etc. etc directories.

  3. If you're sure about the linux root partition, then type the commands listed below one by one. In my case, the partition is (hd0,msdos5) .
    set root=(hd0,5)
    set prefix=(hd0,5)/boot/grub
    insmod normal
    normal
  4. Then you should be able to access the GRUB boot menu like before, select the linux distro and boot to it.
  5. After booting, you must be asked to login to your user account.
  6. Next login to the account and open up a terminal window.
  7. Then determine if the system is booted with UEFI mode or legacy BIOS mode, use the one liner script below.
    [ -d /sys/firmware/efi ] && echo "UEFI boot" || echo "Legacy boot"
  8. To reinstall GRUB for legacy BIOS use this command.
    sudo grub-install /dev/sda --target=i386-pc
  9. To re install GRUB on a UEFI based system, use this.
    sudo mount /dev/sda2 /boot/efi     # mount the EFI system partition
    sudo grub-install /dev/sda --target=x86_64-efi --efi-directory=esp
  10. If grub installation reports no problem, then update the GRUB configuration file.error no such device grub rescue
    sudo update-grub
  11. Finally reboot the PC or laptop to check the if it worked at all or not.

Also don't just copy-paste the commands, your EFI system partition could be different, most probably /dev/sda1 .

Conclusion

It's not a very well described tutorial to fix the grub rescue no such device issue. But I hope you've got basic the idea to deal with the error no such device issue.

First you need to boot linux somehow then reinstall the GRUB bootloader and update the GRUB configuration. Here's the detailed GRUB rescue tutorial.

If you've any question or suggestion, leave comments below.

Filed Under: linux basics, Quick tip Tagged With: grub, grub recovery, grub repair, grub rescue

Your comments
  1. Octavian Paun says

    June 4, 2020

    Hi,

    Please help : I have one Asus X543MA-GO929 with EndlessOS, recently purchased. For about a week, the system does not start. It looks like this: "error no such device ostree". Do you have any suitable suggestions for this error?

    Thank you!

    Reply
  2. jam75 says

    April 2, 2020

    Very interesting.
    I had to change my tower and the new one is an EUFI one with W10. After putting the new tower in both modes (UEFI and legacy) the "old" Ubuntu SSD boots up to the CLI interface but cannot enter the graphical mode.
    I built a new Ubuntu SSD from a DVD. Boots stops with "no such device : 39760...). I disconnected from SATA an HDD used in the old tower and inserted in the new one.
    Without this old HDD, Ubuntu boot was perfect.
    I think the id of old HDD changed under W10 (I tried so many things...).
    How can I solve the problem.
    According to your

    [ -d /sys/firmware/efi ] && echo "UEFI boot" || echo "Legacy boot"

    I booted in legacy mode.
    Best regards

    Reply
    • Arnab Satapathi says

      April 3, 2020

      That's a tricky situation, every PC needs a different approach.

      If you think the old disk's UUID is changed, it's better to reinstall GRUB.

      First you should check the partition table of your old HDD, if it's MBR, install GRUB for legacy BIOS, if it's GPT, install GRUB in UEFI mode.

      The best way is to disconnect all other disk to avoid confusion, then boot from a Live USB, then chroot into the old HDD, and reinstall GRUB.

      This could help, - https://www.pcsuggest.com/grub-rescue-linux/#GRUB_rescue_on_UEFI_systems

      Reply
  3. Me says

    February 24, 2020

    Fails horribly for 4 disk install:

    me@me-MS-7693:~$ sudo parted /dev/sda print
    Model: ATA Samsung SSD 850 (scsi)
    Disk /dev/sda: 250GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    Disk Flags:

    Number Start End Size File system Name Flags
    1 1049kB 524MB 523MB ntfs Basic data partition hidden, diag
    2 524MB 629MB 105MB fat32 EFI system partition boot, esp
    3 629MB 646MB 16.8MB Microsoft reserved partition msftres
    4 646MB 249GB 249GB ntfs Basic data partition msftdata
    5 249GB 250GB 605MB ntfs hidden, diag

    me@me-MS-7693:~$ sudo parted /dev/sdb print
    [sudo] password for me:
    Model: ATA SSD2SC240G1LC709 (scsi)
    Disk /dev/sdb: 240GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:

    Number Start End Size Type File system Flags
    1 1049kB 240GB 240GB primary ext4 boot

    me@me-MS-7693:~$ sudo parted /dev/sdc print
    Model: ATA WDC WD20EZRX-00D (scsi)
    Disk /dev/sdc: 2000GB
    Sector size (logical/physical): 512B/4096B
    Partition Table: msdos
    Disk Flags:

    Number Start End Size Type File system Flags
    1 1049kB 2000GB 2000GB primary ext4

    me@me-MS-7693:~$ sudo parted /dev/sdd print
    Model: ATA WDC WD20EZRX-00D (scsi)
    Disk /dev/sdd: 2000GB
    Sector size (logical/physical): 512B/4096B
    Partition Table: msdos
    Disk Flags:

    Number Start End Size Type File system Flags
    1 1049kB 1682GB 1682GB primary ext4 boot
    2 1682GB 2000GB 318GB extended
    5 1682GB 2000GB 318GB logical ext4

    Reply
  4. Dave Bolt says

    April 12, 2019

    Heads up for a situation not covered here.
    If you have multiple drives and the one giving this problem is attached to an add-in controller card, you might have to connect it to the motherboard main controller instead.
    It seems this can happen if the add-in controller needs a special driver which is not yet available when booting.

    Reply
  5. pai says

    March 16, 2019

    I bought a laptop with EndlessOS in it. I want to install Kubuntu as the main OS, so I split into partition, but accidentally format the first partition and so I install Kubuntu in that partition. After installation finished, it rebooted and I found the problem link this article. I simply go to BIOS and change boot order, made the partition which has an OS as the first boot. I exited BIOS, the laptop rebooted and thankfully it booted.

    Reply
  6. Heinz says

    February 6, 2019

    Do not give these commands consequitvely, like 8th and 9th steps are alternatives of each other, do not put them in a sequence.

    Reply
  7. Lorenzo says

    September 28, 2018

    Thank you very much. It did smoothly

    Reply
  8. Georg Salomon says

    September 19, 2018

    Thanks, very helpfull, probably not for all, but somebody has any linux knowhow, no problem to use.

    Reply
  9. sudogranjas says

    August 3, 2018

    Thanks so much! Very usefull.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © PCsuggest.com · All rights reserved.

  • Home
  • About
  • Contact
  • Privacy Policy
  • Sitemap