Creating and extending Linux LVMs

By | December 18, 2019

Notes on how to create or add disk, volume groups and logical volume in Linux (RedHat)

1. First add disk to system by what ever means your system requires.

2. Find name of disk using fdisk
# fdisk -l /dev/sd* | grep i 'Disk'

For my examples below, it would have listed sdb but not had any partition data with it.

3. Create a new partition on the disk using fdisk
# fdisk /dev/sdb
n to create a new partition
p for primary
enter through the other options
w to write the config and exit

3. make sure the disk and partition are setup OK by using lslbk
# lslbk

4. create the physical volume (pv) on the new disk (sdb1)
# pvcreate /dev/sdb1

5. list current volume groups
# vgs

6a. to create a new volume group, use vgcreate with the volume group name (vg_oracle) and the disk device (/dev/sdb1)
# vgcreate vg_oracle /dev/sdb

6b. extend the current volume group to include the new physical volume use vgextend with the volume group name (vg_oracle) and the disk device (/dev/sdb1)
# vgextend vg_oracle /dev/sdb1

7a. to create a new volume group
# lvcreate -L 20G -n lv_u01 vg_oracle

7b. to extend the logical volume
to increase it by 100GB
# lvextend -L +100G /dev/mapper/vg01_data-lv_data
to increase it to use 25% of the free space
# lvextend -l +25%FREE /dev/mapper/vg01_data-lv_data
to increase it to use all of the free space
# lvextend -l +100%FREE /dev/mapper/vg01_data-lv_data

8a. then create a xfs file system
# mkfs /dev/vg_oracle/lv_u01

8b. or resize the xfs file system
# xfs_growfs /u01

Leave a Reply

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