Increase the size of the root partition in CentOS 7, RHEL 7 on ESXi 5.5

The root filesystem is almost at full capacity. The filesystem must be increased. 
This is a VM running on ESXi 5.5.

[root@ovicentos ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  6.7G  6.2G  532M  93% /

In the VM's settings increase the provisioned size of the root disk. 




In this example I increased the disk from 8 to 20GB.

[root@ovicentos ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               7.51 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              1922
  Free PE               8
  Allocated PE          1914
  PV UUID               hGmOJA-KykA-ar7M-GORn-3gDE-Nvxf-u96ImL

Rescan the SCSI BUS.

[root@ovicentos ~]# echo 1 > /sys/class/scsi_device/2\:0\:0\:0/device/rescan
[root@ovicentos ~]# fdisk -l /dev/sda

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000e3479

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    16777215     7875584   8e  Linux LVM

Use fdisk to create a new partition 

fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help):
Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p):
Using default response p
Partition number (3,4, default 3):
First sector (16777216-41943039, default 16777216):
Using default value 16777216
Last sector, +sectors or +size{K,M,G} (16777216-41943039, default 41943039):
Using default value 41943039
Partition 3 of type Linux and of size 12 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@ovicentos ~]# partprobe
[root@ovicentos ~]#

Create a new PV

[root@ovicentos ~]# pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created

Add the new PV to the root VG

[root@ovicentos ~]# vgextend centos /dev/sda3
  Volume group "centos" successfully extended
[root@ovicentos ~]# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  centos   2   3   0 wz--n- 19.50g 12.03g

Increase the LV size :

[root@ovicentos ~]# lvextend -L+12G /dev/centos/root
  Size of logical volume centos/root changed from 6.67 GiB (1707 extents) to 18.67 GiB (4779 extents).
  Logical volume root successfully resized
[root@ovicentos ~]# lvs
  LV              VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  docker-poolmeta centos -wi-a-----   8.00m
  root            centos -wi-ao----  18.67g
  swap            centos -wi-ao---- 820.00m
[root@ovicentos ~]#

At this point the filesystem must be actually extended using xfs_growfs. Using '-d' will utilize the maximum available space.

[root@ovicentos ~]# xfs_growfs -d /
meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=436992 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=1747968, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 1747968 to 4893696
[root@ovicentos ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   19G  6.2G   13G  33% /
devtmpfs                 901M     0  901M   0% /dev
tmpfs                    921M   68K  921M   1% /dev/shm
tmpfs                    921M   33M  888M   4% /run
tmpfs                    921M     0  921M   0% /sys/fs/cgroup
/dev/sda1                497M  120M  378M  25% /boot
/dev/md127                32G   49M   30G   1% /media
[root@ovicentos ~]#

Another can be adding a new virtual disk to this VM and creating the new PV on that Virtual Disk instead of creating a new partition.