FedoraForum.org - Fedora Support Forums and Community
Page 1 of 3 1 2 3 LastLast
Results 1 to 15 of 42
  1. #1
    Join Date
    Apr 2011
    Location
    On a desperate edge...
    Posts
    170

    How-To Using Grub2 in Fedora

    The following outlines how to install and use Grub2 in Fedora. It will be an ongoing How-To as more of the tools involved are added upstream

    Small History... I came over from Canonical/Ubuntu and was surprised to see that Grub2 was not that widely used or even developed..

    I found this blog posting from Hedayat Vatankhah at his blogsite and this is what I did to replace the Ubuntu Grub2 with Fedora grub2 with the os-prober that Hedayat ported to Fedora and installing grub2

    1: Install os-prober

    Code:
    sudo yum install os-prober
    2: Install grub2 using yum

    Code:
    sudo yum install grub2
    3: Install grub2 to the mba

    Code:
    sudo grub2-install /dev/sda
    4: edit /etc/default/grub

    Code:
    sudo gedit /etc/default/grub
    and add this line

    Code:
    GRUB_DISTRIBUTOR=$(sed "s/.*(\(.*\))/\1/" /etc/system-release)
    This fixes this bug in Grub2 that does not correctly identify Fedora distribution name in the proper syntax

    You can also add

    Code:
    GRUB_DEFAULT=2
    to set what the default boot is ... In my case it is the 3rd boot line (Remember that in grub the first item is 0, the second is one the third is two etc etc etc)

    You can also add

    Code:
    GRUB_TIMEOUT=10
    the default is 5.. If you want 5 then this is not needed... If you want more then add it to what you want

    Note
    Anytime this file is changed you must run the command outlined in step 4

    4: Now run this to update grub.cfg

    Note
    You will need to run this same thing any time there is a new kernel added anywhere on your system

    Code:
    sudo grub2-mkconfig -o /boot/grub2/grub.cfg
    Thats it.. When you reboot, it will be Fedoras grub2 and the same options are always there..

    This is what my finished /boot/grub2/grub.cfg looks like

    Code:
    #
    # /boot/grub2/grub.cfg
    
    # DO NOT EDIT THIS FILE
    #
    # It is automatically generated by /usr/sbin/grub2-mkconfig using templates
    # from /etc/grub.d and settings from /etc/default/grub
    #
    
    ### BEGIN /etc/grub.d/00_header ###
    if [ -s $prefix/grubenv ]; then
      load_env
    fi
    set default="2"
    if [ ${prev_saved_entry} ]; then
      set saved_entry=${prev_saved_entry}
      save_env saved_entry
      set prev_saved_entry=
      save_env prev_saved_entry
      set boot_once=true
    fi
    
    function savedefault {
      if [ -z ${boot_once} ]; then
        saved_entry=${chosen}
        save_env saved_entry
      fi
    }
    insmod ext2
    set root='(hd0,6)'
    search --no-floppy --fs-uuid --set 951268a2-e667-4181-978c-526c0b71cf02
    set locale_dir=($root)/boot/grub2/locale
    set lang=en
    insmod gettext
    set timeout=5
    ### END /etc/grub.d/00_header ###
    
    ### BEGIN /etc/grub.d/10_linux ###
    menuentry "Lovelock GNU/Linux, with Linux 2.6.39-0.rc4.git2.0.fc15.x86_64" --class lovelock --class gnu-linux --class gnu --class os {
    	set gfxpayload=keep
    	insmod ext2
    	set root='(hd0,6)'
    	search --no-floppy --fs-uuid --set 951268a2-e667-4181-978c-526c0b71cf02
    	echo	Loading Linux 2.6.39-0.rc4.git2.0.fc15.x86_64 ...
    	linux	/boot/vmlinuz-2.6.39-0.rc4.git2.0.fc15.x86_64 root=UUID=951268a2-e667-4181-978c-526c0b71cf02 ro quiet rhgb 
    	echo	Loading initial ramdisk ...
    	initrd	/boot/initramfs-2.6.39-0.rc4.git2.0.fc15.x86_64.img
    }
    menuentry "Lovelock GNU/Linux, with Linux 2.6.39-0.rc4.git2.0.fc15.x86_64 (recovery mode)" --class lovelock --class gnu-linux --class gnu --class os {
    	set gfxpayload=keep
    	insmod ext2
    	set root='(hd0,6)'
    	search --no-floppy --fs-uuid --set 951268a2-e667-4181-978c-526c0b71cf02
    	echo	Loading Linux 2.6.39-0.rc4.git2.0.fc15.x86_64 ...
    	linux	/boot/vmlinuz-2.6.39-0.rc4.git2.0.fc15.x86_64 root=UUID=951268a2-e667-4181-978c-526c0b71cf02 ro single quiet rhgb
    	echo	Loading initial ramdisk ...
    	initrd	/boot/initramfs-2.6.39-0.rc4.git2.0.fc15.x86_64.img
    }
    menuentry "Lovelock GNU/Linux, with Linux 2.6.38.5-24.fc15.x86_64" --class lovelock --class gnu-linux --class gnu --class os {
    	set gfxpayload=keep
    	insmod ext2
    	set root='(hd0,6)'
    	search --no-floppy --fs-uuid --set 951268a2-e667-4181-978c-526c0b71cf02
    	echo	Loading Linux 2.6.38.5-24.fc15.x86_64 ...
    	linux	/boot/vmlinuz-2.6.38.5-24.fc15.x86_64 root=UUID=951268a2-e667-4181-978c-526c0b71cf02 ro quiet rhgb 
    	echo	Loading initial ramdisk ...
    	initrd	/boot/initramfs-2.6.38.5-24.fc15.x86_64.img
    }
    menuentry "Lovelock GNU/Linux, with Linux 2.6.38.5-24.fc15.x86_64 (recovery mode)" --class lovelock --class gnu-linux --class gnu --class os {
    	set gfxpayload=keep
    	insmod ext2
    	set root='(hd0,6)'
    	search --no-floppy --fs-uuid --set 951268a2-e667-4181-978c-526c0b71cf02
    	echo	Loading Linux 2.6.38.5-24.fc15.x86_64 ...
    	linux	/boot/vmlinuz-2.6.38.5-24.fc15.x86_64 root=UUID=951268a2-e667-4181-978c-526c0b71cf02 ro single quiet rhgb
    	echo	Loading initial ramdisk ...
    	initrd	/boot/initramfs-2.6.38.5-24.fc15.x86_64.img
    }
    menuentry "Lovelock GNU/Linux, with Linux 2.6.38.5-22.fc15.x86_64" --class lovelock --class gnu-linux --class gnu --class os {
    	set gfxpayload=keep
    	insmod ext2
    	set root='(hd0,6)'
    	search --no-floppy --fs-uuid --set 951268a2-e667-4181-978c-526c0b71cf02
    	echo	Loading Linux 2.6.38.5-22.fc15.x86_64 ...
    	linux	/boot/vmlinuz-2.6.38.5-22.fc15.x86_64 root=UUID=951268a2-e667-4181-978c-526c0b71cf02 ro quiet rhgb 
    	echo	Loading initial ramdisk ...
    	initrd	/boot/initramfs-2.6.38.5-22.fc15.x86_64.img
    }
    menuentry "Lovelock GNU/Linux, with Linux 2.6.38.5-22.fc15.x86_64 (recovery mode)" --class lovelock --class gnu-linux --class gnu --class os {
    	set gfxpayload=keep
    	insmod ext2
    	set root='(hd0,6)'
    	search --no-floppy --fs-uuid --set 951268a2-e667-4181-978c-526c0b71cf02
    	echo	Loading Linux 2.6.38.5-22.fc15.x86_64 ...
    	linux	/boot/vmlinuz-2.6.38.5-22.fc15.x86_64 root=UUID=951268a2-e667-4181-978c-526c0b71cf02 ro single quiet rhgb
    	echo	Loading initial ramdisk ...
    	initrd	/boot/initramfs-2.6.38.5-22.fc15.x86_64.img
    }
    ### END /etc/grub.d/10_linux ###
    
    ### BEGIN /etc/grub.d/30_os-prober ###
    menuentry "Ubuntu 10.10 (10.10) (on /dev/sda1)" {
    	insmod ext2
    	set root='(hd0,1)'
    	search --no-floppy --fs-uuid --set 788582ac-a45e-4289-8fc3-36d3caaa0137
    	linux /boot/vmlinuz-2.6.38-020638-generic root=/dev/sda1
    	initrd /boot/initrd.img-2.6.38-020638-generic
    }
    ### END /etc/grub.d/30_os-prober ###
    
    ### 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.
    ### END /etc/grub.d/40_custom ###
    
    ### BEGIN /etc/grub.d/90_persistent ###
    ### END /etc/grub.d/90_persistent ###
    Note
    I am using Fedora 15 .. this should work with any Fedora release that supports grub2

    I want to stress again that this is an ongoing project and will be updated as the changes happen

    EDIT

    May 8 2011

    I got grub2 1.99~rc2 up and functioning perfectly with os-prober

    If you compile grub2 1.99~rc2 you must create

    /usr/local/etc/default

    and then copy the file grub from /etc/default to /usr/local/etc/default

    This will then read and parse the grub file information
    Last edited by VastOne; 9th May 2011 at 04:56 PM. Reason: update info regarding grub2 1.99~rc2

  2. #2
    tox Guest

    Re: How-To Using Grub2 in Fedora

    i have asked in Bugzilla if 1.99 final will be available for F15, i'll try an keep this updated if it is or not

  3. #3
    Join Date
    Apr 2011
    Location
    On a desperate edge...
    Posts
    170

    Re: How-To Using Grub2 in Fedora

    Quote Originally Posted by detox
    i have asked in Bugzilla if 1.99 final will be available for F15, i'll try an keep this updated if it is or not
    I appreciate that... Thank you

  4. #4
    Join Date
    Apr 2011
    Location
    On a desperate edge...
    Posts
    170

    Re: How-To Using Grub2 in Fedora

    An interesting note, in grub2 1.99~rc2 the '2' has been removed from the commands

    grub2-mkconfig

    is

    grub-mkconfig

    This may change when packaged for Fedora, I do not know for sure...?

  5. #5
    tox Guest

    Re: How-To Using Grub2 in Fedora

    me neither dude sorry

    ---------- Post added at 09:12 AM ---------- Previous post was at 08:53 AM ----------

    here's your Bug and a followup http://lists.gnu.org/archive/html/bu.../msg00040.html http://savannah.gnu.org/bugs/?33265

  6. #6
    Join Date
    Apr 2011
    Location
    On a desperate edge...
    Posts
    170

    Re: How-To Using Grub2 in Fedora

    Quote Originally Posted by detox
    me neither dude sorry

    ---------- Post added at 09:12 AM ---------- Previous post was at 08:53 AM ----------

    here's your Bug and a followup http://lists.gnu.org/archive/html/bu.../msg00040.html http://savannah.gnu.org/bugs/?33265
    Compiling it with

    ./configure --prefix=/usr

    would have done it correctly...

    My haste got the best of me...

    Thanks...

    On another note, Debian allows for entries like this in 40_custom entries

    menuentry “Daily on sda6″ {
    set root=(hd0,13)
    linux /vmlinuz root=/dev/sda6 ro quiet splash
    initrd /initrd.img
    }

    where the latest kernel entry is found in /boot on sda6 because Debian has built in symlinks...

    Is there an easy way to add these symlinks to Fedora to allow for the same thing?

    And on a larger scale, I am curious as to why it is not there by default... It would make things much easier... Especially when testing daily builds or multiple distros

  7. #7
    Join Date
    May 2009
    Location
    /dev/ph
    Posts
    317

    Re: How-To Using Grub2 in Fedora

    You can eliminate most problems with GRUB2 by simply editing grub.cfg directly.

    The requirement to edit /etc/default/grub and then run grub-mkconfig adds a layer of complexity to GRUB2 not needed by most users.

  8. #8
    Join Date
    Apr 2011
    Location
    On a desperate edge...
    Posts
    170

    Re: How-To Using Grub2 in Fedora

    Quote Originally Posted by fpmurphy
    You can eliminate most problems with GRUB2 by simply editing grub.cfg directly.

    The requirement to edit /etc/default/grub and then run grub-mkconfig adds a layer of complexity to GRUB2 not needed by most users.
    True..

    Most users of grub2 (in Debian) are used to this method and complexity as it has always been the norm to edit /etc/default/grub and then run update-grub

  9. #9
    Join Date
    Sep 2007
    Location
    Isfahan, Iran
    Age
    31
    Posts
    18

    Re: How-To Using Grub2 in Fedora

    Quote Originally Posted by VastOne
    An interesting note, in grub2 1.99~rc2 the '2' has been removed from the commands

    grub2-mkconfig

    is

    grub-mkconfig

    This may change when packaged for Fedora, I do not know for sure...?
    Yes, the "2" is added in Fedora packaging to clearly separate it from Fedora's Grub 1.

  10. #10
    bob's Avatar
    bob is online now Administrator (yeah, back again)
    Join Date
    Jul 2004
    Location
    Colton, NY; Junction of Heaven & Earth (also Routes 56 & 68).
    Age
    72
    Posts
    23,385

    Re: How-To Using Grub2 in Fedora

    moved to Guides & Solutions
    Linux & Beer - That TOTALLY Computes!
    Registered Linux User #362651


    Don't use any of my solutions on working computers or near small children.

  11. #11
    Join Date
    May 2011
    Location
    Trinidad & Tobago
    Posts
    20

    Re: How-To Using Grub2 in Fedora

    A broken dependency in GRUB2 requires that you install the gettext first if it was not installed by some other package.

    Code:
    su -c "yum install gettext"
    Or has this been fixed?

  12. #12
    Join Date
    May 2009
    Location
    /dev/ph
    Posts
    317

    Re: How-To Using Grub2 in Fedora

    The latest GRUB2 sources come with an internal gettext. See ../grub-core/gettext/gettext.c and read the ABOUT-NLS file.

    To include the internal gettext support use
    Code:
    ./configure --with-included-gettext

  13. #13
    Join Date
    May 2011
    Location
    Trinidad & Tobago
    Posts
    20

    Re: How-To Using Grub2 in Fedora

    Actually, I was referring to GRUB2 available from the repos, not building from source.

    ---------- Post added at 07:44 PM ---------- Previous post was at 07:25 PM ----------

    To be a bit more accurate:

    From the first post:

    3: Install grub2 to the mba
    Should be install GRUB2 bootloader to the MBR (Master Boot Record). What is MBA?

    4: edit /etc/default/grub

    Code:
    Code:
    sudo gedit /etc/default/grub
    and add this line

    Code:
    Code:
    GRUB_DISTRIBUTOR=$(sed "s/.*(\(.*\))/\1/" /etc/system-release)
    Of course you can also install the lsb package:
    Code:
    su -c "yum install redhat-lsb"
    And add the line:
    Code:
    GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null`
    to you /etc/default/grub configuration file, which would keep it it in line with other distros.

    Or, forget all of the above and simply add:
    Code:
    GRUB_DISTRIBUTOR="Fedora"
    I got grub2 1.99~rc2 up and functioning perfectly with os-prober

    If you compile grub2 1.99~rc2 you must create

    /usr/local/etc/default

    and then copy the file grub from /etc/default to /usr/local/etc/default

    This will then read and parse the grub file information
    QUESTION: Would this be necessary if you set prefix=/usr instead oif /usr/local? In Ubuntu the above is not necessary with prefix=/usr.

  14. #14
    Join Date
    Feb 2005
    Posts
    58

    Smile Re: How-To Using Grub2 in Fedora- Does "yum update" still work

    Question:
    when Fedora 15 is installed with Grub 2, then does automated updates of kernels works?

    Else we should run "Grub-update", after the proper RPM has installed the initrd, and new kernel (and a bit more) into /boot.

    Hopefully that works, else an RPM package to do the work for Fedora 15, to behave properly when used with Grub 2, would be both feasible, and a great first step towards full support and test of Grub 2, with upcoming versions of Fedora, starting with Fedora 16.

    Any volunteer? (Unfortunately not me for now: busy w/Embedded Linux)

  15. #15
    Join Date
    May 2009
    Location
    /dev/ph
    Posts
    317

    Re: How-To Using Grub2 in Fedora

    No, automatic creation of a new menu stanza for GRUB2 does not occur at present when a kernel is updated on F15.

Page 1 of 3 1 2 3 LastLast

Similar Threads

  1. boot fedora from iso using loopback in grub2
    By geseeker in forum Installation, Upgrades and Live Media
    Replies: 19
    Last Post: 27th February 2013, 09:13 PM
  2. dual booting fedora and ubntu should i use grub or grub2?
    By sreek in forum Installation, Upgrades and Live Media
    Replies: 5
    Last Post: 13th November 2011, 06:00 AM
  3. Replies: 4
    Last Post: 29th April 2011, 12:58 AM
  4. Error in building Grub2 in Fedora 10
    By justdo in forum Using Fedora
    Replies: 0
    Last Post: 22nd September 2009, 03:29 PM
  5. Grub2 on Fedora Core 4
    By Computer Guru in forum Using Fedora
    Replies: 8
    Last Post: 8th November 2005, 12:58 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •