2

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:

Current Partitions

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:

Before

After:

After Deletion

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

enter image description here

However I still don't have the space available enter image description here

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!

enter image description here

[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

  • Is it due to no Xorg? If so, at least Gparted from a Ubuntu live dvd can do the trick, as you have a monitor. – Arijit Chatterjee Dec 23 '16 at 11:00
3

I think the easiest way for you is to :

  1. Resize the extended partition /dev/sda2 so that it takes all the space left after it ( end of partition at the end of the disk).
  2. Resize the partition /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, use print 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

| improve this answer | |
  • And of course deleting the /dev/sda2 partition will delete /dev/sda5 . The second partition is an extended one which means it can contain other partition, among it /dev/sda5 . – Dark Sinus Dec 23 '16 at 11:04
  • Thanks - I've edited the question as I think it's nearly there but still not quite right! – Ross Dargan Dec 23 '16 at 12:11
  • I think you are using resize2fs correctly. I suspect that your problem comes from hyper-v, I don't know much about it, I'm not sure that I can help you further... Please let me know if you find how to fix that I am curious about it – Dark Sinus Dec 23 '16 at 14:21
  • I may have found a similar issue here : serverfault.com/questions/520103/… – Dark Sinus Dec 23 '16 at 14:26
  • Finally solved it - man what a pain in the backside! Thanks for your help. – Ross Dargan Dec 23 '16 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.