Anaconda did not cofigure grub 2 correctly

General support questions
Post Reply
emildavis
Posts: 2
Joined: 2014/07/21 02:49:20

Anaconda did not cofigure grub 2 correctly

Post by emildavis » 2014/07/21 03:25:35

Hi everyone. I made a new account and this is my first post. I have been using Fedora for years on my laptop and I have a home server running Centos 6 with three Centos 6 VMs. My foray into Linux is not new but I have encountered a problem that is new to me and I seem to be stumped in solving it.

As the title states I installed Centos 7 over the weekend and the Anaconda installer did not configure my dual boot setup correctly. My laptop had a functioning Windows 7 Home Premium 64 bit installation prior to installing Centos 7. After installing Centos 7 I have no entry in Grub 2 for Windows. I have run this combination of dual booting Windows 7 and Fedora 16/17/18/19 without issue for years. Anaconda always got it right in the past, even when Fedora switched to the "new" Anaconda installer. I am typing this post in Centos 7 on the machine I am referring to, it is fully functional running Centos, I just cannot boot Windows 7.

Info on laptop:
Acer Aspire 5740G
Was dual booting Fedora 19 & Windows 7 Home Premium 64bit (replaced Fedora 19 with Centos 7)
Intel i7 Q740
8GB DDR3 1333
ATI 5650 1GB
[sda] Intel 320 120GB SSD
[sdb] Intel 330 120GB SSD (replaced DVD-ROM)

Typically I upgrade Fedora by wiping my Linux partitions and rebuilding my mdadm array. Grub has always been configured correctly with Fedora in all the times I have wiped/installed. Yes the drives are structures are atypical from a normal user. The root and /home partitions match and are mdadm raid0 pairs with encryption. When I installed I only formatted /, /boot, and /home. I left the ntfs partitions alone. What is different this time is I encrypted my / and /home partitions which I have never done prior. My partition scheme looks like this:
sda: [500MB /boot] [13GB /] [43GB /home] [64GB win D: (ntfs)]
sdb: [100MB win boot (ntfs)] [65GB win C:(ntfs)] [13GB /] [43GB /home]
This results in ~24GB for / and ~83GB for /home. I do not have any swap. The two windows partitions are stand alone ntfs since Windows Home Premium does not have the capability to do software raid.

What do I need to do to place a new entry into Grub 2 to point to the 100MB windows boot partition? The file system should be intact. Thanks in advance!

paulrooney
Posts: 2
Joined: 2014/07/22 00:53:09

Re: Anaconda did not cofigure grub 2 correctly

Post by paulrooney » 2014/07/22 00:57:14

I am seeing this issue as well. I had expected the centos installer to recognise that there was a partition with another OS and offer dual boot.

It didn't. I now cannot boot my windows server 2008 OS.

Any help would be most appreciated.

paulrooney
Posts: 2
Joined: 2014/07/22 00:53:09

Re: Anaconda did not cofigure grub 2 correctly

Post by paulrooney » 2014/07/24 02:30:45

I got my Windows boot option back by doing the following.I don't know if its the best way but it seems to have worked.

Check the partition that Windows resides on

Code: Select all

>$ sudo fdisk /dev/sda

Code: Select all

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63       80324       40131   de  Dell Utility
/dev/sda2   *       81920    27865087    13891584    7  HPFS/NTFS/exFAT
/dev/sda3        27865088   929521663   450828288    7  HPFS/NTFS/exFAT
/dev/sda4       929521664  1953525167   512001752    5  Extended
/dev/sda5       929523712   930547711      512000   83  Linux
/dev/sda6       930549760  1953523711   511486976   8e  Linux LVM
In my case I had a recovery partition on sda2 (partition index 1) and main Windows on sda3 (partition index 2). Note that partition indexes start from 0, so the Dell utility partition is partition index 0.

Then I backed up and edited /etc/grub.d/40_custom to add the windows boot options. NOTE you shouldn't edit /etc/grub2.cfg directly as it is a generated file and your changes will be lost the next time it is recreated by some other process.

Code: Select all

sudo cp /etc/grub.d/40_custom /etc/grub.d/40_custom.original

Code: Select all

sudo vim /etc/grub.d/40_custom
and add the following lines at the bottom of the file (as directed by comments).

Code: Select all

menuentry "Windows Server 2008 (on /dev/sda3)" {
        set root=(hd0,2)
        chainloader +1
}
You would obviously change your menu text (inside "" quotes), if you are not using Windows Server 2008 on /dev/sda3.
The line set root=(hd0,1) is the important part. The part inside the brackets may vary for you.

