Grub2 wont detect Windows 7 Partition

General support questions
Post Reply
eddie70
Posts: 5
Joined: 2015/05/03 12:42:12

Grub2 wont detect Windows 7 Partition

Post by eddie70 » 2015/05/03 12:48:06

hello

I have CentOS 7 3.10.0-229.1.2.el7.x86_64 on my first hard drive and Windows 7 on my second hard drive.

I'm having problems getting grub2 to pick up my windows instillation. I know this has been asked a funk ton of times however going through those posts has not been able to solve this for me.

If I hit F12 in my bios and boot from my first hard drive (P0) it boots CentOS. If I select P1 it boots to windows. I booted again to windows by changing the disk boot order and left a file on C:\ called c_drive.txt. On booting back into Linux I found that file on the partition /dev/sda2

Bellow is some of what I tried as well as some technical information.

If anyone could point me in the correct direction to solve this issue I would be most grateful

Technical information as following.

grub2-mkconfig -o /boot/grub2/grub.cfg
~~~~~~~~~~~~~~
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-229.1.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.1.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-c653dd290c4a4bc087154edb4e5fd561
Found initrd image: /boot/initramfs-0-rescue-c653dd290c4a4bc087154edb4e5fd561.img
Found CentOS Linux release 7.0.1406 (Core) on /dev/mapper/centos-root
done

Disks
~~~~~
parted /dev/sda p all
Model: ATA ST3000DM001-1CH1 (scsi)
Disk /dev/sda: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 1049kB 211MB 210MB fat16 EFI System Partition boot
2 211MB 1285MB 1074MB xfs
3 1285MB 219GB 218GB lvm


Model: ATA ST3000DM001-1CH1 (scsi)
Disk /dev/sdb: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 1049kB 1000MB 999MB primary
2 1000MB 250GB 249GB primary ntfs boot
4 251GB 2450GB 2199GB extended lba
5 251GB 2199GB 1948GB logical ntfs

Some software
~~~~~~~~~~~~~
rpm -qa | grep grub
grub2-efi-2.02-0.16.el7.centos.x86_64
grub2-tools-2.02-0.16.el7.centos.x86_64
grubby-8.28-11.el7.x86_64

rpm -qa | grep ntfs
ntfsprogs-2015.3.14-1.el7.x86_64
ntfs-3g-devel-2015.3.14-1.el7.x86_64
ntfs-3g-2015.3.14-1.el7.x86_64

linux-boot-prober
~~~~~~~~~~~~~~~~~
linux-boot-prober /dev/sda1
linux-boot-prober /dev/sda2
/dev/sda2:/dev/sda2::/vmlinuz-0-rescue-c653dd290c4a4bc087154edb4e5fd561:/initramfs-0-rescue-c653dd290c4a4bc087154edb4e5fd561.img:root=/dev/sda2
/dev/sda2:/dev/sda2::/vmlinuz-3.10.0-123.el7.x86_64:/initramfs-3.10.0-123.el7.x86_64.img:root=/dev/sda2
/dev/sda2:/dev/sda2::/vmlinuz-3.10.0-229.1.2.el7.x86_64:/initramfs-3.10.0-229.1.2.el7.x86_64.img:root=/dev/sda2
linux-boot-prober /dev/sda3
linux-boot-prober /dev/sdb1
linux-boot-prober /dev/sdb2
linux-boot-prober /dev/sdb5

ntfs-3g.probe
~~~~~~~~~~~~~
# ntfs-3g.probe --readwrite /dev/sdb2
# ntfs-3g.probe --readwrite /dev/sdb1
NTFS signature is missing.
# ntfs-3g.probe --readwrite /dev/sdb5

In /etc/grub.d/40_custom
~~~~~~~~~~~~~~~~~~~~~~~~
menuentry "Windows 7" {
insmod ntfs
set root='(hd1,3)'
chainloader +1
}
Tried with (hd1,0)(hd1,1)(hd1,2) and (hd1,3)

# blkid
~~~~~~~
/dev/sdb2: UUID="7CDA7FFDDA7FB1CE" TYPE="ntfs"
/dev/sdb5: LABEL="New Volume" UUID="049A63219A630F0C" TYPE="ntfs"
/dev/sda1: SEC_TYPE="msdos" UUID="88EA-2168" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="da9fe5a5-cb89-4a4d-a1d0-6ee6d589e3bb"
/dev/sda2: UUID="a16a5097-9ded-4a0b-8a78-b11ea8e1e44a" TYPE="xfs" PARTUUID="156f435a-618a-444f-9bf8-6b14d007a70a"
/dev/sda3: UUID="RfIR6g-hMEL-6Cn4-HHSr-yWLw-DmcI-smshGi" TYPE="LVM2_member" PARTUUID="b53f3b2e-ef1f-42eb-9919-c069490ffc3a"
/dev/mapper/centos00-swap: UUID="df6fc950-9928-4c72-af6b-16b5b872f1df" TYPE="swap"
/dev/mapper/centos00-root: UUID="172883a3-ce08-447b-91e5-d1ef7649c2c8" TYPE="xfs"
/dev/dm-1: UUID="172883a3-ce08-447b-91e5-d1ef7649c2c8" TYPE="xfs"

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Grub2 wont detect Windows 7 Partition

Post by TrevorH » 2015/05/03 13:05:45

set root='(hd1,3)'
This is defintely wrong. In fact when I look at my script that I have in /etc/grub.d/15_windows, I have

Code: Select all

