[CentOS] how to resize a partition of a disk define as a physical volume

Wed Feb 22 13:52:43 UTC 2017
Gianluca Cecchi <gianluca.cecchi at gmail.com>

On Wed, Feb 22, 2017 at 2:42 PM, Bernard Fay <bernard.fay at gmail.com> wrote:

> How do you resize the partition without loosing data?
>
> gparted does not support LVM.
>
>
It is preferrable to create PV on the whole disk also to manage these kind
of situations.
In case I have to manage with partitions, the must is that you can do it
only if it is the last partition, and you are ok.
Normally I use fidsk and I first delete the last partition and then without
exiting the utility I create again it using the same starting point and the
new larger end.
For this, take care of using option to show sectors and not cylinders ("u"
switches between the two options) and print your partition layout ("p"
comamnd), so that you can set exactly the same starting point of the new
xvda2 partition otherwise you will have destroyed it and LVM layer would
not be able to identify it (also the type if now it is 8e for Linux LVM).
Eventually you will have to run also the command

partprobe /dev/xvda

to align os with new partition layout

Take care and read well (also on other sources on internet in case). Also
backup your partiion layout before making changes with

sfdisk -d /dev/xvda > part_table.before

and compare with what you have after.

HIH,
Gianluca