2

I run a bare metal Ubuntu server with several VMs running in a KVM environment. I want to increase the size of one VM from 50GB to 100GB.

nextcloudph-lv

I ran the following command to increase the nextcloudph-lv VM from 50GB to 100GB:

sudo lvextend -L+50G /dev/ubuntu-vg/nextcloudph-lv

The VM size increased as expected.

nextcloudph after increase

I then attempted to extend the LV file system using the following command:

sudo resize2fs /dev/ubuntu-vg/nextcloudph-lv

The output I received is:

Bad magic number error message

Running the lsblk command results in:

lsblk

And /dev/mapper contains:

dev mapper list

This looks like a relatively simple process so I'm not sure where I've gone wrong. This is the first time I'm trying to extend an LV and I'm stuck...

Thanks in advance!

EDIT:

As suggested by A. Darwin, I ran the command "df -hT" which produced the following output:

df -hT

I can see the host VM "ubuntu--lv" with an ext4 file system but there is no reference to "nextcloudph--lv" or sda3 where all the VMs are located.

I'm not sure if it makes a difference but when I set up the VMs I first allocated the space using the "lvcreate -L ##G -n lv###### ubuntu-vg" command and then pointed Virtual Machine Manager to that storage pool when building the VM.

EDIT 2 Running "df hT" from within the nextcloudph-lv VM produces the following output:

nextcloudph df -hT

It's strange because there is a reference to a 48GB ext4 drive but it's located at "/dev/mapper/ubuntu--vg-ubuntu--lv".

EDIT 3

As requested by Vojtech Trefny, attached is the output from the command "lsblk -f"

lsblk -f

For clarity, the 84% used refers only to the ubuntu--lv VM. There is still plenty of room left on the SSDs.

6
  • 2
    What kind of filesystem is that? Run df -hT or similar. If it’s xfs, you may need to run xfs_growfs (followed by the mount point) rather than resize2fs.
    – A. Darwin
    Jul 28 at 18:52
  • Thanks for your response. I ran the command "df -hT" and have posted the output above and included additional information on how I built the VMs using Virtual Machine Manager.
    – kvmhali
    Jul 28 at 19:34
  • df shows only mounted devices, please use lsblk -f Jul 28 at 19:50
  • Hi Vojtech Trefny , I've added the output from running the command "lsblk -f". Thanks for your help with this!
    – kvmhali
    Jul 28 at 20:00
  • 1
0

The LV doesn't seem to contain a file system directly, but probably is a whole disk image to the VM. In that case, you need to change the partition size and resize the file system from within the VM; alternatively, you can stop the VM, and treat the LV as whole disk using a partitioning tool, resize the data partition, then set up a loop device with an offset pointing to the enlarged partition and resize the file system within that.

0

Run the command sudo lvextend -L+50G /dev/ubuntu-vg/nextcloudph-lv again, but rather than trying to resize after extending, resize within the lvextend command with -r so it will look like sudo lvextend -L+51G -r /dev/ubuntu-vg/nextcloudph-lv. (Maybe add an extra 1G so it attempts a new extend)

If you get the same error as above in your OP, then make sure the logical volume has a valid filesystem, if not, make it one e.g mkfs.ext4 /dev/ubuntu-vg/nextcloudph-lv and then try and resize again.

3
  • Well, your suggestions made sense so I gave them a try. The first time I ran the lvextend command with the -r it gave an error complaining about the file system so I tried to add the ext4 fiel system but ultimately the entire VM crashed. When I turn it on now I get the following fatal error: "Boot failed: not a bootable disk". I'll rebuild the VM from scratch again and rebuild the entire server in the coming weeks so this doesn't happen again.
    – kvmhali
    Jul 28 at 21:38
  • Do you still see the VM with virsh list --all? If you can see the VM, then the XML configs are probably there too so you can redefine it. What is the output of lvs and lvscan? Most importantly, you have your back ups. Right?
    – HatLess
    Jul 28 at 21:48
  • I have a backup so no worries. I've already deleted the VM and am starting on a temporary rebuild. I think the main issue I'm having is the way the entire server was configured so I plan to rebuild it again from scratch over an upcoming weekend so I don't run into these issues in the future. Thanks again!
    – kvmhali
    Jul 28 at 22:21

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.