In case anyone is interested, that is how it's done: virt-sparsify --machine-readable input.img --convert qcow2 box.img
or qemu-img convert -O qcow2 imput.img box.img Then you're going to have to create minimal metadata.json and Vagrantfile, containing following: Vagrant.configure(2) do |config| config.vm.provider :libvirt do |libvirt| end end Finally, put these 3 files into tarball: tar cvf <box_name.box> Vagrantfile box.img metadata.json Resulting box is ready to be added to vagrant and used to bring the VM up: vagrant vagrant box add <arbitrary_box_name> <box_name.box> vagrant init --minimal arbitrary_box_name vagrant up Source <https://github.com/jedi4ever/veewee/blob/master/lib/veewee/provider/kvm/box/export_vagrant.rb> On 2 May 2015 at 00:36, Алексей Усов <[email protected]> wrote: > Also, my question is more about how to pack an existing VM into a box, > rather than finding a base box to begin with. I'd much rather not to rely > on boxes packed by other people - seems insecure to me. To start with, I > can download virtualbox box and then use Vagrant mutate plugin to convert > it into kvm box with libvirt provider. Once it's done, I can provision that > box with all software I need, but I can't package that VM into a new kvm > box with the same libvirt provider. I tried tar'ing .img file from > /var/lib/libvirt/images, metadata.json, and my Vagrantfile into a new .box > file, but when I try to add it to Vagrant to check if it contains > everything I installed into it, it says that metadata may be corrupted. > Official Vagrant docs say that I have to create box manually for any > provider other than virtual box, but I couldn't find any info on how to do > it properly. > > On 2 May 2015 at 00:22, Алексей Усов <[email protected]> wrote: > >> Well, I'll give it a try, but VMs managed by libvirt use libvirt >> provider, not kvm. >> >> On 1 May 2015 at 23:46, Alvaro Miranda Aguilera <[email protected]> >> wrote: >> >>> Hello, >>> >>> That box is KVM so I think it use libvirt? >>> >>> Ok, the other link seems was bad.. >>> >>> so there is this box >>> >>> https://vagrant-kvm-boxes-si.s3.amazonaws.com/trusty64-kvm-20140418.box >>> >>> So, I downloaded and then extracted >>> >>> x ./box.xml >>> x ./Vagrantfile >>> x ./metadata.json >>> x ./box-disk1.img >>> >>> >>> cat metadata.json >>> >>> {"provider":"kvm"} >>> >>> >>> cat Vagrantfile >>> >>> Vagrant.configure("2") do |config| >>> config.vm.base_mac = '080027A24479' >>> end >>> >>> >>> cat box.xml | gist >>> >>> https://gist.github.com/a190193a9b2f3b4db64f >>> >>> >>> Alvaro >>> >>> >>> On Fri, May 1, 2015 at 11:31 PM, Алексей Усов <[email protected]> >>> wrote: >>> > Thanks for the reply. >>> > >>> > That's the thing - I use libvirt for managing KVM VM. Is there no >>> > difference? >>> > >>> > On 1 May 2015 at 10:48, Alvaro Miranda Aguilera <[email protected]> >>> wrote: >>> >> >>> >> Hello >>> >> >>> >> I would suggest to add this box and try it >>> >> >>> >> if works, then see that's in the box: >>> >> >>> >> https://atlas.hashicorp.com/detain/boxes/ubuntu-14.04-x86_64 >>> >> >>> >> >>> >> >>> >> On Fri, May 1, 2015 at 12:58 AM, Beckett <[email protected]> >>> wrote: >>> >> > Greetings everyone. Could someone explain me how can I package >>> running >>> >> > VM >>> >> > managed by libvirt with KVM driver into a box so anyone who gets it >>> >> > won't >>> >> > have to create & provision it from scratch? The question of >>> packaging a >>> >> > box >>> >> > for virtualbox provider is well covered in the documentation, but >>> >> > libvirt >>> >> > makes it quite tricky. Thank you in advance. >>> >> > >>> >> > -- >>> >> > You received this message because you are subscribed to the Google >>> >> > Groups >>> >> > "Vagrant" group. >>> >> > To unsubscribe from this group and stop receiving emails from it, >>> send >>> >> > an >>> >> > email to [email protected]. >>> >> > For more options, visit https://groups.google.com/d/optout. >>> >> >>> >> -- >>> >> You received this message because you are subscribed to a topic in the >>> >> Google Groups "Vagrant" group. >>> >> To unsubscribe from this topic, visit >>> >> https://groups.google.com/d/topic/vagrant-up/6ig02OJnhLQ/unsubscribe. >>> >> To unsubscribe from this group and all its topics, send an email to >>> >> [email protected]. >>> >> For more options, visit https://groups.google.com/d/optout. >>> > >>> > >>> > >>> > >>> > -- >>> > С уважением, Усов А.Е.. >>> > Best Regards, Usov A.Y.. >>> > >>> > -- >>> > You received this message because you are subscribed to the Google >>> Groups >>> > "Vagrant" group. >>> > To unsubscribe from this group and stop receiving emails from it, send >>> an >>> > email to [email protected]. >>> > For more options, visit https://groups.google.com/d/optout. >>> >>> -- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "Vagrant" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/vagrant-up/6ig02OJnhLQ/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> С уважением, Усов А.Е.. >> Best Regards, Usov A.Y.. >> > > > > -- > С уважением, Усов А.Е.. > Best Regards, Usov A.Y.. > -- С уважением, Усов А.Е.. Best Regards, Usov A.Y.. -- You received this message because you are subscribed to the Google Groups "Vagrant" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
