Showing posts with label ipkg. Show all posts
Showing posts with label ipkg. Show all posts

Monday, January 23, 2012

How to install software into your Iomega StorCenter ix4-200d


This tutorial uses unsupported features of the IOMEGA Storcenter ix4-200d. It worked for me but use it at your own risk! It should work (again, it is unsupported) on the ix2 Storcenter as well.
Tutorial tested on IOMEGA Storcenter ix4-200d firmware 3.1.14.995
The aim of the tutorial is to be able to add programs to you NAS without having to go too deep in the system. This is also helpful to compile natively on the NAS without needing to cross compile for your architecture....


1. SSH into your NAS
See my other post: How to ssh into your Iomega StorCenter ix4-200d


2. Directory Structure on the NAS
The Lifeline OS (Iomega's OS) does put most of the root file system in read only mode. It is not much use to try to put stuff there anyway because the partitition is very small
You can type:
df
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                   51200      5652     45548  12% /
/dev/root.old             6613      2119      4494  33% /initrd
none                     51200      5652     45548  12% /
/dev/md0_vg/BFDlv      4128448    619496   3299240  16% /boot
/dev/loop0              587077    580124      6953  99% /mnt/apps
/dev/loop1                4959      2230      2473  48% /etc
/dev/loop2                 216       216         0 100% /oem
tmpfs                   255748         0    255748   0% /mnt/apps/lib/init/rw
tmpfs                   255748         0    255748   0% /dev/shm
/dev/mapper/md0_vg-vol1
                      16775168   3283704  13491464  20% /mnt/system
/dev/mapper/2602b0ce_vg-lv43ec31bd
                     2867212288 1169119852 1698092436  41% /mnt/pools/A/A0
to see the partitions and their mountpoint.
The idea seems to be that third party programs should be installed in the /opt/ directory, which has ample storage (16GB) whereas root (/) only has 50MB.


3. Use ipkg
ipkg is intalled by default in the Iomega storcenter. We just need to specify the right place to find the packages:
vi /etc/ipkg.conf
src cross http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable
src cross http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/unstable
Then type:
ipkg update
to build the list of available packages.


The problem of this setup is that you won't be able to install some packages because installation will fail because part of the filesystem is readonly.
Thanks to ipkg, there is an easy fix:
ipkg install ipkg-opt
This installs the binary /opt/bin/ipkg-opt. The idea is then to use this binary instead of the regular ipkg: as a result all packages will be installed in /opt/ and you won't run into problems with the read only filesystem.
The only drawback is that /opt/bin/ is not in your path... There is a simple remedy for that:
PATH=/opt/bin:$PATH
Note: this is not persistent (if you start another shell, you will need to do that again).
Also, as a one time persistent thing, I recommand to do
vi /etc/ld.so.conf
and add
/opt/lib/
at the end. That's the main problem with /opt installed software: you might end up to get duplicated libraries between /lib and /opt/lib (ldd and ldconfig are your friends).

You also need to do:
mv /opt/etc/ipkg.conf /opt/etc/ipkg.conf.old
ln -s /etc/ipkg.conf /opt/etc/ipkg.conf
so that you config in /etc/ipkg.conf remains useable with /opt/bin/ipkg and /opt/bin/ipkg-opt

Then type:
/opt/bin/ipkg update
to setup the list of available packages for /opt/bin/ipkg /opt/bin/ipkg-opt

4. Install utilities and optware-devel
First install the utilities you miss to do some actual linux stuff:
ipkg-opt install zip unzip bzip2 gzip

If you want a full gcc toolchain to compile your own applications from source.
ipkg-opt install optware-devel
The compilation can be slow but this allows you to natively compile on your NAS (I think it is simpler because there is no need to set up cross compiling on another box)...

5. Install armel/debian compiled software
Unfortunately, you will soon discover that some of the packages you want are not available for ipkg.
You can then either compile your own software (see next point) or get some ready-made debian archives....
In this case, I suggest to use the following command (for example for libsigc++-2.0-dev):
cd /opt/tmp/
wget http://ftp.de.debian.org/debian/pool/main/libs/libsigc++-2.0/libsigc++-2.0-dev_2.0.18-2_armel.deb
dpkg --instdir=/opt/ --admindir=/opt/dpkg/ -i libsigc++-2.0-dev_2.0.18-2_armel.deb
Note: do not use /tmp/ as the space available there is very small...
Note2: be careful to choose packages compiled for your architecture (armel in my case)! The above command will install your soft as if /opt/ was the root directory (you will end up with /opt/usr/lib directories and the like). As a result, you might need to add stuff in your PATH or edit /etc/ld.so.conf.
Be careful not to make a mess of your system or you will soon end up with several times the same library (with different versions) at different locations... You will need to sort this manually(ln, rm...)


6. Compile from source
For example, a very classic install for libnfnetlink:
cd /opt/tmp/
wget http://www.netfilter.org/projects/libnfnetlink/files/libnfnetlink-1.0.0.tar.bz2
tar -xvf libnfnetlink-1.0.0.tar.bz2
cd libnfnetlink-1.0.0
PATH=$PATH:/opt/bin
./configure --prefix=/opt/
make
make install
Note: to get bzip2 to work I had to do before the tar -xvf:
ln -s /opt/bin/bzip2-bzip2 /opt/bin/bzip2
Another example using svn
cd /opt/tmp/
PAH=/opt/bin:$PATH
svn checkout http://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/stable xmlrpc-c    
cd xmlrpc-c/
./configure --prefix=/opt
make
make install
Don't forget the --prefix=/opt to specifiy you want to install your package.

When compiling from source, you run into the usual complation problems you can get with linux (libraries/includes not found etc...). It gets even more annoying because default stuff does not work well anymore (package manager is not where expected etc), and sometimes you end up having to specify the complie flags yourself.
For example, I recently had to edit the configure script of a source tarball to add:
sigc_LIBS='-L/opt/lib/ -lsigc-2.0 -L/lib/'
sigc_CFLAGS='-I/opt/usr/include/sigc++-2.0/ -I/opt/usr/lib/sigc++-2.0/include -I/opt/include/ncurses'
libcurl_LIBS='-L/opt/lib/ -lcurl'
libcurl_CFLAGS='-I/opt/include/'
libtorrent_LIBS='-L/opt/lib/ -ltorrent'
libtorrent_CFLAGS='-I/opt/include/'
-dev packages can be difficult to find with ipkg, this is where you often need to get a .deb package or compile the library from source just to get the header files right...

7. Conclusion
As you noticed, it is just a matter of using the tools (and using them right). It just gets a little bit more complicated because the usual package manager does not work out of the box, the procedure is unsupported by the hardware vendor and precompiled packages can be difficult to find for armel...