hd means hard drive and 0 is the first hard drive (/dev/sda) and 2 is the third partition (keep in mind indexing starts at 0).

Now you must run grub2-mkconfig to regenerate /etc/grub2.cfg. You must pass the location of the output file, otherwise it will generate the output but not write it anywhere (it does not default to /etc/grub2.cfg)

Code: Select all

>$ sudo grub2-mkconfig -o /etc/grub2.cfg
Now check your overwriting worked, you should see the content of /etc/grub.d/40_custom has been written into /etc/grub2.cfg somewhere near the bottom. If it hasn't you could be reloading and scratching your head about why no windows option is showing up.

Code: Select all

>$ sudo cat /etc/grub2.cfg
Now reboot and wait to see your updated boot options.

Code: Select all

>$sudo reboot

emildavis
Posts: 2
Joined: 2014/07/21 02:49:20

Re: Anaconda did not cofigure grub 2 correctly

Post by emildavis » 2014/07/28 00:11:11

Nice one Paul!

I have my system booting correctly as well. My solution was not nearly as in depth.

Thanks too some nice discussion over on fedoraforum.org I found out I needed to run:

Code: Select all

sudo grub2-mkconfig -o /boot/grub2/grub.cfg 
Don't worry the above command is nondestructive.

There were a couple of errors but it still placed a grub.cfg.new file in the /boot/grub2 directory. I opened and read this new file to verify the needed boot entry for Windows 7 was there. Your config will vary depending on what partitions you have which OS installed on. I just needed to verify the following:

Code: Select all

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
cat << EOF
menuentry "Windows 7"{
set root=(hd1,1)
chainloader (hd1,1)+1
}
EOF
### END /etc/grub.d/40_custom ###
Remember how I said this was nondestructive? The command actually creates a grub.cfg.new file. I wanted to be sure to be able to restore my partially working grub config so I renamed my files keeping the original config:

Code: Select all

mv grub.cfg grub.cfg.old
mv grub.cfg.new grub.cfg
One more issue was grub.cfg (my new file) was not readable except by root a quick chmod to give it the same permissions as the original file:

Code: Select all

sudo chmod a+r grub.cfg
There is now a bottom entry in my grub menu at boot for "Windows 7".

pankajanghan
Posts: 1
Joined: 2014/08/19 04:35:32

Re: Anaconda did not cofigure grub 2 correctly

Post by pankajanghan » 2014/08/19 04:37:01

Hi Paul,
Thanks a lot for detailed information.
It worked for me.

dhairya20
Posts: 1
Joined: 2014/10/28 15:09:52

Re: Anaconda did not cofigure grub 2 correctly

Post by dhairya20 » 2014/10/28 20:23:42

Hi Paul,
Thanks a lot it worked for me too..
Thank you very much for this wonderful information..!

lightman47
Posts: 914
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: Anaconda did not cofigure grub 2 correctly

Post by lightman47 » 2014/10/29 21:50:45

In a previous post was mentioned that CentOS 7 has intentionally "dropped' the creation of the Windows entry. Equally as obvious in same post was their/our bewilderment with this Red Hat decision.
The more I learn the 'behinder' I get.

emilakhil
Posts: 1
Joined: 2014/11/19 09:55:22

Re: Anaconda did not cofigure grub 2 correctly

Post by emilakhil » 2014/11/19 10:00:24

Hi Paul. Thanks a lot for the detailed step by step instructions and information.

B52bomber
Posts: 1
Joined: 2015/01/15 12:23:59

Re: Anaconda did not cofigure grub 2 correctly

Post by B52bomber » 2015/01/15 12:35:51

Hi there!

I have installed CentOS 7 beside Windows 8. Now it is a old laptop with BIOS not UEFI.

Installation went smoothly and CentOS 7 in running properly but when booting there is no windows 8 option.

So I started to follow the steps of paul, >$ sudo fdisk /dev/sda

but it's been almost an hour and nothing has happened. If I click to close the terminal, " There is still a process running in this terminal. Clising the terminal will kill it" message shows up. I have updated the OS and thought it will be solved, but another Linux line has been added in the boot menu but no windows 8 option.

What am I suppose to do now? Kindly help me.

Many thanks in advance,

B52bomber (I know it's weird)

User avatar
TrevorH
Forum Moderator
Posts: 26133
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Anaconda did not cofigure grub 2 correctly

Post by TrevorH » 2015/01/15 12:42:01

If you just run fdisk /dev/sda then it will stop and wait for you to tell it what to do. If you wanted to list the partitions then you should run fdisk -l /dev/sda. If you want to quit your current fdisk then just type 'q' and hit enter and it will exit without saving any changes.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

Post Reply