How to Extend the Disk Partition on CentOS

Document created by fadi.josef Expert on Jan 24, 2017Last modified by dominic.grigg on Apr 6, 2020
Version 4Show Document
  • View in full screen mode

**This document outlines how to resize a partition on a Turbonomic/CentOS VM using a new disk added.**

 

**Be aware** : 

 

This article explains how to add a new virtual disk and to assign all space on that disk to the Turbo logical volume group using:

 

pvcreate /dev/sdb

 

vgextend turbo /dev/sdb

 

This could cause a problem if later someone attempts to create a new numbered physical volume on this disk, ie :

 

pvcreate /dev/sdb1

 

If this is done on a disk where as above pvcreate has already been used to create a volume of the whole disk and where this has already been assigned to the Turbo logical volume group any existing Turbo logical volumes on this disk will be inaccessible and not visible under ‘df’.  When restarted the instance will boot into emergency mode. This is because in creating volume /dev/sdb1 we have re-allocated all of the space on the disk to a new physical volume whereas the Turbo logical volumes are still on physical volume /dev/sdb

 

To avoid this possibility it may be best to not use the whole disk to create a physical volume but to partition any new virtual disk as soon as it is created ie fdisk /dev/sdb to create a partition and then  pvcreate /dev/sdb1 instead of pvcreate /dev/sdb. To do this follow the procedure in the following GC to create numbered physical volumes on the disk and use these to extend the Turbo logical volume in need : https://greencircle.vmturbo.com/community/products/blog/2017/07/25/how-to-extendresize-hard-drive-in-operations-manager-running-centosHow to Extend/Resize Hard Drive in Operations Manager running CentOS

....................................

 

Continuation of steps to extend Turbo logical volume  with all of new disk: 

 

By default, Turbonomic ships with three separate partitions. 

 

Step 1: Add a new Disk from within your Hypervisor.

 

Step 2: SSH into Turbonomic using Putty or any other SSH client.

 

df -h.png

Step 3: In this step, we need to list all the detected partitions so we can then create a primary volume.

 

Command:

fdisk -l

fdisk -l.png

  In the above screenshot, you'll see the highlighted partition detected. On your system, if you have multiple disks added without a physical volume then you will see different names. 

 

The screenshot below is an example of the VM with two disks added without a physical volume.

 

fdisk -l 2.png

Once the new disk is visible run the below commands to create the new physical volume and add it to the volume group as shown below.

 

Step 4: Creating Physical Volume

 

Commands:

 

Don't forget to use the name of the partition you would like to use. In this example, sdb is in use.

pvcreate /dev/sdb

pvcreate.png

 

vgextend turbo /dev/sdb

vgextend.png

 

vgdisplay

vgdisplay.png

Step 5: Extending  Logical Volume

 

Partitions

  • turbo-root
  • turbo-var_lib_mysql
  • turbo-var_log

 

Command:

lvextend -L +10G /dev/mapper/turbo-root

lvextend.png

The disk added was 10GB but if you add more than 10GB then you need to change the command to include the space you would like to allocate to the Root partition.

Command:

xfs_growfs /dev/mapper/turbo-root

 

The command above will extend the root volume.

 

xfs_growfs.png

Command

df -h

 

Now we have extended the root volume We can look at the new size by using the command above, df -h

 

df-h.png

 

Useful Commands

 

Command
Summary
df -hShows disk space available for each volume
fdisk -lfdisk command can display the partitions and details like file system type
6 people found this helpful

Attachments

    Outcomes