If you have about 16GB of free unallocated space, or an unused partition about that size or bigger which you can format (ok to delete its contents), might work with a bit less than that size also, then this answer is for you.
I deleted the ubuntu partition because I needed more space on the windows partition; I did this using Create and format hard disk partitionsCreate and format hard disk partitions
in windows - just click on start menu and type part; resizing of windows partitions should be done only from windows to avoid issues; so I resized the windows partition with a few extra GB;
luckily, I did not give all the free space that was left after deleting the ubuntu partition to windows;
so when I got the grub rescue error, upon the next reboot, the lsls
and setset
grub commands worked, but several other commands like chainloaderchainloader
, initrdinitrd
or normalnormal
did not work;
the problem was that although I did do a shutdown, windows tries to be smarter and second guess you and do a hibernate anyway, to enable a faster boot next time;
so the disk was in a "dirty" inconsistent state and therefore could not be mounted, except in read-only mode which does not allow fixing anything, even using a live ubuntu usb drive, and therefore, could not fix/reinstall grub from the live ubuntu;
this of course also means that windows cannot be started from grub; and naturally, the os-proberos-prober
command from linux cannot find the windows system in this state either, not that it matters;
in my case, as I had free space available, I created a partition from linux, with the ubuntu live usb installer - without touching the windows partitions - and also created a new EFI partition for grub and sized it to 128MB for good measure, and installed ubuntu into the new partition using the live usb installer; it installed fine - but at the end it failed to install grub - because the windows was hibernated/dirty
so for this, I used the live ubuntu usb and installed boot-repairboot-repair
as follows at a terminal (ctrl+alt+tctrl+alt+t
to open a terminal in ubuntu) (this is installed only in memory, not on disk, as it is a live ubuntu usb, so if you reboot, you need to redo these steps below):
sudo apt-add-repository ppa:yannubuntu/boot-repair
sudo apt update
sudo apt install boot-repair
then I ran boot-repairboot-repair
and selected the first option:
sudo boot-repair
this showed the commands to type to remove the old grub and install a new one into the EFIEFI
partition created above; then it was possible to boot in the newly installed ubuntu, using the new grub in the new EFI partition;
then in ubuntu at the terminal prompt I typed
sudo update-grub
and now the windows was also added to the grubgrub
menu and everything works again, upon the next reboot both ubuntu and windows can now be selected in the grub menu
apparently to shut down windows without the dirty hibernation, need to type at a windows command prompt
shutdown /s