Stackfactory: a Tool for Building Disk Images
This is a guest post by David Noe, founder of stacklet.com. David explains how Stackfactory – the GPL tool used to build images – works and how others may benefit.
Stackfactory is a GPL tool used to create filesystems and disk images, complete operating systems ready to run on a virtualization platform such as Xen. The program itself is coded in python and defines an xml minilanguage for building filesystems programatically. The xml files are referred to as “specifications†or simply specs. The entire stackfactory pipleline from specification to disk image is shown here:
From left to right we start out with some specs (which are simple xml files describing how to build a filesystem). The stackfactory program processes these specs into a tree of filesystems. In the tree above (labelled Filesystem Repository) we have created three filesystems: CentOS, Gnome and Ubuntu. The CentOS filesystem contains the minimum amount of core packages that would allow one to run CentOS. The Gnome filesystem is derived from the CentOS filesystem and layers the Gnome desktop components on top of the CentOS core. Then there is a minimal Ubuntu filesystem, analogous to the core CentOS filesystem except that it has Ubuntu packages instead of CentOS packages. Each of these three filesystems were created by running a spec through the stackfactory process.
To be clear, the filesystem repository shown is merely a sample — stackfactory can build trees of filesystems with unlimited depth. The contents of any given filesystem in the tree depends on the specification used to build it. Each filesystem can become the parent of a derived filesystem via snapshots. Essentially the snapshot mechanism lets us create new filesystems with a defined starting point without disrupting the original filesystem.
The final step in the pipeline is to select a filesystem from the tree and bundle it for deployment. During bundling stackfactory transfers the contents of a filesystem into a disk image that will be ready to run under virtualization. This bundling process is also specification driven. Currently there are specs to turn filesystems into xen disk images, vmware vmdk’s, qcow files, tarballs, Amazon ami’s and others. Supporting new platforms is tantamount to writing a specification that can output a format suitable for that platform.
Key Benefits
- Programmable: Uses a specification language instead of hard-coding behaviors.
- Layered: Filesystems can be built incrementally using snapshots
- Flexible: Decoupling the process of creating filesystems from creating disk images allows us to retarget filesystems to the maximal number of platforms.