How to dual boot RHEL7 and Windows 7

Today while installing RHEL7 on my existing laptop running windows 7 , I had tough time. Therefore, I have decided to put all the steps required to install RHEL7 on a Windows7 system for you convenience. Below are the step by step details:

Open Disk Management by pressing Win + R  & type diskmgmt.msc and press enter in windows 7.

diskmgmt

 

 

 

 

Try to shrink an existing partition to create free space for the installation of Linux.

diskmgmt2

 

 

 

Say you have 200 GB free space in drive D: . Right click on the D: and choose shrink . Please do not create any new partition at this moment.

diskmgmt4

 

 

 

 

diskmgmt4

 

 

 

 

Insert the Linux installation disk and reboot the machine and follow the installation instruction and install the Linux in allocated partition created earlier by diskmgmt.msc. Once the installation in done reboot the system.

Oh ho, what’s gone wrong?  You have not noticed windows in the grub menu. Don’t worry; we will resolve this shortly by following below steps.

1) Find out on which partition bootable windows reside by executing the command fdisk -l.

fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes, 976773168 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 label type: dos
Disk identifier: 0x65e700b9

Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048      206847      102400    6  FAT16
/dev/sda2   *      206848   204799999   102296576    7  HPFS/NTFS/exFAT
/dev/sda3       204800000   771477503   283338752    7  HPFS/NTFS/exFAT
/dev/sda4       771477504   976773167   102647832    5  Extended
/dev/sda5       771479552   772503551      512000   83  Linux
/dev/sda6       772505600   976773119   102133760   8e  Linux LVM

From the above output, it seems like the first partition is the boot partition.

2) Now we need to find out the UUID of the boot partition by executing the command blkid.

[root@localhost ~]# blkid
/dev/sda2: UUID=”1008A27008A2550E” TYPE=”ntfs”
/dev/sda3: LABEL=”New Volume” UUID=”86380ADD380ACC5D” TYPE=”ntfs”
/dev/sda5: UUID=”c9a3beb7-53ef-4fb5-8601-70c7435e7d87″ TYPE=”xfs”
/dev/sda6: UUID=”X5NH1O-Tr2C-XaMT-Wo0A-hBSJ-N7zS-mIalbx” TYPE=”LVM2_member”
/dev/mapper/rhel-root: UUID=”ac98656a-0382-40b6-960c-fa73dfdb2e87″ TYPE=”xfs”
/dev/mapper/rhel-swap: UUID=”27242bff-ce6d-4a3f-bc8d-8b1514bfe47c” TYPE=”swap”
/dev/mapper/rhel-home: UUID=”741dd75d-25f6-4d60-aa1d-16dd2a83bb26″ TYPE=”xfs”

3) Now copy the UUID generated in above step. In my case it is: 1008A27008A2550E.

4) We need to update the grub. Create a file in the directory /etc/grub.d/10_windows7 and add the below entry.

#! /bin/bash
echo “Adding Windows7 to grub conf”
cat << EOF
menuentry “Windows7” {
insmod part_msdos
insmod ntfs
set root=’hd0,msdos1′
search –no-floppy –fs-uuid –set=root 1008A27008A2550E
chainloader +1
}
EOF

where -fs-uuid –set=root 1008A27008A2550E is the entry generated in step 2 by blkid command.

5) Regenerate the grub conf file by executing below command.
grub2-mkconfig -o /boot/grub2/grub.cfg

6) Reboot the system. If everything’s goes well, you can see the windows option in grub menu.

 

Note: If you get Error: Invalid signature, please check UUID generated  in step 2 and update accordingly in the file as mentioned in step 4.