To enlarge a Linux partition here is the procedure
Prerequisites
Have achieved an increase in the size of the VM disk
Steps to follow
- Connect to SSH as root (if you are connected with the coadmin account run the command sudo su - )
- Run the following command: echo 1 > /sys/block/sda/device/rescan
- Run the following command: cfdisk
- Go to "Free Space" and choose from the menu New partition / Logic Example: /dev/sda4 => WRITE
- Note the name of the new partition: ex /dev/sda4
- Run the following command: partprobe
- Run the following command: pvcreate /dev/sdaX Example : pvcreate /dev/sda4 (if it doesn't work reboot the box)
- Retrieve the name of the logical volume to be expanded: lvdisplay
- Enter the command : vgextend GRPE_VOLUME_NAME /dev/sdaX
- Example: vgextend template-ubuntu-snb-16-04-vg /dev/sda4
- Get the path of the logical volume LV PATH and do a resize
- lvresize -l +100%FREE LV PATH (to put 100%)
- Example: lvresize -l +100%FREE /dev/template-ubuntu-snb-16-04-vg/root
- Retrieve the name of the partition to be resized with the command df -h
Enter the following command: resize2fs /dev/mapper/template-ubuntu-snb-16-04-vg-root
Check with the command : df -h
IMPORTANT If you need to create a primary partition, be careful not to exceed exceed 3 partitions. Beyond that it is not possible to add space.