#!/bin/bash -e
echo "Adding Windows" >&2
cat <<EOF
menuentry "Windows 7" {
set root='hd0,msdos1'
chainloader +1
}
EOF
Don't forget to chmod +x the /etc/grub.d script file.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

eddie70
Posts: 5
Joined: 2015/05/03 12:42:12

Re: Grub2 wont detect Windows 7 Partition

Post by eddie70 » 2015/05/03 14:58:50

Hi

Thanks for that. I added that the script and got the following
grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-229.1.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.1.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-c653dd290c4a4bc087154edb4e5fd561
Found initrd image: /boot/initramfs-0-rescue-c653dd290c4a4bc087154edb4e5fd561.img
Adding Windows
done

So it did run it however it still did not pick up the Windows partition. I rebooted just to make sure and did not get the option.

I also changed the set root='hd1,msdos0' from hd0 to hd1 and tried msdos0 to msdos3. Still no luck.

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Grub2 wont detect Windows 7 Partition

Post by TrevorH » 2015/05/03 17:54:24

Yours would be hd1 and msdos2
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

eddie70
Posts: 5
Joined: 2015/05/03 12:42:12

Re: Grub2 wont detect Windows 7 Partition

Post by eddie70 » 2015/05/04 06:00:26

I did try that as well.

I have also tried the old method (hd1,0) through to (hd1,3).

Still no luck.

It seems that grub is simply not picking up the boot sector of the windows instillation ? I know it works cose I can boot in to it if I change boot order in bios.

Am I maybe missing some software ? os-probe is installed however what is really getting me is when I do the following.
# linux-boot-prober /dev/sda2
/dev/sda2:/dev/sda2::/vmlinuz-0-rescue-c653dd290c4a4bc087154edb4e5fd561:/initramfs-0-rescue-c653dd290c4a4bc087154edb4e5fd561.img:root=/dev/sda2
/dev/sda2:/dev/sda2::/vmlinuz-3.10.0-123.el7.x86_64:/initramfs-3.10.0-123.el7.x86_64.img:root=/dev/sda2
/dev/sda2:/dev/sda2::/vmlinuz-3.10.0-229.1.2.el7.x86_64:/initramfs-3.10.0-229.1.2.el7.x86_64.img:root=/dev/sda2
# linux-boot-prober /dev/sdb2
#

Nothing comes up under the sdb2 almost like nothing is there. I thought maybe windows 7 makes a separate boot partition and I see there is a 1GB partition on that disk.
Number Start End Size Type File system Flags
1 1049kB 1000MB 999MB primary
2 1000MB 250GB 249GB primary ntfs boot
4 251GB 2450GB 2199GB extended lba
5 251GB 2199GB 1948GB logical ntfs

I tried changing the boot flag to partition 1. and the (hd1,msdos2) to msdos1 ) and msdos0) for good measure.
When I tried to change boot order in bios with this set up I could not boot to windows, also grub2 did not pick it up and linux-boot-probe still did not pick it up so change the boot back to sdb2.
# linux-boot-prober /dev/sdb1
#

Also ntfs-3g.probe does not pick up anything for sdb1, where it does for sdb2.

# ntfs-3g.probe --readwrite /dev/sdb2
# ntfs-3g.probe --readwrite /dev/sdb1
NTFS signature is missing.
#

What else should i be tiring ? What exactly does grub2 (grub2-mkconfig) look for when it sets up the configs ? I think that is missing ?

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Grub2 wont detect Windows 7 Partition

Post by TrevorH » 2015/05/04 11:52:31

What's it actually generating in the grub.cfg section for Windows?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

eddie70
Posts: 5
Joined: 2015/05/03 12:42:12

Re: Grub2 wont detect Windows 7 Partition

Post by eddie70 » 2015/05/04 20:37:45

OK progress

on ur comment I did a search for grub.cfg files and found two.
/boot/efi/EFI/centos/grub.cfg
/boot/grub2/grub.cfg

So this time I did
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
in place of
grub2-mkconfig -o /boot/grub2/grub.cfg

I rebooted and there is now an option for Windows 7.
However I'm now getting the error

error: file '/EFI/centos/x86_64_efi/ntfs.mod' not found
error: invalid EFI file path

So
# locate ntfs.mod
# nada so lets see if I can find it.

OK things just got interesting
yum provides */ntfs.mod
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.ufs.ac.za
* epel: ftp.wa.co.za
* extras: mirror.ufs.ac.za
* updates: mirror.ufs.ac.za
epel/x86_64/filelists_db | 6.3 MB 00:03:58
extras/7/x86_64/filelists_db | 87 kB 00:00:03
updates/7/x86_64/filelists_db | 836 kB 00:01:26
1:grub2-2.02-0.16.el7.centos.x86_64 : Bootloader with support for Linux, Multiboot and more
Repo : base
Matched from:
Filename : /usr/lib/grub/i386-pc/ntfs.mod

1:grub2-efi-modules-2.02-0.16.el7.centos.x86_64 : Modules used to build custom grub.efi images
Repo : base
Matched from:
Filename : /usr/lib/grub/x86_64-efi/ntfs.mod

# ls -ltar /usr/lib/grub/x86_64-efi/ntfs.mod
ls: cannot access /usr/lib/grub/x86_64-efi/ntfs.mod: No such file or directory

OK
#yum -y install grub2-efi-modules-2.02-0.16.el7.centos.x86_64
# grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg

Reboot and same error :( and no file /EFI/centos/x86_64_efi/ntfs.mod. Not sure how to get that file or even if my board is EFI compliant. I might just be going down a long dead end here ?

Post Reply