Extend the root partition in LVM – CentOS7

a) Use the following script:


1) Place this script in /home/compose.

2) Give executable rights chmod +x lvmManagement_Centos7.sh

3) Execute as sudo sh lvmManagement_Centos7.sh

If you do not want to use the script follow the below mentioned steps:

  • ssh to the VM and type “df -h” command to view the partitions and “df -T” for type of partitions.
  • Type “sudo lvs” command to show the logical volumes and volume groups
  • Type “sudo fdisk -l“, here the newely added disk will be visible in /dev/sdb
  • Type “sudo fdisk /dev/sdb” and press the following letters
    Press “n” for new partition
    Press “p” for primary partition
    Press “1” for default value of partition no.
    Let the value of first sector and last sector me deafult
    Press “t” for type of partition
    Press “8e” for the hex code for LVM Partition
    Press “p” to print the value
    Press “w” to write the changes
  • Type “sudo pvcreate /dev/sdb1” to create a new partition
  • Type “sudo vgs”  to find the volume group
  • Use the value of group obtained and type “sudo vgextend cl /dev/sdb1
  • Type “sudo pvs” and “sudo vgs” to get the partitioned volume and volume group
  • Type “sudo lvextend /dev/cl/root -L +{value of extended partition – 1/2 GBs / MBs} -r” to add the volume
  • Type “df -h” tp see the output of storage, you’ll see the that the storage has been extended.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s