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.
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?
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.
- Use the
lscommand on the grub rescue prompt to list all the partitions.
- Then you can use the ls command again to check the contents of each partitions to be sure.
The linux root partition will contain
/libetc. etc directories.
- 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
- Then you should be able to access the GRUB boot menu like before, select the linux distro and boot to it.
- After booting, you must be asked to login to your user account.
- Next login to the account and open up a terminal window.
- 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"
- To reinstall GRUB for legacy BIOS use this command.
sudo grub-install /dev/sda --target=i386-pc
- 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
- If grub installation reports no problem, then update the GRUB configuration file.
- 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
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.