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.
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.
- Perform the install
- Install GRUB2
- Setup GRUB2 and test it with chain loading from GRUB Legacy
- Create the new boot lv and move data from old /boot
- Delete old /boot and edit fstab
- Update GRUB2 and install it to the MBR
- Reboot and pray
- 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.
GRUB2 SETUP & CHAIN LOADING
yum install grub2
yum install gettext
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.
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.
lvcreate -L 512M VOLUME GROUP -n lv_boot
mkfs.ext2 /dev/VOLUME GROUP/lv_boot
mount /dev/sda1 /mnt
mount /dev/VOLUME GROUP/lv_boot /boot
cp -r /mnt/* /boot
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.)
dd if=/dev/zero of=/dev/sda1
Now edit the line in fstab for /boot from:
UUID=********-****-****-****-************ /boot ext4 defaults 1 2
/dev/mapper/VOLUME GROUP-lv_boot /boot ext2 defaults 1 2
UPDATE GRUB2 & INSTALL TO MBR
We must now append some info to /etc/defaults/grub so run:
And add “GRUB_PRELOAD_MODULES=lvm” on its own line. GRUB2 needs to be updated and installed now so run:
THANKS AND CONCLUSION
grub2-mkconfig -o /boot/grub2/grub.cfg
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 188.8.131.52-26.rc1 the system operates fine. But when you try and boot 184.108.40.206-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
And all will be well.