4 ms·
There's a lot of useful command-line tooling for KVM- and QEMU-based virt. Here's a small selection of them: • virsh — This[1] is libvirt's shell interface; a
by kashyapc 5y ago
There's a lot of useful command-line tooling for KVM- and QEMU-based virt. Here's a small selection of them:
• virsh — This[1] is libvirt's shell interface; and gives you access to the rich set of libvirt APIs.
• virt-builder — Use this for rapidly building minimal or customized virtual machines; it's greatly flexible; check out its man page[2]. And here's[3] a quick example that connects both virt-builder and virsh together.
• virt-install — Use this if you don't like the default build of the template images from virt-builder; it lets you create "headless" servers via 'kickstart' and Linux OS trees from the command-line.
• guestfish and libguestfs suite[4] — This rich set of tools help you in a variety of use-cases: repairing your broken disk images, editing, cloning, debugging disk images, and more. It has saved my behind a lot of times.
• qemu-img[5] – This Swiss Army knife lets you powerfully manipulate disk images (QCOW2, raw, et al) offline. Example operations include: create images, backing chains, offline snapshots, disk image merging, ability to convert disk images from one format to another, and more.
[1] https://libvirt.org/manpages/virsh.html https://libvirt.org/manpages/virsh.html
[2] https://libguestfs.org/virt-builder.1.html https://libguestfs.org/virt-builder.1.html
[3] https://developer.fedoraproject.org/tools/virt-builder/about.html https://developer.fedoraproject.org/tools/virt-builder/about...
[4] http://libguestfs.org/ http://libguestfs.org/
[5] https://qemu.readthedocs.io/en/latest/tools/qemu-img.html https://qemu.readthedocs.io/en/latest/tools/qemu-img.html
- voidfunc 5y agoIn terms of speed, how is virt-builder compare to say Terraform? Terraform is dog slow sometimes due to cloud provisioning. Would be nice to just be able to build the VM locally then push the AMI/VHD into AWS or Azure.
- kashyapc 5y agoI don't know how Terraform works, but `virt-builder` will cache the xz-compressed template images locally on your first pull. So for example, if you build a Fedora image: $ virt-builder fedora-32 --size 10G --format qcow2 Then the (xz-compressed) template Fedora 32 image will be cached under ~/.cache/virt-builder. So your subsequent Fedora 32 image provisioning will be much faster. You might want to give it a whirl and see if it satisfies your needs; `virt-builder` should be available on most major Linux distributions.
- rwmj 5y agovirt-builder can usually build out a disk image in 15-60 seconds if the template has already been downloaded and you're running on baremetal. Might be 120 seconds if you have to use nested KVM or TCG. $ virt-builder fedora-33 [ 1.5] Downloading: http://builder.libguestfs.org/fedora-33.xz [ 2.3] Planning how to build this image [ 2.3] Uncompressing [ 8.6] Opening the new disk [ 13.8] Setting a random seed [ 13.8] Setting passwords virt-builder: Setting random password of root to mZbPJw9d1ZHgowBk [ 14.8] Finishing off Output file: fedora-33.img Output size: 6.0G Output format: raw Total usable space: 6.0G Free space: 4.7G (79%) By the way, interesting virt-builder factoid: It uses a STRIPS-based planner to optimize the order of steps when building the image, so it doesn't waste time doing multiple copies. https://en.wikipedia.org/wiki/Stanford_Research_Institute_Problem_Solver https://en.wikipedia.org/wiki/Stanford_Research_Institute_Pr... https://github.com/rwmjones/guestfs-tools/blob/0cffcbb7848af85e6839c459e4b60adf51afb813/builder/builder.ml#L339-L599 https://github.com/rwmjones/guestfs-tools/blob/0cffcbb7848af... https://github.com/libguestfs/libguestfs-common/blob/74bc5c5c5cb4f9519f8deca5c33cb7f434bf3620/mltools/planner.mli https://github.com/libguestfs/libguestfs-common/blob/74bc5c5... https://github.com/libguestfs/libguestfs-common/blob/74bc5c5c5cb4f9519f8deca5c33cb7f434bf3620/mltools/planner.ml https://github.com/libguestfs/libguestfs-common/blob/74bc5c5...
- throwawayboise 5y agovirsh and/or lxc is all I ever use. All that cloud stuff, docker, kub-whatever is overkill to run a few VMs or containers at a small scale on-prem. KISS.