Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora Resources > Guides & Solutions (No Questions)
FedoraForum Search

Forgot Password? Join Us!

Guides & Solutions (No Questions) Post your guides here (No links to Blogs accepted). You can also append your comments/questions to a guide, but don't start a new thread to ask a question. Use another forum for that.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 31st May 2011, 09:10 PM
Scipio Offline
Registered User
 
Join Date: May 2011
Location: Boston, MA
Posts: 6
linuxfirefox
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.
__________________
"While one may lose much because of avarice, nothing was ever accomplished by abstinence" -- Horo, the wise wolf

Last edited by Scipio; 31st May 2011 at 11:34 PM. Reason: Finished error check by following guide top to bottom
Reply With Quote
  #2  
Old 19th June 2011, 07:23 AM
bianxi Offline
Registered User
 
Join Date: Jul 2009
Posts: 1
windows_xp_2003safari
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
Reply With Quote
  #3  
Old 12th July 2011, 11:06 PM
MiFry Offline
Registered User
 
Join Date: Jul 2011
Posts: 5
linuxfirefox
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:
Quote:
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
Reply With Quote
  #4  
Old 12th September 2012, 03:04 AM
Kingtu Offline
Registered User
 
Join Date: May 2005
Posts: 126
linuxsafari
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.
Reply With Quote
Reply

Tags
/boot, grub2, guide, how to, lvm

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
boot fedora from iso using loopback in grub2 geseeker Installation, Upgrades and Live Media 19 27th February 2013 08:13 PM
How-To Using Grub2 in Fedora VastOne Guides & Solutions (No Questions) 41 19th February 2012 12:28 PM
[SOLVED] Putting /boot inside LVM with grub2 Scipio Installation, Upgrades and Live Media 2 1st June 2011 06:04 PM
grub2 loopback boot from livecd iso image does not work johnshen Using Fedora 5 26th October 2010 06:53 PM
Fedora 7 - ISO rar - Files inside, how to Burn for Boot Streets Installation, Upgrades and Live Media 2 17th October 2007 06:01 AM


Current GMT-time: 12:16 (Saturday, 30-08-2014)

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