There are many resources on the Internet to create a custom vagrant box from a VirtualBox instance. But I want to know a direct method to create a custom vagrant box directly from a kvm/libvirt instance . Please don't suggest vagrant-mutate or any that convert VirtualBox to another provider.
how to create custom vagrant box from libvirt/kvm instance?
linux;kvm;libvirtd;vagrant
after spending time with vagrant i got the solution for custom box.first of all install any Linux OS in libvirt/qvm and login to it for customization and create vagrant user with password vagrantadduser vagrantvagrant user should be able to run sudo commands without a password prompt sudo visudo -f /etc/sudoers.d/vagrantand paste vagrant ALL=(ALL) NOPASSWD:ALLdo whatever you want to customize your vagrant box and install openssh-server if not installed previously  sudo apt-get install -y openssh-serverput ssh key from vagrant usermkdir -p /home/vagrant/.sshchmod 0700 /home/vagrant/.sshwget --no-check-certificate \https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub \-O /home/vagrant/.ssh/authorized_keyschmod 0600 /home/vagrant/.ssh/authorized_keyschown -R vagrant /home/vagrant/.sshopen sudo vi /etc/ssh/sshd_config and change PubKeyAuthentication yesAuthorizedKeysFile %h/.ssh/authorized_keysPermitEmptyPasswords noPasswordAuthentication norestart ssh service using sudo service ssh restartinstall additional development packages for the tools to properly compile and install sudo apt-get install -y gcc build-essential linux-headers-serverdo any change that you want and shutdown the VM .  now , come to host machine on which guest VM is running and goto the  /var/lib/libvirt/images/ and choose raw image in which you did the change and copy somewhere for example /testcp /var/lib/libvirt/images/test.img  /test create two file metadata.json and Vagrantfile in /test do entry in metadata.json {  provider     : libvirt,  format       : qcow2,  virtual_size : 40}and in VagrantfileVagrant.configure(2) do |config|         config.vm.provider :libvirt do |libvirt|         libvirt.driver = kvm         libvirt.host = 'localhost'         libvirt.uri = 'qemu:///system'         endconfig.vm.define new do |custombox|         custombox.vm.box = custombox                custombox.vm.provider :libvirt do |test|         test.memory = 1024         test.cpus = 1         end         endendconvert test.img to qcow2 format using sudo qemu-img convert -f raw -O qcow2  test.img  ubuntu.qcow2rename ubuntu.qcow2 to box.img mv ubuntu.qcow2 box.img Note: currently,libvirt-vagrant support only qcow2 format. so , don't change the format just rename to box.img. because it takes input with name box.img by default.create box tar cvzf custom_box.box ./metadata.json ./Vagrantfile ./box.img add box to vagrantvagrant box add --name custom custom_box.boxgo to any directory where you want to initialize vagrant and run command bellow that will create Vagrant file vagrant init customstart configuring vagrant VMvagrant up --provider=libvirt enjoy !!!