Monday, August 21, 2017

How to resize your linux partition when you have this problem (see image)?

Long time since my last blog update, so here goes :D

IMPORTANT NOTE: before doing step 1-3, you need to insert a Ubuntu live-cd and boot from it. And then, open gparted in the live-cd and continue with step 1-3.

The problem was that the partitions were somehow locked. So:
  1. I right Clicked both sd2 and sd5 and chose "Deactivate".
  2. I resized the extended (sda2) partition.
  3. I resized the lvm (sda5) partition.
The problem was fixed
I should add that in the VM the new space was not available, so I had to run those 2 commands: expand LVM to all remaining free space:
lvextend –l +100%FREE [MOUNTPOINT]
expand filesystem:
sudo resize2fs [MOUNTPOINT]
 
::NOTES::
1. To display Mountpoint run the command lvdisplay to display where is 
the root directory. For example, /dev/nameoftheserver/root
 
2. After that, run lvextend -1 +100%FREE /dev/nameoftheserver/root

3. Run sudo resize2fs /dev/nameoftheserver/root.
 
Credit to papnikol and linuxdev2013 for their solution in 
https://superuser.com/questions/917988/
gparted-cannot-resize-extended-or-lvm-partition