Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I use the vmbuilder tool to create KVM virtual machines on my ubuntu host system. For each vm I set up a vmbuilder.partitions textfile in which the partition sizes for the vm are defined.

As simple as:

root 100000
swap 4000

Now I would create a new logical volume for the vm which has exactly the size of all defined partitions. (In the example, I would run lvcreate -L 104G ...)

The result is a LV of exactly 104 GiB in size. But my 100 G(i?)B root-partition fills just 93.13 GiB of it. And swap just about 3.72 GiB. There are about 7 GiB unallocated space in the LV.

This is very strange, because even if you calculate vmbuilder.partitions' numbers by 1024byte/megabyte, the root partition should still be 97.65 GiB and not about 93. And swap should be about 3.9 GiB instead of 3.72. (Unfortunately these numbers scale up, a 1TB-definition will only have about 930 GiB instead of 976.)

This CAN be fixed by manually removing a rule-of-thumb estimated amount of bytes from the LV. But I want to have sane values from the start on. And having 10% of space unallocated in every VM is clearly unnacceptable.

Does anyone know the logic behind this? Thanks a lot.

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

Well, until I find out the real answer I will stick to the following workaround using gparted's LiveCD. As it turned out the partitions are really easy to fix without having to touch the LV itself. If you use the LVM/libvirt/KVM/QEMU combo, you can use the following.

  • place the gparted LiveCD-iso in some readable place (that means not /root)
  • virsh edit <vmname> change <boot dev="hd" /> to <boot dev="cdrom" />
  • add next to your other disk-blocks:

<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/some/vm-readable/path/gparted-live-0.14.0-1.iso'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' unit='0'/>
</disk>

  • redefine and restart vm, connect via VNC (using virt-viewer for example)

Using the gparted GUI you can drag/drop the partitions to fill every last byte of the LV.

Don't forget to change back the boot device of your vm to "hd". Redefine and restart and be happy about your partition sizes as they should have been all along.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.