I'm running ubuntu (Ubuntu 16.04.1 LTS) under hyper-v and I've extended the hard drive (in hyper-v), but I now need to update ubuntu to use this space.
My current partitions looks as follows:
A lot of the guides I've seen recommend deleting the second partition using fdisk and recreating it, but this appears to delete the sda5 partition and I'm thinking this is probably a very bad idea!
Before:
After:
I'm at a bit of a loss as most searches suggest using a GUI tool which I don't have the luxury of!
I promise I have searched and searched
[EDIT]
After following the great answer below and using parted I now have FDisk showing
However I still don't have the space available
sudo pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 dar-docker-01-vg lvm2 a– 126.52g 52.00m
I'm guessing I need to do something again. I've tried using resize2fs but it's likely I'm not using it correctly!
[EDIT 2]
I needed to use
'pvresize /dev/sda5'
then use 'lvdisplay' to get the LV path
Then use 'lvextend -L+150G /dev/dar-docker-01-vg/root'
Finally 'resize2fs -p /dev/dar-docker-01-vg/root'
And after all that df -h shows the full space as available! YAY
Best Answer
I think the easiest way for you is to :
/dev/sda2
so that it takes all the space left after it ( end of partition at the end of the disk)./dev/sda5
inside/dev/sda2
so that it ends at the end of/dev/sda2
To resize a partition without a GUI, I recommend you
parted
:Go on a tty, launch
parted
. You'll get a parted prompt, useprint
to display the current state of your disk.Then to resize a partition: use
resizepart
You'll be ask the number of the partition you want to resize ( to resize/dev/sda2
enter 2 ,and then the end of the partition ( its new size ). For you the new size should be 'space on/dev/sda2
+ free space size' .You can find how to resize a partition using parted :here