Skip to content

TUTORIAL: Libvirt Image Preparation

vlj91 edited this page Sep 16, 2015 · 2 revisions

Once all preperation tasks have been performed for your chosen OS distribution, the image will need to be prepared for upload to the private Cloud of choice. From the build machine, prepare the image with the following steps:

###Sysprep To clean the image and prepare ready for use as a Cloud image, run the virt-sysprep tool:


$ virt-sysprep -d IMAGE_NAME # e.g. centos7.1


The sysprep tool removes all unique information stored on the OS such as logs stored in /var/log, SSH host keys, interface MAC addresses. To view a complete set of actions performed, run:

$ virt-sysprep --list-operations

###Sparsify Reduce the QCOW2 disk file by zeroing any unused disk space, dramatically reducing the image size:


$ virt-sparsify --compress --format qcow2 /path/to/existing/image.qcow2 /path/to/final/image.qcow2


The sparsify tool reduces the overall image size, automatically locating and zeroing any free space in the filesystem - this allows us to easily upload/download or distribute our image using a much smaller image size, as well as requiring less disk space on our Glance image regsitry server.

###Post preparation The image will need to be moved to an appropriate location for upload to the OpenStack Glance image registry. Our recommended methods include:

  • Upload via CLI: Transfer to OpenStack login node via scp
  • Upload via Horizon: Transfer to workstation used to access Horizon via scp

Clone this wiki locally