Fedora 17 has a GRUB2 version that supports booting from a boot partition in a LVM logical volume. That means you can have a full LVM layout of your disk(s) without a separate physical partition for /boot. I want that! Now, I’m rather pleased with my current Fedora setup, so I did not want to do a full re-install. What to do? Would it be possible to lite:rary “move” my existing partitions into LV’s, including /boot? Turn’s out this can be done and it’s fairly (..) easy. You need to have at least the same amount of free disk space available as the separate partitions combined , either in an existing Volume Group or in unused disk space.
I had my Fedora 17 installed on 3 partition’s: swap, boot and root. This is not a default install. A default install has a separate boot partition and the rest lives in a volume group. This procedure also works in that case. Simply apply it then to the boot partition only.
- Create a fourth partition from the remaining space
- Make a LVM Physical device out of it
- Make a Volume Group from the Physical device or grow your existing volume Group if you have that.
- Make a Logical Volume for each to-be-migrated existing partition. Give it a descriptive name and make it exactly the same size as the partition it needs to hold. You could also make them slightly larger. When your done you can then resize the LV’s to a smaller size if you like. There are procedures for that. So, in my case, I created a lv_swap, lv_boot and lv_root Logical volume in my Volume Group called vg00.
- Make a swap for lv_swap:
|
1 |
<span style="font-family: courier new,courier;"># mkswap /dev/vg00/lv_swap</span> |
- Now use dd to make an exact block-by-block copy of the running system from each to-be-migrated partition to each corresponding Logical Volume. In my case this looks like this:
|
1 2 |
<span style="font-family: courier new,courier;"># dd if=/dev/sda2 of=/dev/vg00/lv_boot bs=4k</span> <span style="font-family: courier new,courier;"># dd if=/dev/sda3 of=/dev/vg00/lv_root bs=4k</span> |
|
1 2 |
<span style="font-family: courier new,courier;"># uuidgen d86e14cc-7406-4b5b-b5d2-9630c25ef9b5</span> # tune2fs /dev/vg00/lv_boot -U d86e14cc-7406-4b5b-b5d2-9630c25ef9b5 |
- Next is do adjust the fstab in the etc directory on the involved Logical Volume. Mount this Logical Volume onto /mnt and edit the /mnt/etc/fstab file. I like to use the UUID as a unique device descriptor, so my new fstab like looks like this after editing:
|
1 2 3 |
<span style="font-family: courier new,courier;">UUID=9f99-0d81-e17a-4362-486a-c0764ccbba28 /boot ext4 defaults 1 1</span> <span style="font-family: courier new,courier;">UUID=a937-7f3c-54e2-7c4f-324e-43d2e43658ae / ext4 defaults 1 0</span> <span style="font-family: courier new,courier;">UUID=e934-0ed9-6db9-4366-9278-408ee9667967 swap swap defaults 1 0</span> |
BTW, You can get a list of the UUID’s from all you’re devices using the “blkid” command.
|
1 2 3 |
<span style="font-family: courier new,courier;">/dev/mapper/vg00-lv_boot /boot ext4 defaults 1 1</span> <span style="font-family: courier new,courier;">/dev/mapper/vg00-lv_root / ext4 defaults 1 2</span> <span style="font-family: courier new,courier;">/dev/mapper/vg00-lv_swap swap swap defaults 1 0</span> |
- Next up is the bootloader. We need to add an extra menu entry in the boot loader to boot from the new location. With GRUB2, this is very ease, because there is a script available to do just that. It will search your system for installed operating systems. The statement to do this is:
|
1 |
<span style="font-family: courier new,courier;"># grub2-mkconfig -o /boot/grub2/grub.cfg</span> |
- Now reboot. You will see a new entry in the boot menu. Choose that and boot into your Fedora17 OS in the new location. Hooray! We are however NOT finished. We need to change the GRUB config on the new installation also. Because we are now running in this new location, we can simply to the previous statement again:
|
1 |
<span style="font-family: courier new,courier;"># grub2-mkconfig -o /boot/grub2/grub.cfg</span> |
- If this enough? No, because the stage 1 GRUB in the MBR is still looking at the old /boot partition to find it’s GRUB config. So we also need to change that, by installing GRUB2 again:
|
1 |
<span style="font-family: courier new,courier;"># grub2-install /dev/<your_disk_device_name></span> |
- Reboot and choose the new installation again to see if it still works.
- Now we can clean up the old installation by removing the partitions. It depends on your specific partition layout what to do with them. I just turned them into LVM Physical Volumes and added them to my Volume Group vg00.
- Edit the file /etc/default/grub. There is an entry that starts with GRUB_CMDLINE_LINUX. Check if in that line there is a text like “rd.lvm-0″. If there is, remove it and save the file.
- The old Fedora 17 install is still in the boot menu. Remove it by simply generating a new GRUB2 config:
|
1 |
<span style="font-family: courier new,courier;"># grub2-mkconfig -o /boot/grub2/grub.cfg</span> |
- Reboot to test and your done!




Comments are closed.