[asterisk-users] Build your own "appliance" concept
Gordon Henderson
gordon+asterisk at drogon.net
Thu Sep 6 23:18:10 CDT 2007
On Thu, 6 Sep 2007, Jeremy P wrote:
> I've been working on this the past few days and thought I would put it out
> there to see if anyone else has interest in it. It really has nothing to do
> with the Digium appliance, I've just been looking for some mass produced
> solid state hardware to run small branch offices off of for awhile now and I
> think I've finally landed on something I like.
>
> Basically I've taken an HP thin client workstation which is all solid state
> and loaded Debian and Asterisk on it (well, Asterisk-GUI too, but just to
> prove I could make it "appliance-worthy"). I'd be interested in any
> feedback on how to improve it, specifically on how to make Debian and
> Asterisk take up less space so I could buy the model that only has 512 MB of
> flash rather than 1 GB.
I built my own "appliance" some time back - initially for a router
project, but I've since adapted it for Asterisk boxes and NAS boxes..
The basic unit has 64MB of IDE-flash, 256MB (or more) RAM. The flash IDE
device has one partition and is bootable, so it has a /boot with a bzImage
in it, enough of a /dev/ and /etc to make Lilo work on it and an initrd.gz
which is unpacked into a 128MB RAM disk, then the system runs entirely
from RAM once booted, so there's no continual write to flash issues (I
hope!) I do actually have a 2nd partition on the device which I tar all
the configuration files into - the bare minimal of what I need gets stored
there whenever something changes. (and a copy of astdb too). I don't think
this is perfect, and is prone to issues like a power cycle during write,
but ...
I put a 2nd IDE flash device for Voicemail storage - that does have a live
filesystem on it (currently just ext2, which I force an fsck of at boot
time, if it's dirty) I've used 64MB to 256MB devices for this (storing VM
in GSM format only), some customers want call recording, so they get the
bigger ones, but I'm thinking of moving to a laptop drive for people who
want even more (and enable idle spin down, etc.)
I build the kernel and initrd.gz file on a separate box - it's Debian, but
it could be anything as I don't actually put a "distribution" as such into
it, I just copy the files I need, and I'm lazy about it, so I copy all of
/bin, /lib, most of /etc and a /dev and selected bits of /usr/bin and
/usr/lib. (I use ldd on all the executables to work out which libraries I
really need from /usr/lib) The kernel is a custom kernel for the hardware
with no modules apart from Zaptel, etc.
I copy everything into a 128MB file, zeroed (it compresses better)
formatted ext2, mounted as a lookback device. Once the copy is complete, I
unmount it, gzip -9 it and that's the initrd.gz file. You need to make
sure that the Linix kernel you compile has the ability to load an
initrd.gz file and a big enough ramdisk!
It's not that efficient, and I could save space by using uClib, busybox,
etc. but it's really not worth it, but 2 things I don't have on the target
system is perl and vim.. Perl is about 10MB, as is vim. Right now I don't
have a need for either (and I use nano when I do need to tweak stuff which
is rarely) Perl would be nice so I could run stuff like mrtg locally on
the boxes, but isn't essential for now.
So if there are some new security implications on the current Debian, or
an asterisk upgrade, I just upgrade/update the build box, then create a
new initrd.gz file and install it. (however this is in the order of 40MB
for an Asterisk system with apache & php) so it a bit tricky to do a field
upgrade if the remote system is bandwidth limited, but I can pull it in
off a USB drive if necessary.
My /etc/asterisk and /var/www/docs are actually stored as part of the tar
file, so upgrading those is fairly trivial.
This is what a running system looks like:
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/ram0 124M 107M 18M 87% /
tmpfs 125M 0 125M 0% /dev/shm
/dev/hdc2 60M 23M 37M 39% /data
If I mount the flash device, then:
# ls -l /mnt
total 39019
drwxr-xr-x 2 root root 1024 Aug 9 14:54 boot
drwxr-xr-x 13 root root 24576 Dec 6 2006 dev
drwxr-xr-x 2 root root 1024 Nov 15 2006 etc
-rw-r--r-- 1 dsx 1000 39758472 Aug 9 14:53 image.gz
drwx------ 2 root root 12288 Dec 12 2006 lost+found
# ls -l /mnt/boot
total 2849
-rw-r--r-- 1 root root 512 Dec 12 2006 boot.0300
-rw-r--r-- 1 root root 512 Dec 22 2006 boot.0800
-rw-r--r-- 1 root root 512 Dec 12 2006 boot.1600
-rw-r--r-- 1 dsx 1000 1390066 Jun 5 15:47 bzImage
-rw------- 1 root root 31744 Aug 9 14:54 map
-rw-r--r-- 1 root root 98728 Sep 21 2006 memtest86+.bin
-rw-r--r-- 1 root root 241 Oct 28 2006 message
Because everything is in RAM, it's actually quite fun to "play" with
trying to destroy it :) Eg.
# cd / ; rm -rf *
then just reboot it to recover...
The one thing that's not "appliance" about it is the box - it's still a PC
at the end of the day, but I guess when I'm churning out 100's of these I
can afford a custom case design ;-)
Those HP boxes do look nice though, but they're more expensive that I
build my own for (in the UK at least!) but I do have the option of wall
mount, desktop or rackmount cases I guess...
Gordon
More information about the asterisk-users
mailing list