Expanding Disk Partition on Cloudpath 6.x with VMWare

Before making any modifications, it is standard practice to create a snapshot of the Cloudpath virtual machine (VM). However, be aware that certain versions of VMware do not permit virtual disk expansion while a snapshot exists. To proceed with resizing the disk, you may need to delete all existing snapshots associated with the Cloudpath VM. If you have the capability to clone or create a duplicate of the Cloudpath VM, it is strongly recommended to do so. This ensures you have a backup instance available for recovery.
Complete the following to change the memory configuration of the hardware hosting the virtual machine.
  1. Power down the Cloudpath virtual machine in VMWare.
    Note: Certain versions of the VMs do not allow memory configurations while the VM is powered on.
  2. Edit the VM settings as shown in the images below, then save the changes.

    Default Virtual Hardware

    Expanded Virtual Hardware

    Note that the disk partitions inside the operating system remain the same. Therefore, you must expand the MySQL partition on this server using the following steps.

    The following displays the default partition size (58 G):

    [root@jack155 ~]# df -h
    Filesystem                 Size  Used Avail Use% Mounted on
    devtmpfs                   4.0M     0  4.0M   0% /dev
    tmpfs                      3.8G     0  3.8G   0% /dev/shm
    tmpfs                      1.6G   17M  1.5G   2% /run
    /dev/mapper/vg_root-root    20G  1.4G   18G   8% /
    /dev/sda1                  974M  202M  705M  23% /boot
    /dev/mapper/vg_root-log     10G  399M  9.6G   4% /var/log
    /dev/mapper/vg_root-tmp    436M   29M  408M   7% /tmp
    /dev/mapper/vg_root-opt     10G  1.9G  8.1G  19% /opt
    /dev/mapper/vg_root-mysql   58G  842M   57G   2% /var/lib/mysql
    tmpfs                      769M     0  769M   0% /run/user/1001
    

  3. Power on the Cloudpath VM.
  4. After the VM has successfully booted, connect to the VM using either SSH or the console interface, depending on your environment and access preferences.
  5. Use the sudo command to attain root privileges.
  6. Use the fdisk -l command to view details of the disk.
    [root@jack155 ~]# fdisk -l
    Disk /dev/sda: 120.06 GiB, 128911932416 bytes, 251781118 sectors
    Disk model: Virtual disk
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x4af27b89
    
    Device     Boot   Start       End   Sectors  Size Id Type
    /dev/sda1  *       2048   2099199   2097152    1G 83 Linux
    /dev/sda2       2099200   4196351   2097152    1G 82 Linux swap / Solaris
    /dev/sda3       4196352 209836031 205639680 98.1G 8e Linux LVM
    
    Disk /dev/mapper/vg_root-root: 20 GiB, 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 /dev/mapper/vg_root-mysql: 57.57 GiB, 61811458048 bytes, 120725504 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 /dev/mapper/vg_root-log: 10 GiB, 10737418240 bytes, 20971520 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 /dev/mapper/vg_root-opt: 10 GiB, 10737418240 bytes, 20971520 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 /dev/mapper/vg_root-tmp: 500 MiB, 524288000 bytes, 1024000 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
    

    Notice that the screen displays the following:

    Disk /dev/sda: 120.06 GiB, 128911932416 bytes, 251781118 sectors

    The operating system identifies the physical disk as /dev/sda. Within Cloudpath, all logical volumes are organized into a single volume group located on the /dev/sda3 partition. The remaining two partitions serve specific system functions: one is designated as the boot partition, and the other is used for swap space.

  7. Use the fdisk /dev/sda command to modify the physical disk partition table.
    [root@jack155 ~]# fdisk /dev/sda
    
    Welcome to fdisk (util-linux 2.37.4).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    This disk is currently in use - repartitioning is probably a bad idea.
    It's recommended to umount all file systems, and swapoff all swap
    partitions on this disk.
    
    Note: Ignore the warning message that is displayed in the command line interface.
  8. Enter n for new partition.
    Command (m for help): n
    Partition type
       p   primary (3 primary, 0 extended, 1 free)
       e   extended (container for logical partitions)
    Select (default e):
    
  9. Complete the following steps.
    1. Start partition creation by entering p.
      Select (default e): p
    2. Confirm the partition number.
      Selected partition 4
    3. Press Enter to set the starting sector.
      First sector (209836032-251781117, default 209836032):
    4. Press Enter to set the ending sector.
      Last sector, +/-sectors or +/-size{K,M,G,T,P} (209836032-251781117, default 251781117):

      The system confirms creation of partition 4

      Created a new partition 4 of type 'Linux' and of size 20 GiB.
    5. Enter t to change the partition type.
      Command (m for help): t
    6. Enter 4 to select the newly created partition.
      Partition number (1-4, default 4): 4

      In this case, 4 is set because sda1, sda2, and sda3 are already used.

    7. Enter 8e to assign the Linux Logical Volume Manager (LVM) type. Note that 8e is the hex code or alias for Linux LVM.
      Hex code or alias (type L to list all): 8e
      The system confirms the type change:
      Changed type of partition 'Linux' to 'Linux LVM'
    8. Enter w to save and apply the changes.
      Command (m for help): w
      The partition table has been altered.
      Syncing disks.
  10. Use the pvcreate command to create the new physical volume, /dev/sda4.
    [root@jackl55 ~]* pvcreate /dev/sda4
    Physical volume "/dev/sda4" successfully created.
  11. Use the vgdisplay command to display the volume groups.
    [root@jack155 ~]# vgdisplay
      --- Volume group ---
      VG Name               vg_root
      System ID
      Format                lvm2
      Metadata Areas        1
      Metadata Sequence No  6
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                5
      Open LV               5
      Max PV                0
      Cur PV                1
      Act PV                1
      VG Size               98.05 GiB
      PE Size               4.00 MiB
      Total PE              25102
      Alloc PE / Size       25102 / 98.05 GiB
      Free  PE / Size       0 / 0
      VG UUID               M0gU39-knic-RWra-3NUD-VreH-Xxd2-5UXYMI
    

    Note: You may still see that the free physical extents (PE) attribute, Free PE / Size, is shown as 0 / 0.

  12. Use the vgextend vg_root /dev/sda4 command to extend the volume group and then use the vgdisplay command to view the free PE size.
    [root@jack155 ~]# vgextend vg_root /dev/sda4
      Volume group "vg_root" successfully extended
    
    [root@jack155 ~]# vgdisplay
      --- Volume group ---
      VG Name               vg_root
      System ID
      Format                lvm2
      Metadata Areas        2
      Metadata Sequence No  7
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                5
      Open LV               5
      Max PV                0
      Cur PV                2
      Act PV                2
      VG Size               118.05 GiB
      PE Size               4.00 MiB
      Total PE              30221
      Alloc PE / Size       25102 / 98.05 GiB
      Free  PE / Size       5119 / <20.00 GiB
      VG UUID               M0gU39-knic-RWra-3NUD-VreH-Xxd2-5UXYMI
    
  13. Use the pvscan command to scan physical volumes and to view the new partition /dev/sda4.
    [root@jack155 ~]# pvscan
      PV /dev/sda3   VG vg_root   lvm2 [98.05 GiB / 0    free]
      PV /dev/sda4   VG vg_root   lvm2 [<20.00 GiB / <20.00 GiB free]
      Total: 2 [118.05 GiB] / in use: 2 [118.05 GiB] / in no VG: 0 [0   ]
    
  14. Use the lvextend command to extend the logical volume for /dev/mapper/vg_root-mysql.
    [root@jack155 ~]# lvextend -L+19.9G /dev/mapper/vg_root-mysql
      Rounding size to boundary between physical extents: 19.90 GiB.
      Size of logical volume vg_root/mysql changed from <57.57 GiB (14737 extents) to <77.47 GiB (19832 extents).
      Logical volume vg_root/mysql successfully resized.
    
    Note: To avoid possible binary math issues, only extend the volume by 19.9 GiB as entering 20 GiB may return an error because it is a few sectors short.
  15. Use the xfs_growfs /dev/mapper/vg_root-mysql command to expand the file system to use the new space.
    [root@jack155 ~]# xfs_growfs /dev/mapper/vg_root-mysql
    meta-data=/dev/mapper/vg_root-mysql isize=512    agcount=4, agsize=3772672 blks
             =                       sectsz=512   attr=2, projid32bit=1
             =                       crc=1        finobt=1, sparse=1, rmapbt=0
             =                       reflink=1    bigtime=1 inobtcount=1 nrext64=0
    data     =                       bsize=4096   blocks=15090688, imaxpct=25
             =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
    log      =internal log           bsize=4096   blocks=16384, version=2
             =                       sectsz=512   sunit=0 blks, lazy-count=1
    realtime =none                   extsz=4096   blocks=0, rtextents=0
    data blocks changed from 15090688 to 20307968
    
  16. Use the df -h command to display the MySQL partition.
    [root@jack155 ~]# df -h
    Filesystem                 Size  Used Avail Use% Mounted on
    devtmpfs                   4.0M     0  4.0M   0% /dev
    tmpfs                      3.8G     0  3.8G   0% /dev/shm
    tmpfs                      1.6G   17M  1.5G   2% /run
    /dev/mapper/vg_root-root    20G  1.4G   18G   8% /
    /dev/sda1                  974M  202M  705M  23% /boot
    /dev/mapper/vg_root-tmp    436M   29M  408M   7% /tmp
    /dev/mapper/vg_root-opt     10G  951M  9.1G  10% /opt
    /dev/mapper/vg_root-mysql   78G  961M   77G   2% /var/lib/mysql
    /dev/mapper/vg_root-log     10G  116M  9.9G   2% /var/log
    tmpfs                      769M     0  769M   0% /run/user/1001
    tmpfs                      769M     0  769M   0% /run/user/0