Category Archives: NAS

To keep track of the health of the disks in my ix2-200s, I setup SMART monitoring via SNMP using a lot of information from this post by Glen Pitt-Pladdy. However, I made a few changes.

Firstly, I use the output of smartd stored in /var/lib/smartmontools/ rather than the cronjob he uses. The format is quite different, and there’s a few extra bits of logic required to get the right values. Secondly, I tried rewriting it in python as an excuse to practice some python. Unfortunately, python takes much longer to start up than perl does, which means SNMP performance is noticeably affected by using the python version. Thirdly, since the state files don’t contain the device name, I switch to using the drive serial numbers as the index for the SNMP data. This might cause problems when it comes to swapping disks, but at least you can be sure you’re monitoring the right disk.

Lastly, and this is more of a bug than a feature, the format of the smartd state files is such that some raw fields are stored as 48 bit numbers, which makes the bitwise operations I use to extract the raw temperature fail in some situations on 32 bit perl. The proper solution would be to use Math::Int64, but this slows things down and it’s not a problem for my particular disks.

I’ve previously struggled to find a reliable way of building packages on my ubuntu laptop for my ix2-200 running squeeze. I’ve tried scratchbox/scratchbox2 in various configurations, and although it will work for some packages, not all packages work all the time, and I usually end up fiddling with scratchbox 2 settings/scripts/modes to make it work or using a native qemu session. The problems seem to be related to running scratchbox 2 directly on Ubuntu and thus which native tools that scratchbox 2 tries to use.

Recently my wife got a MacBook Air and so she needs a TimeMachine compatible system to back it up to if she wants to do so over the network. This means I needed to get the netatalk package working on one of my ix2-200s, but because the latest version of MacOS X requires AFP 3.3 support for TimeMachine, I needed 2.2.x rather than the 2.1.x that is currently available in squeeze. At the same time, I was also having a play with LXC that comes with Ubuntu 12.04 and lets you set up lightweight Debian and Ubuntu containers for process isolation etc. so I decided to see if I could get a reliable cross-compile environment going for this. I’m happy with the results and l like how I there is no dependency on packages installed in the underlying OS, although there are probably better ways to do it using tools directories and one of the other scratchbox modes.

The first step is to install LXC and create a Debian Squeeze container:

Once logged into the console (using the root account and password that it tells you in the output to lxc-create), you can then install all the required packages to run scratchbox. I use scratchbox2 and qemu from testing as well as the emdebian toolchain from its own repo, as the stable stuff is just a bit old, so I need to create the right APT preferences.

To enable the testing and emdebian repos, put the following in /etc/apt/preferences.d/10testing. I used cat to do this, because vi wasn’t installed:

One note about the LEDs is that the leds-gpio driver lacks the support to switch them to their full brightness, so they will be a bit dimmer than you might be used to. This can be addressed by twiddling the appropriate GPIO directly, which is documented in the patch.

Update: Alan pointed out that my old patch didn’t apply cleaning on 3.3 or above. I’ve changed my patch to only update the setup file. I’ve also extracted the patch from 3.3 that fixed the GPIO config problem, which you will need if you’re using version 3.2 or older. I’ve put them on google drive, so hopefully they’ll stay available.Setup file Patchmpp.h patchKernel 3.4.4 ConfigKernel 3.0.18 Config

I’ve been doing a few alterations to the kernel to support the ix2-200 LEDs, buttons, i2c sensor etc. and so I needed a fast and reliable way of compiling the kernel. I can do this directly under Ubuntu 11.10 using the arm cross compiler:

apt-get install gcc-4.6-arm-linux-gnueabi

Once that’s installed, I can just use the following environment settings to build as per the usual kernel build process:

Once this is complete, just checkout the version you want to use. I’d recommend the 3.0.x series, since that works well for me under Debian 6.0. The latest as of this writing is 3.0.26 and as of 3.0.13, the issues with mv_cesa have been fixed.

cd linux-stable
git checkout v3.0.26

At this point you can apply patches and copy a previously prepared config, such as from my earlier post

