In SkyHiGh all virtual machines boots from images which is stored in the openstack image service (glance). Manipulation of these images is done trough the use of the glance client or trough the web interface. This page explains the glance client:
Image formats
As SkyHiGh utilizes KVM for the virtualization, a large range of image formats are supportet (vhd, vmdk, vdi, iso, qcow2, aki, ari, ami, raw). The preferred format is however raw images, as this enables the compute-node to create a root-disk for the virtual machine which is a COW (Copy-on-write) snapshot of the original image. This way it is not needed to take a full image before the virtual machine is booted. This speeds up the VM boot process a lot.
Determine image format
To determine what format a certain image is, qemu-img can be used like so:
$ qemu-img info trusty-server-cloudimg-amd64-disk1.img image: trusty-server-cloudimg-amd64-disk1.img file format: qcow2 virtual size: 2.2G (2361393152 bytes) disk size: 248M cluster_size: 65536 Format specific information: compat: 0.10 refcount bits: 16
Converting images
To convert images to the raw format, the utility "qemu-img" can be used:
$ qemu-img convert -f <original_image_type> -O <converted_image_type> <original_image> <converted_image>
So, to convert the qcow2 image "debian-8.2.0-openstack-amd64.qcow2" to a raw image, the following command could be used:
$ qemu-img convert -f qcow2 -O raw debian-8.2.0-openstack-amd64.qcow2 debian-8.2.0-openstack-amd64.raw
Uploading new images
To upload a new image to glance, the following command can be useful:
openstack image create --file <image_location> --disk-format raw --container-format bare --protected [--public|--private] <image_name>
For example, the following command would upload an ubuntu image:
openstack image create --file xenial-server-cloudimg-amd64-disk1.img.raw --disk-format raw --container-format bare --protected --public "Ubuntu Server 16.04 (Xenial) amd64"
The "–public" flag is used to indicate that all projects should have access to this image, and the upload would then require admin credentials. In the case of an image upload which should only be accessible to the project uploading it, that flag can be omitted.
Manipulate image-init images
Required packages for ubuntu, other OS might have different names. The procedure is tested with raw and qcow2 images.
- qemu-utils
- guestfish
- libguestfs-tools
- working sudo for your user
Verify that the cloud-init image is ok.
:~$ qemu-img check <image name> No errors were found on the image. 14510/36032 = 40.27% allocated, 98.23% fragmented, 98.04% compressed clusters Image end offset: 289210368
Manipulate the image with guestfish
# Mounting the filesystem :~$ sudo guestfish Welcome to guestfish, the guest filesystem shell for editing virtual machine filesystems and disk images. Type: 'help' for help on commands 'man' to read the manual 'quit' to quit the shell ><fs> add <path to image> ><fs> run ><fs> list-filesystems /dev/sda1: ext4 ><fs> mount /dev/sda1 / # Editing a file ><fs> vi /etc/fstab #Copying in a file from outside the image ><fs> copy-in <file outside the image> <pat to where to put it inside image> # Commiting and exiting guestfish. Exit does both ><fs> exit
Change existing images