Last week I thought a little about naming volumegroups on SANs, logical volumes,
hosts and (micro)SD cards. They all have one thing in common, if you have a lot
of them you hardly can avoid numbering them. The only problem with this is of course
small typos that can lead to disasters. Fortunately there are of course solutions for this.
After some thinking I thought about using checksums in the numbering, which makes
it harder to create a disaster with just one typo. The best scheme I could find
to work for this was using the ISBN numbering scheme.
So i.e. I now number my (micro)SD cards as follows:
- jni-60001
- jni-10002
- ...
- jni-12761
- jni-72762
- jni-22763
- etc.
As you probably can see the first number is the checksum digit. A number is
valid if and only if the checksum digit + 2 times the second number + 3 times
the third number + 4 times the fourth number ... modulo 11 = 0. Note that the checksum digit
can also be X to indicate a value of 10.
If you look at the jni-60001 number. The checksum is 6. And the 1 is multiplied by 5. Summarized
this makes 11, which modulo 11 is of course 0. So this is a correct number. But what if we make
a typo i.e.:
- jni-60010, this becomes (6+4) modulo 11 = 10, which is not valid.
- jni-60002, this becomes (6+10) modulo 11 = 5 , which is not valid.
- jni-60019, this becomes (6+4+45) modulo 11 = 0 , which is valid. But then you already have
made 2 typos.
Of course I created a script for this that does all the hard work. It can be found
here.