expansion failed : Only the last partition on a disk image can be resized

Hi,

I made a KVM Centos image but when I want to use it to install other VMs I get this error:
"expansion failed : Only the last partition on a disk image can be resized"

But I created the image specifically with swap the first partition and an ext3 one last (because I encountered this error previously).
Here's how my partition table looks like (i temporarily mounted the image on a loop dev so I can view partition table):

" Device Boot Start End Blocks Id System
/dev/loop1p1 1 250 2008093+ 82 Linux swap / Solaris
/dev/loop1p2 * 251 522 2184840 83 Linux
"

Any suggestions?

Status: 
Closed (fixed)

Comments

What does the /etc/fstab file within the VM contain?

===
LABEL=/ / ext3 defaults 1 1
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/vda1 swap swap defaults 0 0
===

Hmm, that LABEL will be causing problems. I will replace it with /dev/vda2.
Should the swap space be defined first in the fstab file?

I'd advise replacing the LABEL= with /dev/vda2. Cloudmin cannot figure out which partition that maps to when a VM is down, which is why all our standard images avoid using it..

The order of the /etc/fstab file doesn't matter though.

Jamie,

Yeah, I figured that out as well and replaced the LABEL.. Cloudmin still won't enlarge the partition though.

So you are getting this error when creating a new VM from an image?

What if you try to expand the disk on the original VM - does the same problem happen?

Ok, I just tried your new Centos image with virtio support and I can expand it. I don't understand!
Here's how a vm created with my Centos image looks like:

[root@hj45 ~]# fdisk -l

Disk /dev/vda: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/vda1 1 250 2008093+ 82 Linux swap / Solaris
/dev/vda2 * 251 522 2184840 83 Linux

It will not go beyond 4294 MB even though I told Cloudmin to create a 10 GB lvm. 4294 MB is the size of my template image.

This is how a vm created with your centos image looks like:
[root@mgd ~]# fdisk -l

Disk /dev/vda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/vda1 * 1 13 104391 83 Linux
/dev/vda2 14 1306 10381337+ 83 Linux

The size is normal, just like I instructed Cloudmin, 10 GB. Your image was successfully enlarged..
The difference that I can see is I have a swap partition as vda1 and you use that for /boot.
However your image does not have a swap which is a problem imho.

Ideas?

I stopped the machine installed from my template (that has a swap partition as vda1), I lvextended it's virtual disk, enlarged partition and filesystem by hand, nothing fancy, pretty standard procedure and it worked. Any ideas why Cloudmin complains?

Let me know if I dont make much sense :)

This is clearly a Cloudmin bug, as the last partition should be extendable in the way you describe.

If you run the command vm2 list-disks --host your-kvm-vm --multiline on your Cloudmin master system, what does it output? That will show me what disks and partitions Cloudmin thinks your system has ..

By the way, make sure you run that command when the VM is shut down ..

[root@localhost ~]# vm2 list-disks --host hj45.cloudmin.co.uk
Real file Device on system Type Size
------------------------------ -------------------- ---------- ----------
/dev/vg0/hj45_cloudmin_localdo /dev/vda Device 14 GB

(ignore the cloudmin.co.uk, it's a bogus i set as virtualmin was refusing to install inside the vm without proper hostname).

Btw, fdisk -l shows this:
fdisk -l /dev/vg0/hj45_cloudmin_localdomain_img

Disk /dev/vg0/hj45_cloudmin_localdomain_img: 15.0 GB, 15032385536 bytes
255 heads, 63 sectors/track, 1827 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/vg0/hj45_cloudmin_localdomain_img1 1 250 2008093+ 82 Linux swap / Solaris
/dev/vg0/hj45_cloudmin_localdomain_img2 251 1827 12667252+ 83 Linux

Sorry, the command should have been :

vm2 list-disks --host hj45.cloudmin.co.uk --multiline

[root@localhost ~]# vm2 list-disks --host hj45.cloudmin.co.uk --multiline
/dev/vg0/hj45_cloudmin_localdomain_img
Description: LVM VG vg0, LV hj45_cloudmin_localdomain_img
Device on system: /dev/vda
Description on system: VirtIO device A
Format: disk
Type: Device
LVM volume group: vg0
LVM logical volume: hj45_cloudmin_localdomain_img
Storage name: LVM volume group vg0
Storage ID: lvm_vg0
Media: disk
Size: 15032385536
Nice size: 14 GB
Mount point: swap
Mount device: /dev/vda1
Filesystem: swap
Mounted: No

Ok, I was wrong - due to a Cloudmin bug, the order of /etc/fstab does matter. If you put the swap mount at the end, you won't have this problem!

I will fix the underlying bug in the 5.4 release.

Hi,

Great! I tested and I can confirm it works if I specify swap last in fstab. Another bug squished! :)

Automatically closed -- issue fixed for 2 weeks with no activity.