In the previous post of this series I looked at what’s in an image. This post will cover the workings of an image factory.
The starting point for an image is... another image.
Whilst it’s possible to create an image entirely from scratch, that would involve having entire operating systems available as packages that could be deployed into those empty images. It’s just more efficient to start from a base operating system image or an imported image of the users choice.
Let’s say the image is mounted at /mnt/my_image... This is no good for running scripts, because if I try to modify files in /etc I’ll end up modifying the /etc of the factory rather than the /etc of the image (which is in fact /mnt/my_image/etc). I need to change root to /mnt/my_image, which can be done using the chroot command.
Chrooting allows scripts to change the image rather than the factory, but it’s not a panacea. Any code that I execute is running in the context of the factory - so (for example) if I try to find out what the OS type is then at best I’ll get the answer of the factory’s OS, and at worst I’ll get no answer at all (because the /proc filesystem that gives me a window into the inner workings of the operating system won’t be populated).
This means that I can use chroot to get some work done at inception but not every type of script or installation is going to work as might be inspected.
Using meta virtualization the image is actually running within the factory, so installation steps that might go awry in a chrooted environment should work perfectly. There are however a couple of things that can catch out the unwary:
Meta virtualization also allows for inception of non Unix derived operating systems (like Windows), which don't have chroot.
An image factory allows software installation to be done before a machine reaches a cloud so that it can be productive more quickly. Getting software into an image is relatively simple, but actually running stuff inside the factory is tougher - needing chroot or meta virtualization. It's worth it though, particularly when an image is going to be launched many times.
Base library and imports
![]() |
| Polly and Dolly, clones. Photo credit: The Telegraph |
Whilst it’s possible to create an image entirely from scratch, that would involve having entire operating systems available as packages that could be deployed into those empty images. It’s just more efficient to start from a base operating system image or an imported image of the users choice.
Mount here
To put things into an image the factory mounts it (or partitions within it) using the loopback interface, so the image appears to be a block device like any other. Once an image is mounted it’s very straightforward to copy packages into it.Chroots aren't just for smoking
![]() |
| Photo credit: chrisjohnbeckett on Flikr |
Chrooting allows scripts to change the image rather than the factory, but it’s not a panacea. Any code that I execute is running in the context of the factory - so (for example) if I try to find out what the OS type is then at best I’ll get the answer of the factory’s OS, and at worst I’ll get no answer at all (because the /proc filesystem that gives me a window into the inner workings of the operating system won’t be populated).
This means that I can use chroot to get some work done at inception but not every type of script or installation is going to work as might be inspected.
Meta virtualization to the rescue
Chroot is often used as a ‘poor man’s virtualization’, and the answer to many of the problems with chroot is to use a real virtualization container. As (in the case of Server3 at least) the factory runs on a virtual machine (in the cloud) this implies virtualization within virtualization, which we can call meta virtualization.Using meta virtualization the image is actually running within the factory, so installation steps that might go awry in a chrooted environment should work perfectly. There are however a couple of things that can catch out the unwary:
- When the image is instantiated as an instance inside the factory it will go through its first boot process. Some aspects of this (e.g. creating machine SSH keys, udev rules for IP addresses etc.) should not be carried over into the true runtime environment - especially where many instances will be launched from a single image.
- The image shouldn’t be allowed to customise itself to the factory hypervisor, and network, as it will meet new ones when it’s launched later as an instance.
Meta virtualization also allows for inception of non Unix derived operating systems (like Windows), which don't have chroot.
Conclusion
An image factory allows software installation to be done before a machine reaches a cloud so that it can be productive more quickly. Getting software into an image is relatively simple, but actually running stuff inside the factory is tougher - needing chroot or meta virtualization. It's worth it though, particularly when an image is going to be launched many times.






