The superblock.c program
In the debrick.sh page I covered the need for a program to manipulate the some of the data in the raid superblock in each partition. If you've read that you can skip the next two paragraphs.
This is necessary because there is the not unreasonable assumption that this script is being run on an Intel/AMD x86 platform. Such processors are 'little-endian' in that numbers are stored least significant byte first. However the Duo's processor is 'big endian' so this can lead to problems if a disk drive is moved from a little-endian environment environment to a big endian environment.
In part this can be dealt with by tight specifications which lay down exactly how data is stored. Unfortunately with the raid arrays used here (Version 0.9 of the spec) the data in the Superblock is endian sensitive. (This was fixed in later versions of the spec). This means that the mdadm tool we used to set up the arrays will have the numbers in the superblock back to front as far as the software on the Duo is concerned. The superblock program turns them the right way round for the Duo.
superblock.c is a slightly enhanced version of the original swap.c program. To run it:
superblock device [swap|zero|check]
e.g. superblock /dev/sda2 swap
There are three options:
swap Reverse the order of the bytes in the numbers in the superblock.
zero Set the superblock data to all zeros.
check Check that the superblock exists.
The first two options are used by the rebuild.sh script. The last option is helpful when checking/confirming that things are working properly. (It checks that a superblock does actually exist on the device).
The superblock data on the disk starts with a 'magic number' that lets software check that it's actually working on the right data. superblock does check this and will not do the byte swapping if it can't find it.
The program is compiled with the line:
gcc -o superblock superblock.c