20 01 2015
Update an OpenStack image
Quick presentation about 4 methodes (guestfish, guestmount, virt-* tools, qemu nbd) to update glance image. Add, remove, update files and install package before upload into glance.
- guestfish : Image is not mount directly on you file system. It provides you a shell with bases bash commandes (touch, edit, rm, chmod …)
- guestmount : Allows you to mount the image’s file system directly on your local file system
- virt-* tools : tools or modification directly in the image
- qemu nbd : mount filesystem without libguestfs
Get your image from glance
List images into glance
Download your image
Run a virtual machin (don’t forget run)
Find and mount the logical volume root
Make your changes
Mount/Umount glance image
To install packages like a running instance, you have to mount this
Run chroot to enter into your image
Fix resolv.conf and do your stuff
Clean your image
Or simply use virt-sysprep. This is a list of operation done by virt-sysprep
Umount to terminate your job
Converted back free space within the disk image to free space on the host
Upload your new image version
A lot of tools are available :
- virt-edit for editing a file inside of an image.
- virt-df for displaying free space inside of an image.
- virt-resize for resizing an image.
- virt-sysprep for preparing an image for distribution (for example, delete SSH host keys, remove MAC address info, or remove user accounts).
- virt-sparsify for making an image sparse
- virt-p2v for converting a physical machine to an image that runs on KVM
- virt-v2v for converting Xen and VMware images to KVM images
Example resize with virt-resize
Identify the root partitions
Here we want resize /dev/sda1
Now create a new image with your needed size (Example : 2G)
Write a resized copy of the original into the new image
Done, you are able to use your resized image.
Mount in RW with ndb
Umount your image