We were recently asked if it was possible to create a bootable CD or DVD that would allow a pre-configured installation of Linux to run entirely in memory, using the computers internal hard-disk for data persistence only.
The answer is yes, quite easily - there are several tool available to create what is know as 'Live Distro' media, which is what this article will outline.
However, creating a Live Distro might sound like a strange way to distribute a software product - why not simply provide a regular installation file that uses automation tools such as ant, make, or an install-wizard etc to install alongside existing products?
The usual reason for adopting a 'Live Distro' approach is that the product will operate in isolation and potentially needs to run in a controlled environment. This might be to test the underlying hardware, to demonstrate a product, for security reasons, or to avoid interfering with existing data on the computer - or it could simply be to stop third-party software from adversely affecting its operation.
By providing a Live CD or DVD the vendor can be confident that their product will always operate in a 'known' and sterile environment - this makes subsequent support much easier...
Several well-known Live Distro products already exist; the Knoppix distribution of Linux (one of the first Live Distros) has proved extremely popular - it provides a rich set of tools and utilities that are often used to troubleshoot, diagnose and repair systems that are experiencing problems. Another popular Live Distro is the SmoothWall firewall which takes advantage of the read-only nature of CD and DVD media to ensure that malicious software cannot breach the integrity of its programs.
Amazon Web Services also use a similar idea - users produce bootable 'images' that create one or more Elastic Compute Cloud (EC2) 'instances' of a running computer. Each 'instance' runs entirely in memory, but can 'persist' data to Amazon's storage solution (S3) via 3rd-party products.
By providing a Live Distro we can be confident about the 'environment' in which the product is operating (although we may not know much about the hardware on which the program is running) and we can also be confident that a client has not changed the software, intentionally or otherwise.
However, there are several potential problems with Live Distros. It is the only software that can run on a given computer and a Live Distro will need to support a wide range of hardware devices, as little will be known in advance about the hardware on which the Live Distro will run - this will cause driver-compatibility issues if uncommon hardware devices are encountered.
Consideration must also be given on how to provide upgrades to the product - in the most basic form this would require production and distribution of new Live Distro media for every change, no matter how small. This is likely to be time-consuming and costly, although a compromise may be possible by allowing 'patches' to be installed on the local hard-disk which are found by the Live Distro as it boots and which override the default behavious (such an approach has serious security ramifications however).
So, how to actually produce your own Linux 'Live Distro'?
There are two popular approaches; the first is to use the Live Linux Scripts which, as the name implies, are a set of shell scripts dedicated to creating Live Linux distributions.This is a well-established and well-thought out approach that allows you to create a bootable version of your favorite Linux distribution using a wide variety of media including, CD, DVD, USB Devices and even your iPod!
The downside of Live Linux Scripts is that they require you to have a fair degree of Linux experience, as you will need to compile specific modules and load them into the Kernel. However, if you are comfortable with this level of technical detail, then the rest is plain sailing as scripts take care of the rest - they create an ISO image which can then be transferred onto a CD, DVD or USB device via other scripts.
The Live Linux Scripts also offer the ability to persist data (as mentioned earlier); the distribution will look for a particular directory on the local hard-disk and if found will record all changes to it.
The second approach is to use to tool called 'remastersys'. This is primarily targeted at the Ubuntu distribution (and its deriviatives). The idea is that the user configures a local Ubuntu installation as they wish - once they're happy with it's configuration, they use 'remastersys' to create a bootable ISO image of that configuration, then burn the ISO to CD or DVD.
Using 'remastersys' is easy:
remastersys dist
However, there are some disadvantages; their is no direct way to create a 'Live USB' distributiuon (although this is still possible using tools such as UNetbootin). There is also no native support for persisting data to a local hard-disk, although this logic could easily be included in the configuration of the source Ubuntu configuration, prior to using 'remastersys'.