Installed Centos 7 after Windows and can't boot into CentOS

43,627

Solution 1

You probably mounted the wrong Windows partition.

Look for a small partition of 100 or 300MB (the Boot Partition of Windows), mount it and then run the command again.

If you are still having problems, add following to the end of /etc/grub.d/40_custom:

menuentry "Windows"{
    set root='(hd0,0)'
    chainloader +1
}

This is assuming the Windows boot partition is the first partition of the first hard disk.

Don't forget to run grub2-mkconfig.

Solution 2

Mount the windows Partition. (If you can't mount install ntfsprogs-2013.1.13-5.el7.x86_64.rpm and ntfs-3g-2013.1.13-5.el7.x86_64.rpm)

Run as root grub2-mkconfig -o /boot/grub2/grub.cfg

Solution 3

I have been trying a dual boot with window 7 and centos 7 for 2 days and I did it. Just follow simple steps
Install window 7
Then centos 7
When you restart the pc you will not see any boot option for windows 7 in grub.
Boot into centos switch to su
use command cfdisk
Then check for flags where boot is written notify that partition
Then open grub file in /boot/grub2/grub.cfg first backup the grub.cfg file by copying it as grub.old.cfg open the file and edit it with

menuentry "WINDOWS"{
set root='(hd0,msdos1)' 
chainloader +1
}

change the value of msdos with the partition where the boot flag is given. as if boot flag is in /dev/sda1 then msdos1 if /dev/sda2 then msdos2.

Don't forget to run grub2-mkconfig

I hope you will find it useful.

Solution 4

Reinstall the CentOS bootloader (whether it is LILO or GRUB). The bootloader installer should recognize OSes in your machine and automatically show you OS choices in booting time. CMIIW.

Solution 5

Found that adding File 11_windows in /etc/grub.d was more helpful:

Contents:

#!/bin/sh
cat << EOF
menuentry "WINDOWS"{
set root='(hd0,msdos1)' 
chainloader +1
}
EOF

Then ran grub2-mkconfig after saving backup of grub.cfg in /boot/grub2.

Results included added Entry "WINDOWS" in grub menu during start up.

My case was for Windows10, but should be the same.

Share:
43,627

Related videos on Youtube

Kim Somers
Author by

Kim Somers

Updated on September 18, 2022

Comments

  • Kim Somers
    Kim Somers over 1 year

    I wanted to setup a dual boot for Windows 7 and CentOS 7

    I had a Windows 7 machine with 500GB disk. I shrank the Windows partition to provide space for CentOS 7 (roughly 230GB). I created a USB CentOS 7 netinstall stick and booted from that. I ran the install configured as best I knew to install CentOS 7 into the free space (rather than over the whole disk). I did the net install and all seemed to go well but when it rebooted I was back into Windows and can't get into CentOS.

    I've rebooted from the USB and tried to fix the situation (carefully) using cfdisk, e.g. selecting what I believe is the CentOS boot partition but it reports "missing operating system." Also cfdisk says it can't reread the partition table when I write it with CentOS boot but starting cfdisk again seems to show the flag has been set.

    Currently the USB CentOS 7 netinstall shows me the following partitions on the disk:

    ## DATA  
    /home 168GB centos-home  
    
    ## SYSTEM  
    /boot 500MB sda3  
    / 51GB centos-root  
    swap 3.85GB centos-swap  
    

    The "other" Windows partitions are:

    ntfs 100MB sda1  
    ntfs 253GB sda2
    

    This looks ok BUT when I go into CentOS 7 Installation again it is telling me I have to create mount points for the root partition. I didn't do this originally as I thought it would be done automatically when I clicked "Click here to create them automatically" for the disk setup the first time I installed.

    And the partition table accessed using cfdisk from "Rescue a CentOS system..." looks like this:

    Unusable 1MB  
    sda1 Primary ntfs 105MB    
    sda2 Primary ntfs 265GB  
    sda3 Boot Primary xfs 525MB    
    sda5 NC Logical LVM2_member 235GB  
    Logical Free space 0.03MB
    

    As mentioned, when I try to boot with this configuration I get "missing operating system." If I change the boot flag back to sda1 then it boots into Windows 7 fine.

    UPDATE #1

    I (re)installed grub2 using grub2-install from netinstall on /dev/sda and now when I boot from the disk I get the grub prompt. I can using it to chain load into Windows. However, when I try to boot into CentOS 7 I get some sort of trace/dump.

    I used:

    linux  (hd0,msdos3)/vmlinuz-3... root=/dev/sda3
    initrd (hd0,msdos3/initrd-plymouth...
    boot
    

    NOTE: I believe linux is the primary boot partition for CentOS

    Trying the above just crashes.

    UPDATE #2

    I installed NTFS-3G and NTFSPROGS using yum from the EPEL repository.

    I ran grub2-mkconfig -o /boot/grub2/grub.cfg and then rebooted to find Windows 7 (Loader) in the boot menu. But when I choose it I get:

    error: no such device 978778...
    error: hd1 cannot get C/H/S values....
    

    which doesn't sound very good at all, but at least some progress.

    I should also say that I now have CentOS 7 only on the internal drive and I'm working on this drive as an external USB drive (hence /dev/sdb).

    Can someone please help me to get Windows to boot?

    I have a Unix background but mostly use Mac OS X. I always come unstuck on setting up Windows and Linux dual boot.

    Finally, I have CentOS 6.5 system running fine on another machine, as well as my Mac.

  • Kim Somers
    Kim Somers almost 10 years
    Thanks Ade. I believe CentOS 7 uses Grub2, so I will reinstall that. I guess it goes in the 500MB boot partition but I thought the problem would relate more to the MBR (or something like that). Will the Grub2 set that up appropriately?
  • Kim Somers
    Kim Somers almost 10 years
    Thanks for the comment. After many attempts to get this working I put in a new disk and installed just Centos 7. However, I still want to get the other disk with Windows working so I will put the disk in another machine and follow your direction. Thanks again!
  • Kim Somers
    Kim Somers almost 10 years
    Did that. Now getting entry in boot menu :-) But now get: error: no such device 787776677... error: hd1 cannot get C/H/S values...
  • Nav
    Nav over 8 years
    Hope the OP selects this as the accepted answer. Worked perfectly for me: nrecursions.blogspot.in/2015/12/…, but it would have been better to have a third-party boot-loader which automatically recognizes OS'es on partitions: superuser.com/questions/1009739/…
  • stv
    stv about 8 years
    Format of grub2-mkconfig command: