How do I expand /dev/sda3 and volume group from the command line?

We're running Ubuntu 16.04.6 LTS as a VM under Hyper-V - no UI, so gparted isn't really an option.

We were running low on space on /dev/sda3 so I expanded the drive inside of Hyper-V, then ran:

sudo parted -l

It warned:

Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 20971520 blocks) or continue with the current setting? Fix/Ignore? Fix

After fixing, I see running fdisk -l that /dev/sda is now 100 GiB.

It's not really clear to me how to assign this extra space to /dev/sda3 - I tried just expanding the logical volume that is at 99% usage (the one that prompted me to try to expand the space available in the first place):

sudo lvextend /dev/srv-vg/root /dev/sda3

But I think that since the space isn't assigned to sda3 it can't expand it (as it didn't really expand it).

So then I tried parted:

$sudo parted /dev/sda
resize part 3
End? [85.9GB]? -0
(parted): quit
Information: You may need to update /etc/fstab

fdisk -l now shows sda3 has more space, but it still shows that 99% of the space is used.

Device Start End Sectors Size Type
/dev/sda1 2048 1050623 1048576 512M EFI System
/dev/sda2 1050624 2050047 999424 488M Linux filesystem
/dev/sda3 2050048 209715166 207665119 99G Linux LVM
Disk /dev/mapper/srv--vg-root: 77 GiB, 82703286272 bytes, 161529856 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

I tried lvextend again:

sudo lvextend /dev/srv-vg/root /dev/sda3

but it says this:

 No free extents on physical volume "/dev/sda3". No specified PVs have space available.

I rechecked vgdisplay:

--- Volume group ---
VG Name srv-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 79.02 GiB
PE Size 4.00 MiB
Total PE 20229
Alloc PE / Size 20217 / 78.97 GiB
Free PE / Size 12 / 48.00 MiB
VG UUID HvKrjH-VGRA-svAB-NOmW-f23C-7uwq-hdh5Ja

It feels like I'm almost there, but I'm not seeing what else I need to do to expand this.

What am I missing here?

1 Answer

Each time You are playing with disks You have to go through these stages:

  1. extend/modify storage device (VM disk in Your case)
  2. sometimes there is a need for OS/kernel partition table refresh (reboot is sure and easy step)
  3. extend/modify partition table of that partition
  4. again, refresh partition table (via blockev or partprobe command or reboot)
  5. now You cand extend your filesystem and youre done or continue...
  6. in case of LVM or so is now time to use PV, VG and finally LV resize commands

So You are probably looking for a missed step of:

pvresize/vgextend in the case You have successfully resized the correct partition

And if the partition is still not resized?

Use fdisk (, cfdisk, sfdisk, parted, -gparted-, ..) to resize this partition. It will be easy if it is the last one partiton on the disk (neverless the type GPT/MBR). I usually delete that one partition and re-create it as bigger.

Try pvdisplay, vgdisplay commands and look what shows $ cat /proc/partitionsIf You dont see Your free space here it probably still isnt assigned to the right partition.

PS: If You are not sure always do the BACKUP

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like