Centos 7 Add Space VLM

First check to see if you need to add a new Virtual Disk, or if you can just increase the current Virtual disk

Login to the VM and look at this command

fdisk -l

If you already have 4 separate Partitions, you will need to add a New Virtual Disk, Otherwise you can increase the current size, and we’ll add a new LVM Partition to the new space thats added.

Make Linux Find the new space

You NEED to do this as the Root user. So ‘sudo su -‘

If you expanded the existing disk

echo 1 > /sys/block/sda/device/rescan

If you added a new disk

ls /sys/class/scsi_host/

Depending on what your host is, adjust the next command as needed

echo “- – -” > /sys/class/scsi_host/host0/scan

Create the new Parition

Once the rescan is completed, verify you see the new disk, or the new size

fdisk -l

Now we will go into fdisk for the disk that needs the changes, either the free space on the original disk, or the new blank disk

fdisk /dev/sda

enter ‘n’ to create a new partition

enter ‘p’ for a primary partition

enter the partition number that is one higher then the current highest one

First cylinder should default to the first available one in free space

Last Cylinder should default to the last available one in the free space

Now you need to tell it what type of partition it is

enter ‘t’

enter the partition number you just created (eg 4)

the Hex code for VLM is ‘8e’ you can verify that by entering ‘L’

enter ‘q’ to wright the configuration to the disk

Rescan partition table for linux to find the updates

partprobe -s

Sometimes that doesn’t work and you need to do

partx -v -a /dev/sda

Check your work

fdisk -l

You should now see an additional partition you just made (eg /dev/sda4)

Create the Physical Logical Volume

Note, i’ll be using /dev/sda4, be sure to use the correct one you made

pvcreate /dev/sda4

You should see it was created, now find our your Volume Group name

vgdisplay

Now add the Physical volume to the Volume Group

vgextend cl /dev/sda4

Check your work

pvscan

Now you can extend your Logical Volume (eg var) to use the space thats available on the new Physical volume you added. Use lvdisplay to see what the name is.

lvextend /dev/cl/var /dev/sda4

Extend the File system

Assuming your using XFS:

xfs_growfs /dev/mapper/cl-var

If your using EXT:

resize2fs /dev/mapper/cl-var