11

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.

4

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.

3

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

  • 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! – Ashley Aitken Jul 25 '14 at 9:38
  • Did that. Now getting entry in boot menu :-) But now get: error: no such device 787776677... error: hd1 cannot get C/H/S values... – Ashley Aitken Jul 29 '14 at 9:54
  • this worked great with windows 7 and CentOS 7. thanks. – Nathan McCoy Aug 21 '14 at 17:15
2

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.

  • 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? – Ashley Aitken Jul 18 '14 at 11:09
2

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.

1

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.

  • Format of grub2-mkconfig command: – stv Apr 30 '16 at 20:21
  • 1
    cd /boot/grub2; grub2-mkconfig --output=grub.cfg – stv Apr 30 '16 at 20:22
1

I have been trying a dual boot with window 7 and centos 7 for two 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

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.