1

I am resizing an installed KVM domain

# resize the partitions
virt-resize --expand /dev/vda2 --LV-expand /dev/vg_main/lv_root $VMFILE $VMFILE.tmp

and virt-resize throws an error:

virt-resize: error: You cannot use --expand when there is no surplus space to expand into.  You need to make the target disk larger by at least 224.0K.

What does this mean and how can I avoid it?

I am using resizevm.sh script from CentOS KVM Image Tools and the script produces a dead disk image (domain doesn't boot up).

I am using the latest CentOS 6.5

3

1 Answer 1

0

Assuming you're using a modern enough version of KVM (CentOS 6+) you'll need to expand the image file prior to running the virt-resize command. Typically it's a 2 step process:

$ sudo truncate -s +2G $VMFILE

Followed by your resize command:

$ sudo virt-resize --expand /dev/vda2 --LV-expand /dev/vg_main/lv_root \
    $VMFILE $VMFILE.tmp

This will have the effect of expanding the .img file by 2GB. Change the argument to truncate to whatever size you'd like to expand the .img file by.

References

2
  • 1. So, to expand a file, we should use a command which is named to the opposite of what it does, i.e. truncate? 2. I wonder how it worked previously, without the truncate command. Thanks, will try it! Apr 26, 2014 at 22:16
  • @NickolaiLeschov - yes that step was very counter-intuitive to us as well. I believe the tool needed to be called either reduce or expand and they opted to call it by the shrinking function. You can also do what you want via virt-manager (the GUI).
    – slm
    Apr 26, 2014 at 22:55

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.