Linux Home

(Last updated: Saturday February 24, 2007)

LORHA - Linux OpenRemote/Home Automation

Okay so the acronym sucks! It's pronounced Laura and no it's not named after anyone. I'm not the most imaginative person when it comes to naming things and this was the best I could come up with.


I need to have a complete operating system geared towards the needs of a HA server. While I'm trying to setup a custom environment for HA I'm also trying to adopt ready made packages and their package manager (I'm leaning towards iPkg). I don't want to be responsible for trying to keep up with every update on my own. Yet I would like to keep up to date so vulnerabilities don't weaken the quality of the the system.

Management of the ocnfiguration will be available via the command line (accessed via ssh) or via http (a web server). I'll probably use Perl and CGI but I'm not certain of that yet. I'd like to have it at least look as good as the Linksys web interface. Actually probably more like the SPA-3000 interface (lots of Javascript). Since it's all open source I won't be hiding anything but I really want to see security being used from the git-go. Most HA lacks real security and often a huge weakness.


At minimum:

  • Disk space - at least as much as the CF card holds.

To actually write the image to the CF card:

  • Disk space - at least as much as the CF card holds.
  • A CF card
  • A CF card reader. I've used a nice Sandisk USB reader I have and a Kodak PCMCIA card reader. Both have worked fine.


Of course this is a work in progress but this should be the spot for my notes and instructions on how to build an embedded Linux distribution. In the next few days (from 7/11/2008) I'll post the details on how I took a 128M CF image and grew it to 2G. I couldn't find any decent notes on the web to do this. Eventually I'd like to have fully explained everything from cross compile development systems to putting the whole thing on a compact flash, USB, or a hard drive (like the micro drives). I'm looking at some existing projects first so I don't have to go through the entire from scratch (Linux From Scratch is one of those systems I'm looking at). Basically it would be nice to be roll my own for what every processor I need instead of spending $500+ (US) for what is essentially a free distribution.

What you won't find here is how to take you're brand new gen-X 64 and a half bit processor and compile a new kernel for that. Sorry I'm not that far along and doubt I every will be.

Currently I'm mostly interested in embedded x86 systems (I have a few), ARM (a few of those too), the AVR32 (if I ever get time to sit down with this one) and maybe a few more, but no promises.

LORHA Images

Here are the initial LORHA images needed by the OpenRemote reference implementation hardware:

Growing my CF image

Okay, so here's what started all of this, I just received my new embedded system (an ALIX3C2) and I wanted to get it booted up quickly. So I downloaded the image (a 128M image for a CF card) and followed the directions for dumping it to the CF card:

    $ dd if=cf.img of=/dev/sdb bs=1024

That works great, I put it int the system and it boots up (yeah!). Only issue is that the card I have is a 2G CF card. That means I have about 1.7G of wasted space. Oh, I also need to get the Java JRE (about 100M) on this card. Hmm what to do? I know I'll search for information on growing the partition to fill the CF. Well that almost works, parted doesn't seem to play nice with my CF card. It could be me, I've not used parted a lot before except when I put Linux on my XP laptop. There is worked great!.

STOP!: If you don't know what you are doing you can royally screw up your working system! On my Linux system the compact flash card shows up on /dev/sdb. My boot disk is on /dev/hda. Mix those up and you will make your system unrecoverable. Don't follow these instructions if you are tired or confused. If you are using grub be even more careful as (hd0) and (hd1) can get pretty confusing when typing in all these commands.

    # STOP! If you've just found this don't use these instructions
    # yet! I'm in the middle of putting these instructions together
    # and I haven't double checked them yet. When I remove this
    # warning then it's probably safe to use them.
    # You need to be root, I'm using '$' as the prompt as '#' is being
    # used for comments

    $ dd if=cf.img of=/dev/sdb bs=1024
    $ dd if=/dev/sdb1 of=cf.root.img bs=1024

    # Wipe out the partition, then add it back in using the full space
    $ fdisk /dev/sdb
    $ mkfs -ext3 /dev/sdb1
    $ mount /dev/sdb1 /mnt

    # I need to look at using losetup, this may allow me to use grub
    # on the locally mounted device instead of having to have a real
    # CF card mount. This would be great to create images without
    # having to setup a card each time.
    $ mount -o loop cf.root.img /media/tmp -o r


    njc@toshiba:~$ uname -a
    Linux toshiba 2.6.24-19-generic #1 SMP Wed Jun 18 14:43:41 UTC 2008 i686 GNU/Linux
     (a)   -(b)-   ------(c)------   --------------(d)---------------    (e)   (f)
    [root@orc ~]# uname -a
    Linux orc.uucp 2.6.20-imedia-wrap #1 Mon May 14 13:30:50 EEST 2007 i586 unknown

