You might of come across this page because your BIOS or efibootmgr has also corrupted, meaning that you can no longer boot from USB and otherwise change systems. One of these problems can be your BIOS registering bootloaders on EFI System Partitions (ESP), or otherwise being suck in 32-bit Legacy when you want it in 64-bit UEFI bootloading.
For me, I was luck enough to have both problems, so if you have either then you’ve come to right place! Fortunately, I was eventually able to re-install 64-bit Linux onto a new internal HDD with the compromise of 32-bit booting in Legacy, due to a faulty BIOS.
The GRUB rescue prompt is never a good sight to see, but in the short-term is can be a real life saver for bootstrapping into an installed or Live system. So first off, you should give this a go, as it’s a lot quicker than the final solution proposed here.
The bootrapping commands are at least basic:
The (hdX,X) is the disc (starting from 0) and partition (start from 1) of your boot partition, not your root filesystem. As in the example above, the user is trying to boot the 6th partition (msdos6) from their 1st disc (hd0) – usually the internal HDD.
This process is widely documented, so I won’t go into much further details, other than an extra few tips that may help you on your journey in grub rescue:
List files/directories in hd0,1: ls (hd0,1)/
List files/directories in gpt partition hd0,1: ls (hd0,gpt1)/
List files/directories in msdos partition hd0,1: ls (hd0,msdos1)/
List files on USB: ls (h1,1)/
Search in lost+found in hd0,1: ls (hd0,1)/lost+found/./../
Sometimes it will tell you partition does not exist, or filesystem unknown, the result you want is for Ext2 filesystem to be found, as this is what you can boot from.
Furthermore, if you’ve still got a functioning GRUB then you should explore these options further and try modifying the configuration scripts (by Ctrl + E) as well as attempting bootstrapping from there with Ctrl + C to enter commands.
In GRUB you are notably not restricted to EFI-only recognized partitions for bootsrapping into partitions, as you are in grub rescue, so consider your options. Nonetheless, the following method will work for nearly laptops that support booting from EFI system partitions, or otherwise still capable of reading USB boot images.
By now you should have tried out all the settings in your BIOS, from secure boot on/off and boot order options to Legacy and UEFI booting modes, in order to of given yourself the best chance of booting from USB with your hard drive still installed.
After removing your hard drive and therefore removing the bootloader installed on the EFI partition of the disc, your laptop will now only have the option to access the bootloader on your EFI partition of your bootable USB.
To do this, install Unebootin and Gparted (if you don’t already have them):
$ sudo apt-get install gparted $ sudo add-apt-repository ppa:gezakovacs/ppa $ sudo apt-get update $ sudo apt-get install unetbootin
Alternatively, if your distribution doesn’t support Unetbootin, then download the bin file followed by chmod +x ./unetbootin-linux and ./unetbootin-linux.
First off, using Gparted create a new partition table and select msdos, as opposed to our favourite – GPT. Then create new primary partition as FAT32 leaving 512MB for a final FAT32 EFI partition. Then after applying changes, flag the larger partition as bootable with the smaller partition as ESP (EFI System Partition).
Create your USB using Unetbootin of your favorite Linux distro to /dev/sdb1, it’s important to afterwards copy any boot and efi folders, as well any other boot images, from the bootable partition (/dev/sdb1) to the EFI system partition (/dev/sdb2).
In my case, for Lubuntu 17.10, there were initrd.lz and vmlinuz.efi that were worth grabbing in the casper folder, that I’d failed to boot from before.
Next, it’s likely that when selecting USB as booting option your BIOS will still fail, but then it will fall back search for any ESPs. Any BIOS without the option of attempting to boot from an outdated bootloader should therefore get the message loud and clear.
Fortunately this slap dash copy and paste trick works, as the bootloader will be searching for a specific disc UUID, partition and image to boot from that still applies after being copied. It’s similar to how grub rescue works but with better knowledge and accuracy.
And there we have it! You’re back to your old desktop in no time.
Not quite, remember you took the hard drive out, well it makes it a little difficult to install a new operating system onto it now! Unfortunately it’s not like a USB you can just mount and unmount, it has to be read by the BIOS upon boot up.
Therefore,to continue on with installing onto an internal HDD/SSD, then you will need to install your system onto another USB – making sure to install the bootloader onto that USB – /dev/sdb – as opposed to the hard disk, which may be unreliable.
Finally, after installing your USB with a bootable persistent volume and bootloader, with any luck you can install your new system – this time with the bootloader set to /dev/sda and boot straight into it . After this, run Boot Repair and cleanup that mess!
sudo add-apt-repository ppa:yannubuntu/boot-repair sudo apt-get update sudo apt-get install -y boot-repair && boot-repair