Friday, May 20, 2011

Optware/ipkg on Synology DS211+

Note that the following covers the DS211+ device, which is characterized by being based on the Marvell Kirkwood mv6282 ARM core (1.6Ghz version of 1.2Ghz mv6281). AFAIK the content of this blog entry should be equally applicable to all DS211 variations, but you should consult the Synology wiki for your device to be certain.

While quite feature rich out-of-the-box, developer types will likely want to make their NAS do even more, either out of a real need or just to tinker. For instance, I eventually plan to connect my USB weather station and generate live charts. Because of the modding desire, Synology has a faily comprehensive wiki about the subject. To make a long story short, ease of modding is greatly assisted by the possibility of installing Optware package manager.

Installing Optware
Optware (ipkg) is an online package system a la what you may know from Debian/Ubuntu. This makes it easy to locate, install and uninstall compiled binaries (*.ipk) through the command-line.

Bootstrapper and Optware packages are maintained by the NSLU2-Linux community for use with various modifiable hardware devices incl. many Synology products. The installation procedure simply involves you downloading and installing the Optware-bootstrapper for your NAS. Here's what I wrote while logged in as root via SSH/telnet, to get it working.

Download the Optware bootstrapper:

NAS> cd /volume1
NAS> wget
           => `syno-mvkw-bootstrap_1.2-7_arm-ds111.xsh'
Connecting to||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 251,866 (246K) [text/plain]

100%[====================================>] 251,866      435.14K/s             

22:58:08 (434.50 KB/s) - `syno-mvkw-bootstrap_1.2-7_arm-ds111.xsh' saved [251866/251866]

Start the installation:

NAS> sh syno-mvkw-bootstrap_1.2-7_arm-ds111.xsh 
Optware Bootstrap for syno-mvkw.
Extracting archive... please wait
1227+1 records in
1227+1 records out
Creating temporary ipkg repository...
Installing optware-bootstrap package...
Unpacking optware-bootstrap.ipk...Done.
Configuring optware-bootstrap.ipk...Modifying /etc/rc.local
Installing ipkg...
Unpacking ipkg-opt.ipk...Done.
Configuring ipkg-opt.ipk...WARNING: can't open config file: /usr/syno/ssl/openssl.cnf
Removing temporary ipkg repository...
Installing wget...
Installing wget (1.12-2) to root...
Configuring wget
Successfully terminated.
Creating /opt/etc/ipkg/cross-feed.conf...
Setup complete.

BusyBox v1.16.1 (2011-04-08 10:13:55 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.


Note, if you get the message "Error: CPU not Marvell Kirkwood, probably wrong bootstrap.xsh", this is likely due to a too agressive sanity check (mv6281 but not mv6282) in the install script. If the output of the command "cat /proc/cpuinfo" mentions a "Feroceon" CPU, then you may safely open up the file "/volume1/bootstrap/" and edit line 21, changing "Feroceon-KW" to just "Feroceon", and run the script manually with "sh /volume1/bootstrap/".

The above will install a boot hook and create the directories /volume1/bootstrap and /volume1/@Optware where package manager and installed packages will reside. The content in /volume1/@Optware can also be found in /opt, due to an Optware bind mount requirement you can verify by invoking the mount command:

NAS> mount | grep @optware
/volume1/@optware on /opt type bind (bind)

Now reboot the NAS:

NAS> reboot

Managing packages
After a reboot, you can update the list of packages with:

NAS> ipkg update
Updated list of available packages in /opt/lib/ipkg/lists/cross
Successfully terminated.
You can list all packages with "ipkg list" or search specific packages with "ipkg list [wildcard]".

NAS> ipkg list cpu* 
cpufrequtils - 006-2 - To make access to the Linux kernel cpufreq subsystem easier for users and cpufreq userspace tools, a cpufrequtils package was c
Successfully terminated.

To install a package, simply type "ipkg install [name]". You may also browse the available packages by accessing the repository directly from within a browser.

NAS> ipkg install iperf
Installing iperf (2.0.4-1) to root...
Configuring iperf
Successfully terminated.

Removing packages is just as easy as installing:

NAS> ipkg remove iperf 
Removing package iperf from root...
Successfully terminated.

To make sure all installed Optware packages are up to date:

NAS> ipkg upgrade     
Upgrading grep on root from 2.7-1 to 2.8-1...
Configuring grep
update-alternatives: Linking //opt/bin/grep to /opt/bin/grep-grep
update-alternatives: Linking //opt/bin/egrep to /opt/bin/grep-egrep
update-alternatives: Linking //opt/bin/fgrep to /opt/bin/grep-fgrep
Successfully terminated.

Uninstalling Optware
To my knowledge, there isn't a one-liner for uninstalling the Optware system. It involves stopping the Optware service, unmounting the /opt bind mount, deleting the folder/files, editing the Linux service script and rebooting:

NAS> /etc/rc.optware stop
NAS> umount /opt
NAS> rm -rf /volume1/@optware
NAS> rm -f /etc/rc.optware
NAS> echo -e "#!/bin/sh\n" > /etc/rc.local
NAS> reboot

Note that the above wipes the rc.local script. If you have added custom stuff beyond just Optware, you should edit out the Optware stuff manually!

Of course, there aren't as many packages available as one would like, but it's still impressive that you can install Mono, Java, Python, Perl, Lua etc. on a small NAS device just with a single command. Hope this entry helps others get to hacking on their Synology device.

Post a Comment