0

I had a dual-boot (Ubuntu+Win10) configuration on my laptop (single disk). Due to space limitations, I had to delete the Ubuntu partitions (root, home, swap in extended partition) and extend the big NTFS partition to the full disk. Unfortunately the Grub configuration was stored in the Ubuntu part. So I was not able to boot any more. I just got to the grub repair CLI.

During repair attempts using a Ubuntu 20.04 live USB stick, I got to the point where I now have sda1 (NTFS 500MB), sda2 (Windows 10, 250GB), sda3 (Windows recovery) and sda4 (300MB ext4 designated as /boot partition for Grub). With the latter I try to repair the existing configuration. I installed grub using grub-install --root-directory /mnt/sda4 /dev/sda from this post.

I am able to boot into the Grub CLI (2.04). With the commands from this post, I can boot into Win10 again:

insmod chain
insmod ntfs
set root=(hd0,msdos1)
chainloader +1
boot

But at this point I am stuck. I do not see how to install the grub menu permanently again. Commands like update-grub or grub2-mkconfig (run from the live stick) require not to be run from the live stick. I tried chroot, but was not successful. All manuals that I found assume that one Linux OS is still installed, which seems to be the "basis" of chroot. I want to get a running Windows-only configuration. Right now it would be ok if it is with a Grub bootloader. It would be better to use the Windows bootloader, but I seem not to be able to start the recovery mode despite hitting F8 on Windows boot and also have no Windows recovery media.

So does someone have a clue on how to permanently add the windows boot entry to Grub in this scenario? A quick workaround which does not require me to type the five commands on every boot would also be fine. Thanks :-)

1 Answer 1

0

Since you ran grub-install using live media and designated the mounted /mnt/sda4 as the root filesystem for it, after grub-install there should now be a /mnt/sda4/boot/grub/ directory with at least an i386-pc sub-directory in it. Possibly also files like device.map and/or grubenv.

Just type those five Windows-booting commands into a text file (ideally with Linux-style line endings, so maybe use a Linux text editor), and place that file as /mnt/sda4/boot/grub/grub.cfg and that should be your quick workaround.

The grub2-mkconfig is just for running the scripts in /etc/grub.d/ to parse the simplified configuration file /etc/default/grub and optionally run utility scripts like os-prober to auto-detect other operating systems and auto-generate a grub.cfg file with a nice menu system based on the results. And update-grub is essentially just a Debian/Ubuntu-specific alias for grub2-mkconfig.

There is nothing to stop you from skipping the middle-man and writing your actual grub.cfg file from scratch yourself, other than the fact that it can be fairly tedious if you want to do a more elaborate menu structure.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .