Note: You should run almost all of the following commands using a Live CD. Sometimes, it wants you to unmount the partition that already mounted on / (in this case, you cannot unmount it).
These are all the steps required to resize a LVM or LVM2 partition:
sudo lvresize --verbose --resizefs -L -150G /dev/mapper/ubuntu
sudo pvresize --setphysicalvolumesize {some-space} /dev/sda5
If the second command produces something like this:
/dev/sda5: cannot resize to xxxxx extents as later ones are allocated.
Then, you have to rearrange the unallocated space at the end of the LVM. That means after root and swap_1 partition. So, initially, you need to check physical volumes' information using the command below:
sudo pvs -v --segments /dev/sda5
This will show the output like:
/dev/sda5 ubuntu lvm2 a-- 698.04g 150g 0 xxx root 0 linear /dev/sda:0-rrr
/dev/sda5 ubuntu lvm2 a-- 698.04g 150g xxx sss 0 free
/dev/sda5 ubuntu lvm2 a-- 698.04g 150g zzz ttt swap 0 linear /dev/sda5:yyy-www
Note the yyy-www. Use the following command to remove external fragmentation:
sudo pvmove --alloc anywhere /dev/sda5:yyy-www
Now, let us see how it goes:
sudo pvs -v --segments /dev/sda5
This will show the output like (note the changes):
/dev/sda5 ubuntu lvm2 a-- 698.04g 150g 0 xxx root 0 linear /dev/sda:0-rrr
/dev/sda5 ubuntu lvm2 a-- 698.04g 150g xxx ttt swap 0 linear /dev/sda5:xxx-sss
/dev/sda5 ubuntu lvm2 a-- 698.04g 150g yyy www 0 free
After that, use the GParted and resize the LVM to maximum used area and rest will be in unallocated space. Enjoy...