Centos7 – Manage LVM & extend LVM

This is a recurrent operation I’m doing regularly these time : extending a Linux partition by adding new virtual disk I’ve attached to a growing VM. Nothing fantastic to expect in this post. Its purpose is to keep on my hand the solution I’ve used to stop searching google and getting a different one every time ;).

This tuto is applicable for centos 7. The content will be updated when I’ll have to perform different operations.

Install LVM

yum install lvm2

With default tools

  • PV – Physical Volume = raw disk
  • VG – Volume Group = group of PV
  • LV – Logical Volume, partition of VG we can mount

Initialize a PV:

  1. use fdisk to create a partition type 8e (LVM)
  2. create the associated PV with pvcreate /dev/sdxy

Create a VG

  1. vgcreate name_of_the_group /dev/sdxy /dev/sd..
  2. verify : vgdisplay

Create the LV

  1. lvcreate -n lv_name –size XXG vg_name or lvcreate -l 100%FREE vg_name
  2. verify : lvdisplay
  3. format: mkfs.ext4 /dev/vg_name/lv_name
  4. add in fstab
/dev/vg_name/lv_name /mount_point ext4 defaults 0 0


BTRFS can be used for compression:

Install on ubuntu : apt install btrfs-progs
Create fs: mkfs.btrfs /dev/vg_name/lv_name
Add in /etc/fstab
/dev/vg_name/lv_name /mount_point btrfs defaults,compress 0 1

Install some tool for helping

# yum install system-storage-manager

Display the running configuration

# ssm list

Create a volume ready for being extended from scratch

Here is an example for a LVM Pool initialized with 1 drive

# ssm create -s 50G -n disk0 --fstype xfs -p pool-name /dev/sdX /mnt/point

we can add drives to the pool :

# ssm add -p pool-name /dev/sdX

Add the entry into the fstab

/dev/dm-0         /mnt/point            xfs     defaults     0 0

References

  • http://xmodulo.com/manage-lvm-volumes-centos-rhel-7-system-storage-manager.html

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.