Okay, I know, the title says it all right? And there are hundreds and thousands of tutorials out there that allows you to do this right? Show me one tutorial which tells you what different partitions are needed when you are doing fresh install of Linux especially whose installers do not support LVM/LVM2 installations. Lets take an example of Manjaro, the latest talk of the town. The graphical installers do not have an option to support LVM. Even if you do manual partitioning, it does want to install anything over LVM and it wants the root and swap partitions. Besides, it will forget that we also need a smaller boot partition to install GRUB/SYSLINUX right? Well, atleast it did that to me and either I am too stupid to understand it or I didn’t read the instructions properly. In any case, I headed over to the CLI installer which thankfully had an option to use LVM (which was misguiding) since it wanted to do partitions manually and did not provide any guidance as to what partitions should be created. Instead it more felt like an GUI menu for creating reminding the steps namely partitioning, creating physical volumes (PVs) and creating volume groups (VGs).
So without much ado, below are the things that you really need to do to use LVM properly and then use it without the installers supporting/not supporting it. My assumption is that you want to use all the disks in your computer inside the VG for LVM. Assuming 2 disks, below is the schema.
/dev/sda should have the following partitions.
1. A boot partition of around 256MB (create lesser if you want, will only be used to install GRUB/SYSLINUX/any other boot loader). /dev/sda1
2. A swap partition double the amount of RAM that you have. /dev/sda2
3. A LVM partition covering the whole disk. /dev/sda3
/dev/sdb should have:
1. A swap partition double the amount of RAM that you have /dev/sdb1
2. A LVM partition covering the whole disk. /dev/sdb2
Add whatever number of disks that you need to add but be sure to create the 2 varieties. Use any of fdisk, gdisk, parition managers, etc. to create the needed partitions. Now create the (PVs) and (VGs) that you want. For this the following commands will help.
lvmdiskscan –> shows the partitions available to create volumes
pvcreate <all LVM partitions here> eg: pvcreate /dev/sda3 /dev/sdb2 (for the above example) –> create a physical volume group with the needed partitions
pvdisplay –> list the partitions added to the physical volume(s)
vgcreate <vgname> <partitions to include in this vg> eg: vgcreate vgpool /dev/sda3 /dev/sdb2 –> create a volume group with the name vgpool including the listed partitions
vgdisplay –> Display your volume group and included partitions
lvcreate –l 100%FREE <vgname> –n <logical_volume_name> eg: lvcreate –l 100%FREE vgpool –n lvhome –> creates a logical volume lvhome on the vgpool consuming 100% of the free space on the vg
vgscan and vgchange –ay –> scan and activate the lvms.
At this point in time you should be able to use your LVM for installing. In the installer, go to manual partitioning and select /dev/sda1 as the boot partition and /dev/sda2 as the swap with mount point of /dev/lvhome as root. Hopefully this will avoid the number of formats and partition restructuring that I had to do. Énjoy your new Linux using LVM on this machine. PS: The latest kernel support LVM but if not, do a modprobe on dm-mod install lvm2 before doing all the above.