FedoraForum.org - Fedora Support Forums and Community
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2011
    Location
    Boston, MA
    Posts
    6

    HOW TO: Fedora 15 with /boot inside LVM using GRUB2

    This how to was designed primarily for intermediate to expert users. It is advised that you know your way around and are fluent in the command line.

    INTRO

    A lot of people will advise against putting /boot inside an LVM container claiming that it is unstable and/or dangerous. I will agree with both of these claims; however, Fedora is a bleeding edge distro and I like testing out new features. I also enjoy the idea of only having a single partition contain all my Linux stuff because I boot different OS's a lot. So do not apply this tutorial to something like a server or production machine unless you know exactly what you are doing and the risks associated with your actions.

    Now then, the point behind this guide is to take a clean install of Fedora 15 and move /boot into it's own Logical Volume (here on refereed to as an lv) so that you only have one partition for all of the install and not the usual /boot partition and a LVM partition.

    OUTLINE
    1. Perform the install
    2. Install GRUB2
    3. Setup GRUB2 and test it with chain loading from GRUB Legacy
    4. Create the new boot lv and move data from old /boot
    5. Delete old /boot and edit fstab
    6. Update GRUB2 and install it to the MBR
    7. Reboot and pray

    REQUIREMENTS
    • Fedora 15 install medium (I used the DVD)
    • Time and a taste for adventure

    It is also advised that you have a spare HD and a copy of Clonezilla so you can take snapshots of your progress if something goes wrong. This was a tremendous help to me when constructing the test system so my thanks to them.

    PERFORM THE INSTALL

    So to start off we need an installed system to work with so boot up the installer and do a standard install. The only thing you need to ensure is that when you are doing the partitioning you leave some free space inside the LVM container to create the new /boot. I went with 20GB so I have some space to grow with in the future. When the install is done reboot and setup your new system; then continue on.

    INSTALL GRUB2

    Code:
    su -
    yum install grub2 
    yum install gettext
    GRUB2 SETUP & CHAIN LOADING

    Now we need to use GRUB2's auto config file generator to tell GRUB2 where our kernels are. Then chain load GRUB2 from GRUB so if our test fails we don't end up with a trashed system.
    Code:
    su -
    grub2-mkconfig -o /boot/grub2/grub.cfg
    grub2-install --grub-setup=/bin/true /dev/sda
    Now reboot and press escape just as Fedora starts booting you should get the GRUB menu. Select GRUB2 and then select the kernel you would like to boot into. This should work, if it fails double check everything and trouble shoot this; DO NOT CONTINUE if this fails.

    CREATE NEW boot lv AND MOVE OLD /boot

    It is now time to create the new /boot and copy all the data from the old /boot to the new one.
    Code:
    su -
    lvcreate -L 512M VOLUME GROUP -n lv_boot
    mkfs.ext2 /dev/VOLUME GROUP/lv_boot
    umount /boot
    mount /dev/sda1 /mnt
    mount /dev/VOLUME GROUP/lv_boot /boot
    cp -r /mnt/* /boot
    umount /mnt
    Fill in "VOLUME GROUP" with your computers volume group of course.
    This is now pretty much the time to turn around and give up. Past this if things go wrong the only option really is a rescue Live CD or a fresh install.

    DELTE OLD /boot AND EDIT fstab

    Now lets nuke the old /boot partition and remove it with cfdisk; while you are deleting the old /boot go ahead and mark the LVM partition as bootable while your at it (I had some strange issues when this was not done.)
    Code:
    su -
    dd if=/dev/zero of=/dev/sda1
    cfdisk /dev/sda
    Now edit the line in fstab for /boot from:
    Code:
     UUID=********-****-****-****-************ /boot ext4 defaults  1   2
    to
    Code:
     /dev/mapper/VOLUME GROUP-lv_boot /boot ext2 defaults 1   2
    using nano

    UPDATE GRUB2 & INSTALL TO MBR

    We must now append some info to /etc/defaults/grub so run:
    Code:
    su -
    nano /etc/defaults/grub
    And add “GRUB_PRELOAD_MODULES=lvm” on its own line. GRUB2 needs to be updated and installed now so run:
    Code:
    su -
    grub2-mkconfig -o /boot/grub2/grub.cfg 
    grub2-install /dev/sda
    THANKS AND CONCLUSION
    Many thanks go to Peter Jones who contributed the wiki page outlining the install of GRUB2 on Fedora. I also want to thank Jim Studt who wrote this wonderful write-up on using GRUB2 with a /boot inside LVM on Debian Lenny. His notes were not the best but I was able to decipher them and apply them to Fedora.

    Now the question left assuming this worked for you is what now? Well I plan to expand my LVM container to use up the freed space (I paid for this SSD, I am getting the most out of it.) I will document this and add it to this how to when I get around to it. If their are any inaccuracy's in this guide feel free to point them out.

    ---------- Post added at 04:05 PM ---------- Previous post was at 02:40 PM ----------

    After doing a yum update it would seem that with kernel 2.6.38.6-26.rc1 the system operates fine. But when you try and boot 2.6.38.6-27.rc1 the system throws a kernel panic in GRUB2 about not syncing: VFS: Unable to mount root fs on Unknown-block(0,0). I am investigating this now and will edit this post when I have found a solution

    ---------- Post added at 04:10 PM ---------- Previous post was at 04:05 PM ----------

    Well that was strange but to fix the problem with the kernel panic after an update run
    grub2-mkconfig -o /mnt/grub2/grub.cfg
    grub2-install /dev/sda
    And all will be well.
    Last edited by Scipio; 31st May 2011 at 11:34 PM. Reason: Finished error check by following guide top to bottom
    "While one may lose much because of avarice, nothing was ever accomplished by abstinence" -- Horo, the wise wolf

  2. #2
    Join Date
    Jul 2009
    Posts
    1

    Re: HOW TO: Fedora 15 with /boot inside LVM using GRUB2

    Dear Scipio,

    I have set up lvm2 in raid5, and tried to move /boot to LVM, but got following error message:

    /usr/sbin/grub2-probe: error: physical volume pv0 not found.

    Do you know how to fix this issue? Thank you very much!

    Best Regards,
    Bian Xi

  3. #3
    Join Date
    Jul 2011
    Posts
    5

    Re: HOW TO: Fedora 15 with /boot inside LVM using GRUB2

    I cannot get pass this part
    Code:
     lvcreate -L 512M VOLUME GROUP -n lv_boot
    I found the volume group name via the lvdisplay command under the VG Name.
    But when I try the lvcreate I get this message:
    Volume group "vg_redauir" has insufficient free space (0 extents): 16 required.
    I have also tried to use gparted to shrink the partition, but I was unable to do so.
    Any tips?


    Also this is what I get with lvdisplay -m
    Code:
      --- Logical volume ---
      LV Name                /dev/vg_redauir/lv_swap
      VG Name                vg_redauir
      LV UUID                QYC0Wd-JToJ-cQ6Y-CqH2-mWR6-siQi-6R8ezn
      LV Write Access        read/write
      LV Status              available
      # open                 2
      LV Size                21.66 GiB
      Current LE             693
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:0
       
      --- Segments ---
      Logical extent 0 to 692:
        Type		linear
        Physical volume	/dev/sde3
        Physical extents	0 to 692
       
       
      --- Logical volume ---
      LV Name                /dev/vg_redauir/lv_home
      VG Name                vg_redauir
      LV UUID                oPfeto-QqwX-99f1-fG67-FU3e-lnTh-1PQtaI
      LV Write Access        read/write
      LV Status              available
      # open                 1
      LV Size                161.06 GiB
      Current LE             5154
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:1
       
      --- Segments ---
      Logical extent 0 to 5153:
        Type		linear
        Physical volume	/dev/sde3
        Physical extents	693 to 5846
       
       
      --- Logical volume ---
      LV Name                /dev/vg_redauir/lv_root
      VG Name                vg_redauir
      LV UUID                Vz26Jq-46p3-R1Vw-S0gL-eoLQ-6KAv-DssBya
      LV Write Access        read/write
      LV Status              available
      # open                 1
      LV Size                50.00 GiB
      Current LE             1600
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:2
       
      --- Segments ---
      Logical extent 0 to 1599:
        Type		linear
        Physical volume	/dev/sde3
        Physical extents	5847 to 7446
    Last edited by MiFry; 12th July 2011 at 11:07 PM. Reason: clarity

  4. #4
    Join Date
    May 2005
    Posts
    128

    Re: HOW TO: Fedora 15 with /boot inside LVM using GRUB2

    I have followed your directions exactly and failed twice. Both times I get thrown into grub rescue mode with no such disk errors. I even reinstalled to a new drive created a new lvm while keeping my old lvm but every time I try to move boot to the lvm my system won't boot. Is there anything missing from this write up? Using Fedora 15 64 bit??? I have a correction to make Im not following your instructions exactly because I have a dying drive with the boot partition so I have attempted to move that boot partition to the LVM that still has 2 good physical drives and remove the bad one reducing the LVM from a 3disk LVM to 2 disk LVM. Is this not possibel??? I dont see why not and I have already migrated the extents off of the bad drive to the rest of the LVM. Any suggestions would be a great help. I am at a loss and do not want to have to reinstall.
    Last edited by Kingtu; 12th September 2012 at 03:32 AM.

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. How-To Using Grub2 in Fedora
    By VastOne in forum Guides & Solutions (Not For Questions)
    Replies: 41
    Last Post: 19th February 2012, 01:28 PM
  3. [SOLVED] Putting /boot inside LVM with grub2
    By Scipio in forum Installation, Upgrades and Live Media
    Replies: 2
    Last Post: 1st June 2011, 06:04 PM
  4. Replies: 5
    Last Post: 26th October 2010, 06:53 PM
  5. Fedora 7 - ISO rar - Files inside, how to Burn for Boot
    By Streets in forum Installation, Upgrades and Live Media
    Replies: 2
    Last Post: 17th October 2007, 06:01 AM

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
  •