2

I had in my mind that I cannot do much wrong when installing Linux (CentOS 7) after Windows (Server 2012 R2) to get all OSs as boot options.

So, after installing Server 2012 R2 nicely, I installed Centos 7. But now I only have Centos in the boot menu, no Windows anymore at all.

The things I have tried so far have failed:

  • manually editing the /boot/grub2/grub.cfg to add the entry (all my added entries were not working)
  • boot-repair package is only available for ubuntu, not for centos
  • running os-prober does not show any windows partitions
  • running fdisk -l shows the 2 NTFS partitions (0/1) and my added Linux partitions

All installed on same HD, I turned off UEFI before install since I heard this would have complicated things even more.

I will next try the Windows repair option from install-usb-stick but have a feeling that afterwards the Centos entries will be gone.

How to get all entries?

1

I offer this "Answer" as a supportive post AND as additional information on a point.

The Andreas Reiff answer with 4-step details worked very well for my situation and I learned/found an interesting "oh, by the way".

My situation was an attempt to TRIPLE-BOOT CentOS 7, Windows Server 2012, and Windows7. I thought I would be smart and add two separate Windows menuentry items, one for WinServer2012 and one for Win7.

I knew each partition number and found UUID for each Windows-related partition/installation, and gave it my best shot for both to appear in the GRUB menu. Both Windows entries did appear, but one failed with a message informing me of a missing boot manager or something like that. I did notice the entry that failed did not have the asterisk in the 'Boot' column.

Device Boot Start End Blocks Id System /dev/sda1 2048 419432447 209715200 83 Linux /dev/sda2 419432448 450889727 15728640 82 Linux swap / Solaris /dev/sda3 * 450889728 765462527 157286400 7 HPFS/NTFS/exFAT /dev/sda4 765462528 976773119 105655296 7 HPFS/NTFS/exFAT

However, the one Windows entry that did work (with '*' in the Boot column) took me to what is surely the normal WINDOWS boot manager that presented both of my Windows installations there...and each installation of Windows did successfully boot.

Aside from a different value for the UUID line, my only difference was the set root='(hd0, 3)' line that included the associated partition number.

What I ended up doing was to have

  1. one GRUB menuentry for my CentOS 7
  2. another single GRUB menuentry for 'anything Windows' which covered my multiple (both) Windows installations...by way of the single, boot-able NTFS entry at /dev/sda3.

Both Windows installations got covered by a single GRUB menuentry.
HOWEVER, each of the two Windows installations appeared as separate entries in the Windows boot manager...after I picked the 'anything Windows' entry from the initial GRUB menu.

I agree that running grub2-mkconfig was probably not needed. It seems to have worked without it, in my experiment.

This got the job done for me. The answer from Andreas helped me achieve what I wanted and I learned something I thought I should share, as well. And a THANK-YOU to Andreas.

2

Actually.. I could manually add the entry when I get the entry correct.

For all others having same problem (system always only booting into centos):

  1. to find out, on what partition Windows is actually installed (for me it is 0/sda1), run

fdisk -l

for me, it shows

.... /dev/sda1 * 2048 718847 358400 7 HPFS/NTFS/exFAT ....

  1. to find out partion UUID, run (described here) and find matching UUID

blkid

  1. then add the menu entry to /boot/grub2/grub.cfg like

menuentry "Windows 2012 R2" --class windows --class os { insmod ntfs set root='(hd0, 1)' search --no-floppy --fs-uuid --set=root XXXXXXXXXXXXX(UUID from step 2) chainloader +1 }

  1. I also ran grub2-mkconfig though I am not sure if that is really needed.

Now I also have 2012 in the boot menu.

  • This worked for me without running grub2-mkconfig. – Antony Perkov May 26 '16 at 2:27
  • The purpose of grub2-mkconfig is to overwrite the grub.cfg file. Of course, you need to add to the command a -o argument with the file you want the output placed. So, if you didn't use that argument, it just went to stdout and it did nothing. If you specified the file, then your edits would be lost. It is better to put your custom entry into /etc/grub.d/40_custom. Then grub2-mkconfig will incorporate that into the final product and you work will survive upgrades. – Kevin Buchs Jan 20 '17 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.