I use a standard set of environment variables for when I’m compiling a kernel:

export LOCALVERSION="" # don't append a special version string the kernel (but you can if you like)
export INSTALL_MOD_PATH=../modules # install the kernel modules in a special directory outside of the kernel structure

The next step is to setup the configuration by running make oldconfig.

make oldconfig

If you’re using the 3.0.x series and the configuration as above you probably won’t be asked any questions, but you’ll need to figure out the answer yourself if you do. The next step is to actually compile the kernel:

make -j8 uImage
make -j8 modules
make modules_install

Once these are done, I tar up the modules directory and then copy all the required files to the target.

At some point I’d like to get packaging automated so that I can just install a .deb like other howtos do.

I haven’t included the steps to use the cryptodev module, which I use for giving accelerating SSH via a modified openssl.

There are some packages in debian-backports that I think are required to make Debian 6.0 fully support modern kernels. I haven’t looked that closely as to what exactly might not work, but I haven’t run into any problems either.

Warning: This completely removes the existing filesystems from disk and kernel images from the flash that ship with the ix2-200 and leaves you with a basic Debian install. Only do this if you understand what this means and have nothing important stored on the device.

uBoot Parameters

The first step in installing Debian that I did was to reconfigure the uBoot environment to fix a number of issues. This is done from the uBoot prompt, which is only accessible via a serial interface.

Update the MAC address of the disconnected ethernet port on the SoC to an address from an unused range so that udev doesn’t get confused:

setenv ethaddr AA:00:00:00:00:01

Enable booting of a standard linux kernel

setenv mainlineLinux yes
setenv arcNumber 1682

Save and reset

saveenv
reset

Booting the Debian installer and completing the install

I used the published debian installer images from here copied to a ext2 formatted usb stick. I connected the usb stick to the front port of the ix2-200.

You should also have the ix2-200 connected to the internet somehow. A simple way of doing this for me was to connect to the Ethernet port of my laptop running Ubuntu and bridge it with the virtual bridge I use for running VirtualBox VMs and provides DHCP and NAT. Internet connectivity can than be used through another connection e.g. a home wireless connection. You can do this by running the following command on the laptop:

sudo brctl addif virbr0 eth0

From uBoot on the ix2-200, start the usb subsystem and load the netboot installer kernel and initial RAM disk into memory:

Exit the shell and reboot into uboot by selecting the “Finish the installation” option. At this point we should be able to now boot from disk using the uInitrd and uImage files on usb. Note that I also setup the mtd in the bootargs_console setting so we can write the kernel and initrd files to flash once we know it’s working. Replace the root value with what ever you setup during the install:

A few months back I bought a 2TB iomega ix2-200 ostensibly to use for backups. I chose this particular model because it was cheap – only AU$289 from a store here in Melbourne. Many other similar models cost more than that and they don’t even include the disks. I did actually use it for backups for a while before getting curious and finding out how to get a shell on the underlying OS. This turned out to be simple – username root, password soho<whatever you set for admin password>. From here it was easy enough to find that it was running a modified Debian (EMC Lifeline 2.1) under the hood.

Before I could let it just get back to the the lowly task of backing up all my data, I next did the obvious thing and took it to bits to see what was inside. I already new it was running a Marvell Kirkwood 88F6821 SoC and that it had 256MB of RAM. I discovered that it also had a 32MB NAND flash and an RS-232 header. I decided that it would be cool to try and get it to run something like FreeNAS so that I could ZFS, so I soldered up some sockets to a 3.5mm stereo jack and used my TTL-232R-3V3-AJ USB serial adaptor and using minicom, I could then get access to the uBoot boot loader.

I tried working with FreeBSD for a while, but with only 256MB of RAM system performance with ZFS would have been terrible so abandoned that idea and decided to give btrfs a go under Linux. Debian for ARM is easy to get a hold of and I ended up following the instructions by Diogo Gomez for installing Debian on the iomega iConnect. This got me to the stage of booting Linux from a USB stick. Next, in part one I’ll cover getting linux installed to the hard disks.