0

I'm trying to expand my root (/) partition in Ubuntu, but GParted will not let me change this. I've read several things about using the swap partition to accomplish this, but maybe I'm not doing this in the right order.

I'm booting from a live CD. I need to add my unallocated space to sda5. Can someone tell me the order in which I need to proceed? Thanks.

screen shot of g-parted

wjandrea
  • 14,236
  • 4
  • 48
  • 98
  • @user68186 That question is from before GParted supported LVM physical volumes, so there are probably simpler solutions these days. – wjandrea Nov 01 '18 at 22:50
  • 1
    What have you tried already, and what was the outcome? You can [edit] the question to add details. – wjandrea Nov 01 '18 at 22:52

1 Answers1

0

I see 2 possible solutions, but in either case you'll first need to move your swap partition to the end of the unallocated space. Click on the swap partition and slide it all the way to the right. Click "apply".

Go have lunch/dinner/a couple of beers, it's going to take a while.

Then you'll need to expand sda2 (the extended partition) to include all of the unallocated space. Click on sda2, then click Resize/Move. Make it as big as you can, try getting the numbers for before and after as small as you can (you'll probably have at least 1MiB both before and after).

Since sda5 is lvm2, the cleanest way (least likely to break something) is to create a new partition (sda6) using all of the unallocated space and create another PV using sda6 and add it to your VG. Then you can resize any/all of your logical volumes in that VG using lvresize(8). Make sure you use the -r option to grow the filesystem as well.

The other option is to try and resize sda5. Gparted may well refuse, since it usually can't see inside a LVM PV and usually won't do something that will probably destroy data.

I've never tried to grow a PV this way, so I can't say for sure. I know that the first option will work.

If it does work, you'll likely still have to do a pvresize(8), followed by an lvresize(8).

ron

  • Does moving a swap partition really take long? Maybe it would be faster to just delete it and create a new one. – wjandrea Nov 02 '18 at 00:16
  • I got it fixed. I ended up having to create a new partition in G-parted using my unallocated space, and then went back to the command line to create the pv, and extend the lvm using the instructions I found here. https://www.tecmint.com/extend-and-reduce-lvms-in-linux/ – patrickwilson82 Nov 02 '18 at 15:33
  • 1
    @patrickwilson82 you can add your solution as an answer with more detail to help future visitors :) – Zanna Nov 02 '18 at 18:44
  • In my experience, moving any partition on a larger drive takes quite a long time. In this case, the swap partition is a primary partition (sda3) while any new partitions must necessarily be logical partitions in the extended partition (sda4) – r_widell Nov 03 '18 at 14:37
  • @wjandrea to finish answering your query-- you can delete the swap partition, then recreate it after expanding the extended partition. Just make sure that after recreating that partition that you do a mkswap(8) with the appropriate option (-U/-L) so the system will find and use it. – r_widell Nov 04 '18 at 13:48