Fedora Linux Support Community & Resources Center
  #1  
Old 13th February 2012, 11:30 PM
g2nightmare Offline
Registered User
 
Join Date: Feb 2012
Location: virginia
Posts: 42
linuxfirefox
installing grub2 to MBR, looking to do this correctly.

Ok so I've checked guides online but I want to be ABSOLUTELY sure that nothing goes wrong (I backed up important data too, but I don't have the time to restart partitions, etc)

I have:

sda1 - MBR (i think?) it's like 22/100 mb used.
sda2 - windows 7
sda3 - fedora 16 64 bit
sda4/5 swap, etc.

My current set up goes like this:

Turning on the laptop, I get the windows boot manager that boots into either fedora 16 or windows 7.
upon selecting fedora 16, grub starts.
on grub, i am able to boot into windows or linux.

I had installed grub2 onto the partition when installing fedora 16, and I had used EasyBCD on my windows partition to be able to boot into linux for the first time.

What I would like:

To move grub to the MBR, remove windows boot manager, copy all of my previous grub settings.

Please let me know how to do this!

Thanks.
Reply With Quote
  #2  
Old 14th February 2012, 01:52 AM
stoat Offline
Registered User
 
Join Date: Jun 2006
Posts: 7,548
windows_xp_2003ie
Re: installing grub2 to MBR, looking to do this correctly.

Of course, do what you think is best. And in the past, such a thing has been common and routine. But now, considering the recent issues with GRUB 2 and core.img and so on, I would spend some time reconsidering. After all, your current boot loader arrangement is working.

Anyway, theoretically, and IMO, you should be able to accomplish what you described by booting Fedora, opening a terminal, and running grub2-install /dev/sda. I can't think of a reason why you would need to regenerate grub.cfg since it already successfully boots Fedora and Windows, but that should be a harmless thing to do, too.

No promises for anything above this sentence. And don't do anything until you know that you have a way to emergency boot the systems or to repair the Windows boot loader.
Reply With Quote
  #3  
Old 14th February 2012, 02:00 AM
sgage Offline
Registered User
 
Join Date: Nov 2010
Posts: 51
linuxfirefox
Re: installing grub2 to MBR, looking to do this correctly.

Quote:
Originally Posted by g2nightmare View Post
Ok so I've checked guides online but I want to be ABSOLUTELY sure that nothing goes wrong (I backed up important data too, but I don't have the time to restart partitions, etc)

I have:

sda1 - MBR (i think?) it's like 22/100 mb used.
sda2 - windows 7
sda3 - fedora 16 64 bit
sda4/5 swap, etc.

My current set up goes like this:

Turning on the laptop, I get the windows boot manager that boots into either fedora 16 or windows 7.
upon selecting fedora 16, grub starts.
on grub, i am able to boot into windows or linux.

I had installed grub2 onto the partition when installing fedora 16, and I had used EasyBCD on my windows partition to be able to boot into linux for the first time.

What I would like:

To move grub to the MBR, remove windows boot manager, copy all of my previous grub settings.

Please let me know how to do this!

Thanks.
The MBR would be /dev/sda, not /dev/sda1. The MBR is not really a partition, it's a reserved area of the disk for the, well, the Main Boot Record.Whatever you have in /dev/sda1, it ain't the MBR. Probably some Windows System Partition or suchlike.

You should be able to simply (as root) do this:

grub install /dev/sda
update-grub

It should pick up all your installed OS'es and you'll see them in the grub boot menu.

You don't need to remove the Windows boot manager - once you put grub2 in the MBR you won't see it. Unless you select Windows from the grub menu, and then you'll see it.
Reply With Quote
  #4  
Old 14th February 2012, 02:21 AM
stoat Offline
Registered User
 
Join Date: Jun 2006
Posts: 7,548
windows_xp_2003ie
Re: installing grub2 to MBR, looking to do this correctly.

Quote:
Originally Posted by sgage

You should be able to simply (as root) do this:

grub install /dev/sda
update-grub
The correct name of the script for re-installing GRUB in Fedora's version of GRUB 2 is grub2-install. And to my knowledge, there is no update-grub command in Fedora. In the early Fedora grub2 package versions, there was an update-grub2 script. But that disappeared way back with Fedora 13's version, and we have to use grub2-mkconfig to regenerate grub.cfg in Fedora.
Reply With Quote
  #5  
Old 14th February 2012, 02:22 AM
VernDog Offline
Registered User
 
Join Date: Aug 2009
Posts: 327
linuxchrome
Re: installing grub2 to MBR, looking to do this correctly.

I use this command without fail:

Code:
sudo grub2-install --recheck --root-directory=/ /dev/sda
or

su
Code:
grub2-install --recheck --root-directory=/ /dev/sda
I have in the past use dd to backup my MBR just in case:

