Add ova file as VM on Linux with libvirt (Qemu)
2018-02-12
173 words
1 min read
Although the commands are very simple and just 2-3 steps but I keep forgetting them and hence wrote the following script:
The script takes input as “ova” filename and then creates the qcow2 image and finally a VM for you.
#!/bin/bash - #=============================================================================== # # FILE: ova2vm.sh # # USAGE: ./ova2vm.sh # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Amit Agarwal (aka), # ORGANIZATION: Mobileum # CREATED: 12/28/2017 13:59 # Last modified: Thu Dec 28, 2017 02:17PM # REVISION: --- #=============================================================================== set -o nounset # Treat unset variables as an error if [[ $# == 0 ]] then echo "You need to provide ova/vmdk filename" exit fi if [[ $1 == *ova ]] then tmp=$(mktemp -d /tmp/amitXXXXXXX) cd $tmp tar xvf $1 file=$(echo $PWD/*vmdk) else file=$1 echo "Not a OVA file" fi dfile="$dest/$(basename $file)" read -p "Enter the name for VM" vmname qemu-img convert $file $dfile -p -c -O qcow2 virt-install --disk $dfile --ram 512 \ --virt-type kvm --vcpus 1 --name "$vmname" --import
Related Articles:
- 2018/01/29 Better windows VM experience on Qemu
- 2016/07/04 Python script to manage virtual machines with python API for libvirt.
- 2016/02/01 virsh – show ip address of all running VMs
- 2017/05/22 Fix display size on libvirt/Qemu guest
- 2016/07/25 Install virtual machines in one line
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.