(a) - kernel name
(b) - node name
(c) - kernel release (-EXTRAVERSION appended)
(d) - kernel version 
(e) - machine hardware name
(f) - operating sytem

Compact flash layout

Here is my proposed layout of a 1G Flash card. Since 2 and 4G flash cards are becoming more prevalent then adjust the Boot partition as needed. And yeah, I know it doesn add up, I'm rounding the numbers.

             1G CF Card
        |       GRUB       | ~64K
        | Rescue Partition | 256M
        |  Boot Partition  | 768M

Grub configuration

the grub.conf file:


serial --unit=0 --speed=38400 --word=8 --parity=no --stop=1

terminal --timeout=2 console serial

title OpenRemote controller - ORC
    root (hd0,1)
    kernel /boot/vmlinuz ro root=/dev/hda2 console=ttyS0,38400,8n1 hdb=noprobe hdc=noprobe hdd=noprobe reboot=bios quiet  

title OpenRemote Rescue
    root (hd0,0)
    kernel /boot/vmlinuz ro root=/dev/hda1 console=ttyS0,38400,8n1 hdb=noprobe hdc=noprobe hdd=noprobe reboot=bios quiet  

Some quick links


How do you build bootable compact flash?


Grub and OpenEmbedded

Voyager Linux

Voyage Linux - WRAP

XORP, or Extensible Open Router Platform

Floppy FW


Building a stealth firewall (bridging)


bmon (local file)

Debian gw6c

Openwrt gw6c Makefile

Bering Uclib GRUB

Grub on Compact Flash

Installing GNU/Linux on a CompactFlash Card Mini-HOWTO

How to build an IPV6 router Linux 5 for the ALIX

How to create a FreeDOS bootable CF card

OpenWRT ALIX port (old)

OpenWRT BuildRoot (old)

OpenWRT Get source

How do I make an image that I can write to a cf card?

    # mount /dev/sda1 /mnt
    # chroot /mnt sh
    $ mkdir /boot/grub
    $ cp /usr/lib/grub/i386-pc/stage1 /boot/grub
    $ cp /usr/lib/grub/i386-pc/e2fs_stage1_5 /boot/grub
    $ cp /usr/lib/grub/i386-pc/stage2 /boot/grub
    $ cat > /boot/grub/menu.lst
    # use the serial terminal for the console.  The --unit is specifying
    # that it should use /dev/ttyS1, the speed is 115200
    serial --unit=1 --speed=115200

    # it's a dumb terminal.
    terminal --dumb serial

    # by default, boot menu entry 0.  There's no timeout, so we'll sit at
    # the prompt until the user hits "enter"
    default 0

    # start menu entry with title
    title openembedded GNU/linux
    # tell grub to find the kernel on /dev/hda1
    root (hd0,0)
    # the kernel needs to use ttyS1, same speed as grub.  Also, we need to
    # tell the kernel where to find its root filesystem.  Note the
    # different syntax for specifying the console and specifying the root.
    kernel /boot/bzImage console=ttyS1,115200 root=/dev/hda1
    $ mknod /dev/sda b 8 0
    $ mknod /dev/sda1 b 8 1
    $ grub
    grub> device (hd0) /dev/sda
    device (hd0) /dev/sda
    grub> root (hd0,0)
    root (hd0,0)
    Filesystem type is ext2fs, partition type 0x83
    grub> setup (hd0)
    Checking if "/boot/grub/stage1" exists... yes
    Checking if "/boot/grub/stage2" exists... yes
    Checking if "/boot/grub/e2fs_stage1_5" exists... yes
    Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  17 sectors are embedded.
    Running "install /boot/grub/stage1 (hd0) (hd0)1+17 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded
    grub> quit
    $ exit
    # umount /mnt