Linux – How to shrink Linux partition (sda2, type is Linux LVM)

linuxlvmpartitionshrink

I have sda disk with 2 partitions. The second partition sda2(which is LVM) is 1.4TB in size and want to shrink to 50GB. I reduced Logical volume to 50GB but when I run vgdisplay it shows Free PE / Size 1.33 TiB. I want this free space to have sda and not sda2 for to create sda3 partition which I want not to be formatted (Who is familiar with Oracle and asm , I will clarify that I want sda3 to mark as an asm disk)

So I want to take 1.33 TiB from sda2 and give it to sda, how? Please, help.

fdisk -l

pvdisplay

vgdisplay

lvdisplay

Best Answer

You must resize the LVM physical volume after you have reduced the partition on the filesystem with fdisk.

I have not the possibility to confirm the exact steps right now, so you should get someone to review the steps before you perform them.

1. Backup your data!

In case something goes wrong, make sure you have your data backed up.

2. Resize the filesystem

resize2fs -p /dev/VolGroup00/LogVol00 50GB

3. Resize the logical volume

lvresize -L50G /dev/VolGroup/LogVol00

4. Backup partition table

sfdisk -d /dev/sda > /var/tmp/partition-table.txt

5. Delete /dev/sda2 partition

Use fdisk to delete the partition /dev/sda2

6. Create a new /dev/sda2 partition

Create a new partion with the exact same starting offset as your former partition (this should be default) and make it only 50G

7. Resize the LVM Physical Volume

pvresize /dev/sda2