Code:
dd if=/dev/hda of=boot.mbr bs=512 count=1
edit:Make sure Fedora is the booted linux you want to use, or modify
--root-directory=/ to point to the mounted partition.

Last edited by VernDog; 14th February 2012 at 04:30 AM.
Reply With Quote
  #6  
Old 14th February 2012, 02:29 AM
stoat Offline
Registered User
 
Join Date: Jun 2006
Posts: 7,548
windows_xp_2003ie
Re: installing grub2 to MBR, looking to do this correctly.

Okay. Very well. I thought we were talking about GRUB 2. Maybe not. Or, maybe Fedora 16 has new GRUB 2 script names or symlinks (I haven't even downloaded Fedora 16 yet).

Anyway, you have enough advisors now. Good luck with it.
Reply With Quote
  #7  
Old 14th February 2012, 02:38 AM
sgage Offline
Registered User
 
Join Date: Nov 2010
Posts: 51
linuxfirefox
Re: installing grub2 to MBR, looking to do this correctly.

Quote:
Originally Posted by stoat View Post
The correct name of the script for re-installing GRUB in Fedora's version of GRUB 2 is grub2-install. And to my knowledge, there is no update-grub command in Fedora. In the early Fedora grub2 package versions, there was an update-grub2 script. But that disappeared way back with Fedora 13's version, and we have to use grub2-mkconfig to regenerate grub.cfg in Fedora.
Well, it's been a while since I've fiddled with it. Every other distro calls it "grub-install" and "update-grub". Good ol' Fedora.
Reply With Quote
  #8  
Old 14th February 2012, 03:10 AM
g2nightmare Offline
Registered User
 
Join Date: Feb 2012
Location: virginia
Posts: 42
linuxfirefox
Re: installing grub2 to MBR, looking to do this correctly.

Well I attempted to install grub after carefully reading everything.

sudo grub2-install /dev/sda

seemed to work.

followed by:

sudo grub2-mkconfig

grub now loads upon booting the computer. It lists 2 linux kernel and 2 windows partitions.

The first one is my typical windows partition. The second one brings me to the windows boot manager, which allows me to still choose between windows and linux.

I don't get it.. I'm really starting to think sda1 is an empty partition that contains the windows boot manager.

Any ideas?
Reply With Quote
  #9  
Old 14th February 2012, 03:19 AM
stoat Offline
Registered User
 
Join Date: Jun 2006
Posts: 7,548
windows_xp_2003ie
Re: installing grub2 to MBR, looking to do this correctly.

Quote:
Originally Posted by g2nightmare

I'm really starting to think sda1 is an empty partition that contains the windows boot manager.
Well, I don't use any newer Windows systems with the BOOTMGR boot loader, but I often see partition layouts of them with a small boot partition.

Quote:
Originally Posted by g2nightmare

followed by:

sudo grub2-mkconfig
That grub2-mkconfig command needs you to specify an output file (see its man page). Example...
Code:
su
grub2-mkconfig -o /boot/grub/grub.cfg
Figure out the syntax and path for your situation and run it again. Maybe it will help the situation. Maybe not.
Reply With Quote
  #10  
Old 14th February 2012, 03:22 AM
g2nightmare Offline
Registered User
 
Join Date: Feb 2012
Location: virginia
Posts: 42
linuxfirefox
Re: installing grub2 to MBR, looking to do this correctly.

Quote:
Originally Posted by stoat View Post
Well, I don't use any newer Window systems with the BOOTMGR boot loader, but I often see partition layouts of them with a small boot partition.

Next, the grub2-mkconfig command needs you to specify an output file (see the man page). Example...
Code:
su
grub2-mkconfig -o /boot/grub/grub.cfg
Figure out the syntax and path for your situation and run it again. Maybe it will help the situation. Maybe not.
Why is this necessary?

I think I've specified it before. I've changed my /etc/default/grub in the past on this partition and updated it sucessfully. I did it yesterday to make my grub echo "black people" when loading linux, it works just fine.

Maybe I should edit grub.cfg and remove the option from the list?

I plan on using gparted to delete my sda1 and sda2, my goal is to not be totally screwed when I delete it. I'm in the clear right now, right?
Reply With Quote
  #11  
Old 14th February 2012, 03:35 AM
stoat Offline
Registered User
 
Join Date: Jun 2006
Posts: 7,548
windows_xp_2003ie
Re: installing grub2 to MBR, looking to do this correctly.

Quote:
Originally Posted by g2nightmare

Why is this necessary?
As I said in my first post above, I couldn't think of a reason why you needed to regenerate grub.cfg since it was already creating working menu entries for Fedora and Windows and you only wanted to re-install the boot loader. But now you don't like the current menu. GRUB 2 reads the grub.cfg file to create the boot menu. The grub.cfg file is generated by that grub2-mkconfig command. You entered it incorrectly when you decided to run it. Therefore, I suggested you do it again as something to try. It's usually a harmless thing to do, as I also said above.

Quote:
Originally Posted by g2nightmare

I've changed my /etc/default/grub in the past
Right. That file is for setting some global properties for the boot loader. After changes to it, the grub.cfg file should be regenerated.

Quote:
Originally Posted by g2nightmare

Maybe I should edit grub.cfg and remove the option from the list?
Nothing at all wrong with that. Many people do that. You may need to repeat your changes every now and then after the file is regenerated by something.
Reply With Quote
  #12  
Old 14th February 2012, 03:56 AM
PabloTwo Offline
"Registered User" T-Shirt Winner
 
Join Date: Mar 2007
Location: Seville, FL
Posts: 7,562
linuxchrome
Re: installing grub2 to MBR, looking to do this correctly.

You can edit the /boot/grub2/grub.cfg directly to remove whatever menu entries you desire, and that will work. However, when ever you run grub2-mkconfig -o /boot/grub2/grub.cfg afterwards, your edit will be gone. I highly suspect that using grub2-mkconfig alone defaults to using /boot/grub2/grub.cfg as the output file.

The reason a direct edit will be gone is because when you regenerate a new grub.cfg file, all the scripts in /etc/grub.d/ are run, and the 30_os-prober script, will find all bootable items and include them in the new grub2 menu. It'll be back.

You can make edits to the 30_os-prober script itself to exclude selected menu items. I have done so with success so that a long unused install of Windows 2000 on /dev/sdb1 doesn't show up in my grub2 menu. The following works for Windows partitions.
Code:
  if [ -z "${LONGNAME}" ] ; then
    LONGNAME="${LABEL}"
  fi
  if [ "${DEVICE}" = "/dev/sdb1" ]; then
  continue
  fi
The blue text is my edit (added text). It causes the W2K entry to be skipped. The only caveat to this method is that when grub2, the rpm package, gets updated, your edited 30_os-prober file gets replaced with a new file, but the saving grace to that is that your edited file gets saved as 30_os-prober.rpmsave.

Last edited by PabloTwo; 14th February 2012 at 04:02 AM.
Reply With Quote
  #13  
Old 14th February 2012, 04:10 AM
stoat Offline
Registered User
 
Join Date: Jun 2006
Posts: 7,548
windows_xp_2003ie
Re: installing grub2 to MBR, looking to do this correctly.

Quote:
Originally Posted by PabloTwo

I highly suspect that using grub2-mkconfig alone defaults to using /boot/grub2/grub.cfg as the output file.
Maybe so. I don't have a Fedora system with GRUB 2 to check the man page of grub2-mkconfig. But the common man page for the generic grub-mkconfig page specifies the default for the -o option this way...
Quote:
Originally Posted by man page for grub-mkconfig
Code:
 -o, --output=FILE
        output generated config to FILE [default=stdout]
Reply With Quote
  #14  
Old 14th February 2012, 04:28 AM
VernDog Offline
Registered User
 
Join Date: Aug 2009
Posts: 327
linuxchrome
Re: installing grub2 to MBR, looking to do this correctly.

Quote:
-o, --output=FILE output generated config to FILE [default=stdout]
Using grub2-mkconfig from a terminal just outputs the results to the screen.

It's a good way to test how grub picks up partition information

Last edited by VernDog; 14th February 2012 at 04:33 AM.
Reply With Quote
  #15  
Old 14th February 2012, 05:22 PM
g2nightmare Offline
Registered User
 
Join Date: Feb 2012
Location: virginia
Posts: 42
linuxfirefox
Re: installing grub2 to MBR, looking to do this correctly.

Quote:
Originally Posted by stoat View Post
Well, I don't use any newer Windows systems with the BOOTMGR boot loader, but I often see partition layouts of them with a small boot partition.

That grub2-mkconfig command needs you to specify an output file (see its man page). Example...
Code:
su
grub2-mkconfig -o /boot/grub/grub.cfg
Figure out the syntax and path for your situation and run it again. Maybe it will help the situation. Maybe not.
I ran your suggested change. There was no difference. It still generated my same config file with my same fonts.

That brings me back to my original question.

Is it safe to remove sda1/sda2? I should still be able to boot into grub and fedora right?
Reply With Quote
Reply

Tags
correctly, grub2, installing, mbr

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing grub2 on /dev/sdb after /dev/sda died jdc18 Using Fedora 3 11th December 2011 06:31 PM
upgarade 15 to 16 was good before installing grub2 gnulinux Installation, Upgrades and Live Media 1 5th December 2011 11:31 PM
[x86_64] Installing Grub2 on EFI Elv13 Mac Chat 1 24th March 2010 02:44 AM
Yum not installing/removing dependencies correctly srdempster Using Fedora 22 12th April 2008 03:32 PM
not installing correctly? mcmischief Installation, Upgrades and Live Media 2 3rd September 2007 08:07 AM


Current GMT-time: 23:48 (Saturday, 23-09-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat