4

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

1
  • 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. Dec 23, 2016 at 11:00

2 Answers 2

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

5
  • 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, 2016 at 11:04
  • Thanks - I've edited the question as I think it's nearly there but still not quite right! Dec 23, 2016 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, 2016 at 14:21
  • I may have found a similar issue here : serverfault.com/questions/520103/…
    – Dark Sinus
    Dec 23, 2016 at 14:26
  • Finally solved it - man what a pain in the backside! Thanks for your help. Dec 23, 2016 at 18:32
0

I had almost the same issue (but no LVM). Ubuntu on a VM in VirtualBox. Had to make the disk larger, which I first did in VirtualBox. Then needed to expand the partition and filesystem in Ubuntu.

Here is the disk after expanding the partition.

    Device            Boot               Start            End        Sectors        Size      Id Type
    /dev/sda1         *                   2048        1050623        1048576        512M       b W95 FAT32      
>>  /dev/sda2                          1052670      419430399      418377730      199,5G       5 Extended
    └─/dev/sda5                        1052672      419428351      418375680      199,5G      83 Linux

The solution

I had the luxury that I could use a GUI. I installed gparted. It took literally 30 seconds of work to expand the extended partition and then the logical partition inside it. That was the first time I used gparted and with no need for documentation. Great.

Before that I tried to do the same in cfdisk but sadly it could not do it and threw an error. I welcome suggestions for a command line tool that can do it and is self explanatory to use, just like the GUI. Cheers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .