Friday, January 4, 2008

Installing optware and NFS on a QNAP TS-201/TS-101

With optware installed on the turbostation you can install additional packages. So you
can make your turbostation to do what you want.

This post describes how to installl optware without changing the firmware in your turbostation.
It also describes how to install NFS as an example on installin packages. And as last in detail how to change so that when you boot up you can start services automatically, so you do not have to redo it manually (On reboot the firmware overwrites changes made.)

As always be aware and it done on your own risk.

This post is a compilation of the information found in:

Prerequisites

To be able to install things on your TS-201 is that you have a firmware with telnet enabled. If you do not have it, you can download it from QNAP homepage:
Install the firmware according to the instructions.


Telnet

First you have to telnet into your TS-201.
The port to use is 13131 and with username administrator.
The default password for administrator is admin if
you have not changed it through the webinterface.

telnet TS201_Address 13131

Now you are in ash shell as root on your TS-201.

Install optware

1. Create directory structure

cd /
rmdir /opt
mkdir /mnt/HDA_ROOT/opt
ln -sf /mnt/HDA_ROOT/opt /opt


2. Get and install latest ipkg. Currently the below is latest.


cd /tmp
wget http://ipkg.nslu2-linux.org/feeds/optware/ts101/cross/unstable/ipkg-opt_0.99.163-9_powerpc.ipk
tar -zxOf ipkg-opt_0.99.163-9_powerpc.ipk ./data.tar.gz | tar -zx -C /
# Add where to download packages from
echo src ts101 http://ipkg.nslu2-linux.org/feeds/optware/ts101/cross/unstable >> /opt/etc/ipkg.conf


NOTE: The above 'wget ipkg-opt...' does not work right now since it is deleted in the feed for some reason. According to:
http://tech.groups.yahoo.com/group/OpenTurbostation/message/1002
So use this instead:

wget http://www.mediamax.com/bzhou/Hosted/optware/ts101/ipkg-opt_0.99.163-9_powerpc.ipk


Now you can install all packages that you want in your TurboStation

Install NFS

1. Install NFS with optware. See above to install optware.

/opt/bin/ipkg update
/opt/bin/ipkg install unfs3

2. Create exports file and start nfs.

echo /share/Public (rw,no_root_squash) > /opt/etc/exports
portmap
/opt/sbin/unfsd -e /opt/etc/exports


Above example exports the Public folder. Also the no_root_squash option should only be used if you trust your users. That if they mount the folder as root they will have root permissions.

If you want to mount the TurboStation with fstab you should have something like the below in there.


Your_TS_Address:/share/Public /qnap/Public nfs auto,nosuid,user,nolock,tcp 0 0


Backup configuration

Backup your configuration. I find it best to do the backup inte /share/Public
which the TurboStation should not overwrite.

cd /share/Public
tar -cf backupTS201.tar /mnt/HDA_ROOT/opt

Edit autorun.sh

When the turbostation is rebooted the firmware overwrites the changes that have been made. What is kept is what is on the harddrives. You also have to restart the services manually. This can be done automatically by editing the autorun.sh in mtdblock4 which the firmware isnt overwriting on a reboot.

If you reboot after the above, the opt symlink would need to be redone and start of nfs aswell. There is also no guarantee that the things in HDA_ROOT are kept. So you might need to extract your backup aswell.

But everything can be done automatically with autorun.sh.

1. Mount mtdblock4

mkdir -p /tmp/config
mount -t ext2 /dev/mtdblock4 /tmp/config

2. Edit config/autorun.sh you can use vi or the echo method above.

vi config/autorun.sh

Add this to the script:

rmdir /opt
ln -sf /mnt/HDA_ROOT/opt /opt
portmap
/opt/sbin/unfsd -e /opt/etc/exports -t

3. Save the file and umount.

umount /tmp/config

Now NFS will be started and the symlinks to opt will work.