Creating LVM Pools

Partition the Disk

    fdisk /dev/sdb #repeat this first step for all disks required (/dev/sdc)

  1. Choose n to create new partition
  2. Choose p to create a primary partition.
  3. Choose which number of partition we need to create. 1 is good for a new disk.
  4. Press Enter twice to use the full space of the Disk or free space.
  5. We need to change the type of newly created partition type t.
  6. Which number of partition need to change, choose the number which we created its 1.
  7. Here we need to change the type, we need to create LVM so we going to use the type code of LVM as 8e, if we do not know the type code Press L to list all type codes.
  8. Press P to print the partitions and see what we created to just confirm.
  9. Here we can see the ID as 8e LINUX LVM.
  10. Write the changes (w) and exit fdisk.

  fdisk -l

Add the Physical Volume to LVM (PV)

    pvcreate /dev/sdb1 #/dev/sdc1 /dev/sdd1 # add as applicable
    pvs #check the creation

Create a Volume Group (VG)

Replace my_new_vg with a name of your choice

    vgcreate -s 32M my_new_vg /dev/sdb1 # /dev/sdc1 /dev/sdd1 #see below for -s variable
    vgs #verify it exists

The -s value sets the size fo the extents (optional) Larger values are best for storing larger files and having larger partitions

Work out the number of extents you need (preferred method)

This VG uses a 32Mb value. If this was a 120gb partition, there would be 120GB / 32MB or 120000 / 32 = 3750 If you want multiple partitions, work out the number for each (10gb, 50gb and 60gb is 312, 1562 and 1875 respectively)

Create each Logical Volume (LV)

    lvcreate -l (Extend size) -n (name_of_logical_volume) (volume_group) #General Syntax
    lvcreate -l 3750 -n disk my_new_vg #Full disk
    OR
    lvcreate -l 312 -n small my_new_vg #Partition 1 10gb
    lvcreate -l 1562 -n medium my_new_vg #Partition 2 50gb
    lvcreate -l 1875 -n big my_new_vg #Partition 3 60gb
    lvs #Check creation

If you are lazy, and don't like maths, you can use estimated GB values:

    lvcreate -L 10G -n small my_new_vg
    lvcreate -L 50G -n medium my_new_vg
    lvcreate -L 50G -n big my_new_vg #We won't have 60GB free
    lvextend -l +100%FREE /dev/my_new_vg/big #use up all the remaining space
    lvs #check creation

Create FileSystem

    mkfs.ext4 /dev/volume_group_name/logical_volume_name #General Syntax
    mkfs.ext4 /dev/my_new_vg/small
    mkfs.ext4 /dev/my_new_vg/medium
    mkfs.ext4 /dev/my_new_vg/big

Mount the new partitions

    mount /dev/volume_group_name/logical_volume_name /mnt/mountpoint/ #general syntax
    mount /dev/my_new_vg/small /mnt/small_LVM_volume
    mount /dev/my_new_vg/medium /mnt/medium_LVM_volume
    mount /dev/my_new_vg/big /mnt/big_LVM_volume
    df -h #confirm

AutoMounting on boot

nano /etc/fstab

    /dev/mapper/volume_group_name-logical_volume_name /mnt/mountpoint filesystem defaults 0 0
    /dev/mapper/my_new_vg-small /mnt/small ext4 defaults 0 0
    /dev/mapper/my_new_vg-medium /mnt/medium ext4 defaults 0 0
    /dev/mapper/my_new_vg-big /mnt/big ext4 defaults 0 0

NOTE THE VARIATION FROM BEFORE!! volume group name is part of the device file, not a folder. Save and exit The partitions will automount!