Appliances usually describe a smallish computer with a dedicated purpose. These are usually slow computers with no hard drive, very little RAM, and often lacking a monitor, keyboard, or graphical display.
The wireless network router is a perfect example. It has no screen, no input method except for a reset button, very limited RAM, and little bit of flash memory for saving user-defined settings. The user interaction takes place via the network, mostly through a small web application. Most of the time, it just sits there doing its job without the owner giving it a second thought. It may go months or even years without being rebooted or any other user interaction.
There are four main things you need to carefully consider before starting out:
Hardware: Since it will potentially be running 24 hours a day for years on end, the appliance should be built on a reliable and/or easily replaced hardware platform.
Operating system: Ideally, the operating system on a network appliance will take up as little space as needed, and have only the most basic set of tools to get the job done.
Configuration & resilience: An appliance should be resistant to damage that can be caused by a sudden power-off or reboot, but changes made in the user interface should be stored to non-volatile memory as soon as the user chooses to save the configuration.
Daemons & Services: A little network-attached computer that doesn't do anything for the network is just plain useless. Be creative.
Hardware
With modern technology, it's not difficult to meet the hardware requirements that an appliance demands. A motherboard and processor can last longer than a decade. Most computer hardware failures are due to moving parts such as cooling fans and hard drives. If you take the moving parts out of the equation, it's possible to build a computer that will be reliable for years to come.
Building an appliance out of a normal, everyday PC is possible. Get a motherboard that supports booting from USB, or purchase a solid-state hard drive (including those IDE-to-Compact-Flash adapters), under-clock the CPU and pick up a really good heat sink. There will be no need for a CPU fan, and if the fan in the power supply fails, it still should function properly.
A more practical route is to built a mini-ITX system. These are small motherboards, usually with slow but cool-running processors. They usually require no ventilation and are powered by an external power brick, without a real power supply in the case.
Another option is the use of a specialized ultra-compact, low-power computer that's purpose-built for this sort of thing. On the forefront of this market is Soekris Engineering. Soekris manufactures and sells purpose-built appliances that are for the most part x86 compatible. You can order just the components you want, or you can purchase it assembled into a high-quality metal case that's no bigger than an average-sized small-office ethernet hub. The logic boards come with at least one serial port for console interaction, and can be specified with several ethernet ports, cardbus, compact flash, and miniPCI connectors. They are affordable in small quantities for tinkering and prototyping, with heavy discounts on bulk orders.
Operating System
The operating system, as the base of your appliance, should be rock-solid and of course should have hardware and software support for everything you plan on doing with your appliance. The last thing you want is a setup that requires you (or your users!) to constantly reboot the appliance because of an unstable kernel, un-tested third-party patches for unsupported hardware devices, and the like.
Several appliance developers have chosen to go with OpenBSD, with many of them choosing Soekris hardware as their platform. Installation of the operating system in an "appliance" style really doesn't vary too much from platform to platform as much as it varies depending on the type of media that you plan on installing onto. Since we want to keep moving parts to a minimum, the best media to use is some sort of flash memory such as a compact flash card or a USB flash drive. Generally speaking, compact flash cards have the highest performance potential assuming you don't bottle-neck their performance by hooking them up via a USB card-reader. Many of the Soekris appliances and mini-ITX motherboards come with a built-in CF slot and support booting off of compact flash. On other mini-itx systems and most full-sized computers, you will probably end up having to boot off of a USB flash drive, but if you never need to change configurations, you could just as easily burn your installation to a CD and boot your appliance that way.
Flashdist is one project that aims to make it really easy to install OpenBSD onto an appliance. The author's target is Soekris, but in reality flashdist will work to install a compact version of OpenBSD onto a small flash drive, and the resulting flash drive should boot OpenBSD on any system that supports booting from USB, although I'd strongly recommend re-compiling the OpenBSD kernel with only the hardware support and options that are needed for your project.
Getting the base operating system installed is somewhat beyond the scope of this article. There are several other projects that you can find for getting various other operating systems to run on a very compact environment. Some are made with Soekris in mind, while others, such as m0n0wall are made to boot a full-sized desktop or server PC from CD and write configuration information to magnetic media, such as a floppy diskette.
Configuration & Resilience
This is a big one. Resilience is usually achieved by leaving the boot media mounted read-only so that files can't be easily corrupted if power is suddenly lost. Configuration changes can be saved by re-mounting the drive in a read/write state just long enough to modify the necessary files.
An operating system still needs a place to store its temporary files, and it's quite possible that other services you install on your homebrew appliance will also want to store logs, or otherwise require some writable drive space. This is achieved through the use of ramdisks. Usually, an appliance only keeps temporary logs that vanish once it's rebooted. Ramdisks for /tmp and /var are most common. This allows the system to use the binaries and libraries directly from the boot media, while giving the operating system and daemons somewhere to store logs and temporary files.
You will likely have to tinker with the configuration of the OS and daemons you choose to run. Ramdisks are meant to be small, so you will want to make automated provisions to keep them from becoming full of clutter, carefully monitoring them while you're in the development process.
Daemons & Services
This is where creativity comes into play, but this can also heavily steer the hardware requirements for your project, as well. If you want to make a network attached storage (NAS) file server, you will probably need to have a real hard drive. Some Mini-ITX systems have provisions for a 2.5" laptop hard drive, but I haven't seen a Soekris board that has this feature. You could make an 802.11 bridge to join two wireless networks together, a network sniffing and intrusion detection appliance, a web server load-balancer, or even a simple firewall for your home network. The opportunities are almost limitless!
Links:
------
PCEngines: Adapters to attach a CF card to a normal IDE controller
Soekris Engineering: Manufacturers of high-quality x86 appliance hardware
Flashdist, a package for creating embedded OpenBSD installations
M0n0wall, a ready-to-run network appliance CD-ROM
They even have MICRO-ITX boards which are even smaller!
ReplyDelete