Solving the problem of missing Windows 7 entry in grub2 on Fedora 18

I installed Fedora 18 on laptop a couple of weeks back. I basically set up a dual boot system alongside with Windows 7 as I sometimes need Windows to play games and stuff. Despite the installer being pretty convoluted, I managed to install Fedora 18 successfully. After installation though I didn’t find any entry for Windows 7. My first reaction was that I might have corrupted the windows partition, but I checked and it was not the case. After searching for some time, I came across a pretty straightforward solution to this, which is as follows:

1. First we have check for the partition where our windows is installed. For that we need to fire up the terminal and use the following command:

sudo fdisk -l

There should be an output like this :

Disk /dev/sda: 320.1 GB, 320072933376 bytes, 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe3d12c7c

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 357074943 178536448 7 HPFS/NTFS/exFAT
/dev/sda2 357074944 519493904 81209480+ 7 HPFS/NTFS/exFAT
/dev/sda3 519495680 520536063 520192 83 Linux
/dev/sda4 520536064 625142447 52303192 5 Extended
/dev/sda5 520538112 625141759 52301824 8e Linux LVM

Disk /dev/mapper/fedora-root: 12.6 GB, 12582912000 bytes, 24576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes …..

In my case I have my Windows 7 installed in /dev/sda1 partition, which might be different for other people so it’s better to check.

2. Now we need to create a custom grub script to add the Windows entry in the Grub menu. Create a file 15_Windows in the /etc/grub.d  folder and add the following lines to it.

 #! /bin/sh -e
echo "Adding Windows" >&2
cat << EOF
menuentry "Windows" {
set root=(hd0,1)
chainloader +1

Note that we would need root permissions to create this file. Also on the line

“set root=(hd0,1)” , it depends on the partition where we have installed our windows on. My Windows was on my first hard disk ( the only one for that matter) and the first partition, hence hd0,1. hd0 refers to the first hard disk and 1 refers to the first partition. Edit this line to point it to the appropriate Windows partition.

3. Now we make this script executable by all users using the command:

chmod +x /etc/grub.d/15_Windows

4. After this we need to update the grub2 configuration file so that the script we created is always loaded at boot time. The following command accomplishes that

grub2-mkconfig -o /boot/grub2/grub2.cfg

And there all done. The next time you boot your computer, you should see the Windows option in the grub2 menu.

I found the guide originally here.



15 thoughts on “Solving the problem of missing Windows 7 entry in grub2 on Fedora 18

  1. Pingback: Window 7 Tech | Solving the problem of missing Windows 7 entry in grub2 on Fedora …

  2. Hi i have the same problem.
    this is the result of the command fdisk -l:
    linux-oce4:/home # fdisk -l

    WARNING: GPT (GUID Partition Table) detected on ‘/dev/sda’! The util fdisk doesn’t support GPT. Use GNU Parted.

    Disk /dev/sda: 750.2 GB, 750156374016 bytes
    255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disk identifier: 0x5c3358d2

    Device Boot Start End Blocks Id System
    /dev/sda1 16065 756079360 378031648 7 HPFS/NTFS/exFAT
    Partition 1 does not start on physical sector boundary.
    /dev/sda2 * 756080640 1157945343 200932352 7 HPFS/NTFS/exFAT
    /dev/sda3 1157945344 1465143295 153598976 7 HPFS/NTFS/exFAT

    I followed instruction and when i ran the command grub2-mkconfig -o /boot/grub2/grub2.cfg the result is:
    Generating grub.cfg …
    Found theme: /boot/grub2/themes/openSUSE/theme.txt
    Found linux image: /boot/vmlinuz-3.7.10-1.1-desktop
    Found initrd image: /boot/initrd-3.7.10-1.1-desktop
    Adding Windows
    No volume groups found

    And it does not work.

  3. Thank you for some other informative website. Where else may I get that type of info written in such an ideal way? I’ve a mission that I’m just now operating on, and I’ve been on the look out for such information. eekeebadgaed

  4. Pingback: Dual Boot Linux preventing Windows boot

  5. merci tu me sauves la vie de la fonction a merveille (thank you you saved my life function perfectly) no grub2-mkconfig -o /boot/grub2/grub2.cfg (grub-mkconfig -o /boot/grub/grub.cfg)

  6. Pingback: Windows 7… Perché non compari in grub2? | A dummy linux user

  7. thanks a lot….after installing RHEL 7 in my lappy …windows was missing.. by the above steps i made it possible.

  8. basu, thanks for this post, I followed every line but noticed a few differences:

    1. Partition # do not start from 1, but 0, as mentioned in the linked page
    2. The output of the last command writes to grub2.cfg, but my system (CentOS) reads only grub.cfg (for whatever reason the pathetic RH releases all differ in too many ways)
    3. I tried all combinations but it still ended up with: ‘Invalid Signature’ while selecting Windows in the boot list.

    My setup: lenovo T540p, W7, 500G SSD

    • The differences might be because of the grub version. This was written for grub 2 (hence the grub2.cfg) and the particular CentOS version might be using an earlier version. You might want to check that.

  9. Pingback: EFI dual boot windows 7 under fedora 23 – Internet and Tecnnology Answers for Geeks

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s