To enlarge a Linux partition here is the procedure to follow
Prerequisites: Having achieved an increase in VM disk size
- Login as SSH as root (if you are logged in with the coadmin account run the command sudo su - )
- Issue the following command: echo 1 > /sys/block/sda/device/rescan
- Issue the following command: cfdisk
- Go to " Free Space " then choose in the menu News partition / Logic Example: /dev/sda4 => WRITE
- Note the name of the new partition: ex /dev/sda4
- Issue the following command: partprobe
- Issue the following command: pvcreate /dev/sdaX Example: pvcreate /dev/sda4 (if that doesn't work restart the box)
- Retrieve the name of the logical volume to be increased : lvdisplay
- Enter the command : vgextend GRPE_VOLUME_NAME /dev/sdaX
- For example: vgextend template-ubuntu-snb-16-04-vg /dev/sda4
- Retrieve the path of the LV PATH logical volume and resize it.
- lvresize -l +100%FREE LV PATH (to set 100%)
- For 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 3 partitions. Beyond that it is not possible to add space.