Configure/setup LVM on Centos/redhat 7
- First create a partition:
To create partition free space must be available on the server.
Here we have created 2 GB primary partition.
- Check lvm package installed in the system.
# rpm -qa|grep lvm2
Sometimes in minimal OS installation. Package manager not installed LVM package. So we need to install it by yum. Use below command to install lvm package.
#yum install lvm2
- Create physical volume:
Next step to create physical volume. Use below command to create physical volume
# pvcreate /dev/sda4
To see created physical volume. Use below command as shown below
To see list of physical volumes with all attributes. Use below command as shown below.
- Create the Volume Group
Volume groups are nothing but one or more physical volume. Here we create volume group with name vol_1.
To list created volume groups use command as shown below.
LVM Create: Create Logical Volumes
Now everything is ready to create logical volumes from volume groups. Here we have created logical volume with size 500M.
Use lvdisplay command as shown below, to view the available logical volumes with its attributes.
- Creating file system on Logical volumes:
Use below command as shown below to create file system on logical volumes
- Mount Directory on logical volume:
- Resize lvm
You can extend logical volume as shown below:
To make change in lgoical volume need to run below command
Now you can 200 MB storage space has been added to you logical volume