FOSDEM lightning talk Sunday 2nd Feb 2014, 16:00, H.2215 Ferrer https://fosdem.org/2014/schedule/event/libguestfs/ Advanced disk image management with libguestfs libguestfs, virt-builder, virt-sparsify, virt-sysprep ---------------------------------------------------------------------- Good afternoon. Today I'm going to talk about libguestfs with is a suite of tools for looking inside and modifying virtual machine disk images. virt-builder ------------ First off, a new tool that we've written to create virtual machines. [ Show the builder.sh script ] [ Run the builder.sh script ] I'll come back to this script at the end of the talk. virt-builder can: - output raw, qcow2 and other formats - resize using [virt-resize] - write a random seed - set a hostname - edit configuration files - install packages - run custom scripts * at build time * or at first boot Libguestfs can safely and securely inspect and modify disk images without needing root. Virt-builder doesn't install guests from scratch. Instead it takes clean, cryptographically signed, compressed templates and uses libguestfs to customize them. Preparing the templates ----------------------- virt-builder comes with a handful of templates. You can also prepare your own. Over the years we have come up with a good way to prepare and distribute reasonably small templates virt-install (or Oz) v virt-sysprep v virt-sparsify v xz virt-install runs a regular OS install, using anaconda, debian-installer, etc. You can automate this completely using kickstart or preseed. virt-sysprep unconfigures the guest. Using libguestfs it removes SSH host keys, log files, network configuration, user accounts and so on. virt-sparsify ------------- virt-sparsify uses libguestfs to make guests sparse a.k.a. thin-provisioned. It looks for unused space: - in filesystems - in LVM physical volumes - swap partitions Including non-zeroed, but unused blocks. It converts that to sparseness in the host file. xz -- Finally xz compresses the template. We like xz for several reasons: - nearly best in class compression - preserves sparseness - compressed files can be random accessed [nbdkit] - virt-builder includes parallel uncompress Results ------- disk apparent final CirrOS 0.3.1 39 18 11 MB Debian 7 4096 719 142 MB Fedora 20 6144 826 174 MB Ubuntu 13.10 4096 1019 187 MB [At the end of the talk, show the progress of the builder script.] * libguestfs resources and other tools