Okay, so I did something stupid. I was trying to clean up my Grub entries, and accidentally removed all of my Linux kernels from Grub (they're still on the hard drive). So now, obviously, Grub doesn't give me any way to boot into Ubuntu; I can boot into Windows just fine, but Ubuntu isn't even listed.
So I just want to run "sudo upgrade-grub" somehow to restore Ubuntu to the list. I can boot from a LiveCD, but once there how do I run that command? (My Ubuntu installation is on sda5, by the way.)
Since you say your grub bootloader appears, but the menu is empty, I think you don't need to reinstall grub, but rather, as you ask, run update-grub. To achieve this, you can use a Live CD, mount the relevant partitions from your hard disk, chroot into the mounted directory, and run update-grub, which should work as if you were operating on the actual hard disk.
Boot with your Live CD, selecting "Try Ubuntu without installing".
Once it boots, open a terminal (ctrl-alt-t) and mount your Ubuntu partition on /mnt. I'm assuming the Ubuntu partition is /dev/sda5, but you should determine this yourself. Let me know if you need help to do this:
Then mount a few more directories that are needed:
Also, if you have a separate Ubuntu boot partition (pretty uncommon these days, but it may be the case):
How can you tell if you have a boot partition?
Once you have your Ubuntu partition mounted, open
/mnt/etc/fstab
. If you see an entry for/boot
, note which device it is pointing to (/dev/sda4
maybe?). This is the one you have to mount.Once these are mounted, do chroot to start using the mounted directory as the root partition:
You'll get a
#/
prompt. First thing to do is confirm that you're using the correct/boot
directory. Go to/boot/grub
and look at the files there. There should be a bunch of .mod files and a grub.cfg file. If the directory is empty, don't continue, because it means this is NOT your actualboot
directory. Look above to see how to determine if you need to mount an additionalboot
directory.Once you've confirmed that
/boot/
contains the correct files, meaning that it is the correct location, type:This should rebuild your /boot/grub/grub.cfg file with the menu entries.
Then exit the chroot:
At this point you may want to check that things were correctly updated. For this,
cd /mnt/boot/grub
and check that grub's files are there, there should be a bunch of .mod files and grub.cfg, the latter should have entries for your Ubuntu kernels. If you only see grub.cfg and no .mod files, it means that this is NOT the correct boot directory, look above for how to mount a separate boot partition.Unmount the filesystems:
And then reboot, hopefully your Grub menu will be restored.
Boot from a Live CD.
Hit Alt+Ctrl+T to open terminal and run following commands:
Install the GRUB2 boot loader:
That’s
/dev/sda
— the hard disk itself, not the Ubuntu partition –/dev/sda5
.Unmount the Ubuntu partition and restart the computer like so:
If you have more than one OS installed, re-detect OSes like so:
That’s it!
My solution to that problem was:
Maybe it's not the fastest solution but for me it was the easiest one.
This solution is the exact same as roadmr's answer except much easier.
In my particular case, 'Reinstall GRUB Bootloader' fixed it for me.. I have a dual-boot windows/linux setup. I used Macrium 7 to create a clone of a drive to a file. Then restore that file to a new drive. After I restored it to the new drive, it would boot to a black screen with a blinking cursor in the upper left.
The combined instructions of roadmr and Basharat Sialvi can be found here: https://askubuntu.com/a/88432/293759
Instructions for chainloader and multiboot commands of Grub2 are at Community Help Wiki.
In 2022, you probably have an EFI system that requires a couple more steps.
Boot from a Live CD and open the terminal.
Mount the partition (e.g.
/dev/sda5
) with your original OS to/mnt
:In case you are using a SSD disk, the device name starts with nvme, e.g.
/dev/nvme0n1
.Find out which partition has the EFI system:
Mount the EFI system partition (e.g.
/dev/sda1
) to/mnt/boot/efi
:Install GRUB according to @basharat-sialvi's instructions:
Finally, reboot the system.
Thanks for all the great help! However, in the end nothing seemed to work, and since I had a separate /home partition, I was able to reinstall Ubuntu without losing any data. I still have to reinstall programs and do some configuring, but everything seems good at this point.