Install Optware IPKG

From QNAPedia
Jump to: navigation, search

By installing Optware IPKG, you open the door to installing many other software packages by many different developers. QNAP supplies Ipkg as a QPKG plugin on many of their products. This is probably the easiest way to install for most. We also give instructions on manual install.

Simplified installation using QPKG

This is the simplified installation method using the QPKG update system firmware page with an Optware_Ipkg.qpkg file.

  1. First update your firmware to the latest build.
  2. In the device's Administration interface, select 'App Center'. In the App Center window, search for "Optware" using the search box at the top left, or click on the "Developer Tools" item in the left pane. An icon "Optware IPKG" appears. Click on the icon, and the App Center will install it.

Installation in firmware 3.2x

If you are using Firmware before version 4.x, your Administration Interface might not have an 'App Center'. The following instructions are appropriate for firmware 3.2.x, and may be appropriate for firmware as late as 3.8.x. (No editor of this article has checked on 3.6.x through 3.8.x yet.)

    • For firmware version 3.2x, select the 'System Tools' -> 'QPKG' page, click on 'Get QPKG' button.
    • If nothing is listed you must get the package from the appropriate download page on the QNAP website.
  1. Download 'Optware IPKG' package that matches your model.
  2. If the archive ends with a .zip extension, then unzip the downloaded archive to get a file with a .qpkg extension.
  3. If you're behind a proxy, put this in the /root/.wgetrc or in the /etc/wgetrc or in both:
http_proxy =
use_proxy = on

The install will fail if you don't do that.

  1. Now install the qpkg file. Go to the 'Installation' tab. Click the Browse button, and select the qpkg file. Click the OK button. A progress bar appears, then a confirmation dialog that the installation was successful.
    • Alternative: install it (.qpkg file) via the 'System Update' under your 'System Tools' page.
  2. If you get this error (check your mails!):

Optware 0.99.163 installation failed. /share/MD0_DATA/optware existed. Please remove it first.

ssh on the NAS and issue this command (use with care!!):

rm -rf /share/MD0_DATA/.qpkg/Optware
  1. Return to the 'QPKG Installed' tab. An icon with a penguin, and caption "Optware", should now be visible.
  2. Click the Optware icon or caption. A dialog "QPKG Plugins - QPKG - Optware" appears. At the bottom, it has buttons "Enable", "Disable", and "Remove".
  3. Click the "Enable" button. There is a pause, then the device gives you an alert box to confirm IPKG is enabled.
  4. Now Ssh into the admin account on your NAS device.
  5. As of April 2010, TS-219P Firmware 3.2.5 build 0409T has two bugs which require you to patch an initialisation file, /etc/init.d/ Follow the instructions in sections #Running_.2Fopt.2Fetc.2Finit.d.2F.2A_on_startup and #Fix_the_.24PATH_in_.2Fetc.2Fprofile below.
  6. Log out, and restart the NAS device to get the patches enforced.
  7. Confirm that ipkg is available. Ssh in again, and type: # ipkg --version. A message like ipkg version 0.99.163 appears. ipkg is now installed.

Continue to the article Using IPKG for instructions on what to do next.

Running /opt/etc/init.d/* on startup

Some, but not all, ipkg packages install startup scripts into /opt/etc/init.d/. These are to be run as part of system startup. As of April 2010, TS-219P Firmware 3.2.5 build 0409T does not run the scripts in this directory. This section explains how to patch the firmware to add this startup action.

The Optware QPKG creates an initialisation script and stores it in a QPKG Optware directory on your main data share. When the QNAP NAS device starts up, it adds a link to this script from /etc/rcS.d/. The name of this link is something like QS100Optware, where 100 is a sequence number that depends on how many QPKG packages you installed and in what order. This is what these files look like in TS-219P Firmware 3.2.5 build 0409T:

# ls -lFh /etc/init.d/*Optware* /etc/rcS.d/*Optware* /share/MD0_DATA/.qpkg/Optware/*Optware*
lrwxrwxrwx    1 admin    administ       40 Apr 19 16:02 /etc/init.d/ -> /share/MD0_DATA/.qpkg/Optware/*
lrwxrwxrwx    1 admin    administ       40 Apr 19 16:02 /etc/rcS.d/QS100Optware -> /share/MD0_DATA/.qpkg/Optware/*
-rwxr-xr-x    1 admin    administ     1.9k Feb 21 21:10 /share/MD0_DATA/.qpkg/Optware/*

Edit the install script. It's fine to get to it via one of its Symlinks:

vi /etc/init.d/

Look towards the end of the file for content like this:

case "$1" in
	# adding Ipkg apps into system path ...
	/bin/cat /etc/profile | /bin/grep "PATH" | /bin/grep "/opt/bin" 1>>/dev/null 2>>/dev/null
        [ $? -ne 0 ] && /bin/echo "export PATH=$PATH":/opt/bin:/opt/sbin >> /etc/profile


We will add a block of code just before the ;; stop) lines. The portion of the file now looks like the following:

case "$1" in
	# adding Ipkg apps into system path ...
	/bin/cat /etc/profile | /bin/grep "PATH" | /bin/grep "/opt/bin" 1>>/dev/null 2>>/dev/null
        [ $? -ne 0 ] && /bin/echo "export PATH=$PATH":/opt/bin:/opt/sbin >> /etc/profile

  # Patch per
  /bin/echo "Run Optware/ipkg /opt/etc/init.d/*"
  	source /etc/profile
        # Start all init scripts in /opt/etc/init.d
	# executing them in numerical order.
	# 11-May-2015 edit: added semi-colon to for-do statement otherwise script throws an error
	for i in /opt/etc/init.d/S??*; do
	    # Ignore dangling symlinks (if any).
    	    #[ ! -f "$i" ] && continue

            case "$i" in
	            # Source shell script for speed.
		        trap - INT QUIT TSTP
			set start
		        . $i
	    	    # No sh extension, so fork subprocess.
	    	    $i start
# End patch


Save the file and quit the editor.

Now, restart the QNAP NAS device. All Optware packages which need to run at startup time, should run automatically.

Because this code runs whatever scripts are in the /opt/etc/init.d/ directory, you do not need to modify it when you add or remove Optware packages. However, there's a likelihood that future QNAP firmware releases may overwrite This would require you to reapply this patch.

For further information:

Fix the $PATH in /etc/profile

The code that sets up the Optware environment should extend the $PATH environment variable, adding the Optware bin directories to the head of the path where they can preempt any equivalents that come with the QNAP firmware. It should also preserve the original path, with any modifications which other software made. As of April 2010, TS-219P Firmware 3.2.5 build 0409T does not do this correctly.

[note] In July 2010, firmware 3.4.3, we do not need to modify the "" as below.

There is a simple fix, to the same file we edited in the previous section.

Edit the file:

vi /etc/init.d/

Look for the section of code which mentions /opt/bin. Replace it so that this part of the file looks like:

	# adding Ipkg apps into system path ...
	/bin/cat /etc/profile | /bin/grep "PATH" | /bin/grep "/opt/bin" 1>>/dev/null 2>>/dev/null
        # Bug fix for following: put IPKG first, per
	# was [ $? -ne 0 ] && /bin/echo "export PATH=$PATH":/opt/bin:/opt/sbin >> /etc/profile
	[ $? -ne 0 ] && /bin/echo "export PATH=/opt/bin:/opt/sbin:\$PATH" >> /etc/profile

Save the file and quit the editor.

Now, restart the QNAP NAS device. In the admin shell, check the $PATH environment variable. /opt/bin and /opt/sbin should come before /bin and /usr/bin. For instance:

# echo $PATH

For further information:


  • Installing the package requires that the target device has internet access otherwise the installation will fail about 60% of the way through.
  • After a failed install you will not be able to reattempt the installation until you manually delete the Optware directory under /share/MD0_DATA/.qpkg. Failure to do this will result in an error message in the system log stating the package is already installed.
  • If you perform an installation through QPKG, get an installation successful alert, but ipkg doesn't appear in the 'QPKG Installed' tab, check to see if you installed a file with a .zip extension. QPKG cannot install ZIP archives. You must unzip the archive, and there should be a file with a .qpkg installation inside. You must install this .qpkg file.
  • If you install an Optware package, and it runs right after installation but fails to restart automatically when the server restarts, then check to see that the patch in #Running_.2Fopt.2Fetc.2Finit.d.2F.2A_on_startup above has been completed correctly.

Migrating from the previous installation (either automatic script or manual)

For migration from previous install (automatic/manual) to the QPKG'ed install, please see below:

  • umount all the mounts for your original IPKG install
# umount /share/MD0_DATA/optware/dev
# umount /share/MD0_DATA/optware/proc
# umount /share/MD0_DATA/optware/proc/bus/usb
# umount /share/MD0_DATA/optware/mnt/ext/Qmultimedia
# umount /share/MD0_DATA/optware/mnt/ext/Qdownload
# umount /share/MD0_DATA/optware/mnt/ext/Qweb
# umount /share/MD0_DATA/optware/mnt/ext/Qusb
# umount /share/MD0_DATA/optware/mnt/ext/Public
  • remove all the Ipkg-related entries in
# mount /dev/mtdblock5 /tmp/config
# vi /tmp/config/
  • remove these entries:
# Internet access... 
cp /etc/resolv.conf /share/MD0_DATA/optware/etc
cp /etc/hostname /share/MD0_DATA/optware/etc
# Timezone... 
cp /etc/TZ /share/MD0_DATA/optware/etc
# User/Group management... 
cp /etc/config/passwd /etc/config/group /etc/config/shadow /share/MD0_DATA/optware/etc
# sym-link /share/MD0_DATA/optware/opt to /opt
rm -rf /opt
ln -sf /share/MD0_DATA/optware/opt /opt
# Mount directories into chroot
mount -o bind /dev /share/MD0_DATA/optware/dev
mount -o bind /proc /share/MD0_DATA/optware/proc
mount -o bind /proc/bus/usb /share/MD0_DATA/optware/proc/bus/usb
mount -o bind /share/MD0_DATA/Qmultimedia /share/MD0_DATA/optware/mnt/ext/Qmultimedia
mount -o bind /share/MD0_DATA/Qmultimedia /share/MD0_DATA/optware/mnt/ext/Qdownload
mount -o bind /share/MD0_DATA/Qmultimedia /share/MD0_DATA/optware/mnt/ext/Qusb
mount -o bind /share/MD0_DATA/Qmultimedia /share/MD0_DATA/optware/mnt/ext/Qweb
mount -o bind /share/MD0_DATA/Qmultimedia /share/MD0_DATA/optware/mnt/ext/Public
# adding Ipkg apps into system path ...
export PATH=/opt/bin:/opt/sbin:$PATH 
  • save then close


  • rename /share/MD0_DATA/optware
mv /share/MD0_DATA/optware /share/MD0_DATA/
  • Install QPKGed IPKG according to the guide 'Automatic installation via QPKG' above (but do not enable it yet, or disable it if it was enabled after the install)


  • copy the IPKG start script to the old IPKG directory
# cp -af /share/MD0_DATA/optware/ /share/MD0_DATA/
  • Now remove the optware directory you've just install (Warning! make sure Optware_Ipkg is not enabled! or no mounts is present on any of the directories under the newly installed ipkg location, eg, /share/MD0_DATA/optware/mnt/ext/Public or /share/MD0_DATA/optware/share/Public, etc... Failed to do so will wipe all your data under /share/Public, /share/Qdownload, /share/Qmultimedia, /share/Qusb and /share/Qweb on your hard drive. you can check this by 'df' and see if any mount points are made under these locations.)
# rm -rf /share/MD0_DATA/optware
  • Rename the old IPKG folder name back
# mv /share/MD0_DATA/ /share/MD0_DATA/optware 
  • Now you may enable/disable your previous ipkg install from your QPKG admin page and use them as normal.

Manual installation

This is the manual installation method.

Create the required directories on the NAS

# mkdir -p /share/MD0_DATA/optware/opt
# mkdir /share/MD0_DATA/optware/ipkglib


  • For NAS running RAID (2 disks or above)
# cd /; ln -sf /share/MD0_DATA/optware/ipkglib /usr/lib/ipkg
  • For NAS running single disk (1 disk only)
# cd /; ln -sf /share/HDA_DATA/optware/ipkglib /usr/lib/ipkg

Create a symbolic link to /opt

Create a symbolic link to the Optware installation directory

# rm -rf /opt
# cd /; ln -sf /share/MD0_DATA/optware/opt /opt

Check if /opt is symlinked to /share/MD0_DATA/optware/opt (or /share/HDA_DATA/optware/opt)

# cd /
# ls -la

You should see :

opt -> /share/MD0_DATA/optware/opt/ 


opt -> /share/HDA_DATA/optware/opt/

Download and the ipkg file package

First, go to optware installation directory to avoid messing up free space on root partition then downloading the package

# cd /share/MD0_DATA/big-disk 
# wget 
# tar -xOvzf ipkg-opt_*_arm.ipk ./data.tar.gz | tar -C / -xzvf -


For PowerPC based devices (TS101/201) you should use instead.

Replace the filename for the ipkg file as appropriate in the command.

Edit /opt/etc/ipkg.conf

# vi /opt/etc/ipkg.conf

Add the line

src cs05q3armel

Save and close with ESC and :wq and enter

Update the package list :

# /opt/bin/ipkg update

You should see :

[/] # /opt/bin/ipkg update 
Updated list of available packages in /opt/lib/ipkg/lists/cs05q3armel 
Successfully terminated.

If there are errors or you do not see Downloading info that means that either you did not edit ipkg.conf mentioned before or hm.

Install applications (mc in this example)

Change to optware directory cause this ipkg left some strange files which makes / partition to small, i dont know if its an error or something

# cd /share/MD0_DATA/optware 
# /opt/bin/ipkg update 
# /opt/bin/ipkg install slang 
# /opt/bin/ipkg install mc --tmp-dir=/share/MD0_DATA/

And then to run mc


Preserve the configurations on reboot

Create the file

# mount /dev/mtdblock5 -t ext2 /tmp/config 
# cd /tmp/config 
# vi

Add to the following lines to the file then save and close

rm -rf /opt
ln -sf /share/MD0_DATA/optware/opt /opt
echo "export PATH=$PATH:/opt/bin:/opt/sbin" >> /etc/profile

Make executable and do not forget to unmount !

# chmod +x
# cd /
# umount /dev/mtdblock5

Note, for TS101/201 users, you should use /dev/mtdblock4 instead of /dev/mtdblock5.

Scripted Manual Installation

Note, this script is a starting point for your own scripts, but thought it might be useful. YMMV, please modify it to your liking and send me an email telling me about your cool improvements.
Note, Currently supports arm systems with RAID only, installs coreutils ipkg

echo "Coreutils setup script"
echo "by Jim Barstow <>"
start_time=`date "+%F %r"`
echo "Coreutils setup started at ${start_time}"

echo -n "Checking for RAID mount point... "
if [ ! -d "/share/MD0_DATA/" ]; then
  echo "FAIL: RAID mount point not found."
  exit 1
  echo "OK"

echo -n "Creating required directories... "
if [ ! -d "${opt_mountpoint}/optware/opt" ]; then
  mkdir -p ${opt_mountpoint}/optware/opt
if [ ! -d "${opt_mountpoint}/optware/ipkglib" ]; then
  mkdir ${opt_mountpoint}/optware/ipkglib
if [ -d "${opt_mountpoint}/optware/opt/" -a -d "${opt_mountpoint}/optware/ipkglib" ]; then
  echo "OK"
  echo "FAIL: required directories could not be created."
  exit 1

echo -n "Symlinking ipkg to /usr/lib/ipkg... "
cd /; ln -sf ${opt_mountpoint}/optware/ipkglib /usr/lib/ipkg
echo "OK"

echo -n "Symlinking /opt... "
if [ -d "/opt" ]; then
  mv /opt /opt.bak
  rm -rf /opt
cd /; ln -sf ${opt_mountpoint}/optware/opt /opt
echo "OK"

echo -n "Updating path to include /opt/bin... "
export PATH=/opt/bin:$PATH
echo "OK"

echo -n "Verifying/Creating sources location... "
if [ ! -d "${opt_mountpoint}/opt_sources/" ]; then
  mkdir ${opt_mountpoint}/opt_sources
if [ ! -d "${opt_mountpoint}/opt_sources/" ]; then
  echo "FAIL: sources location could not be created."
  exit 1
  echo "OK"

echo -n "Verifying system type is ARM... "
sys_type=`uname -m`
if [[ "${sys_type}"=="armv5tel" ]]; then
  echo "OK"
  echo "FAIL: got system type ${sys_type}."
  exit 1

echo -n "Downloading ipkg source... "
cd ${opt_mountpoint}/opt_sources/
wget -q
if [ -f "${opt_mountpoint}/opt_sources/ipkg-opt_0.99.163-10_arm.ipk" ]; then
  echo "OK"
  echo "FAIL: could not download ipkg source."
  exit 1

echo -n "Extracting ipkg source... "
tar -xOzf ipkg-opt_*_arm.ipk ./data.tar.gz | tar -C / -xzf -
echo "OK"

echo -n "Configuring ipkg... "
ipkg_src=`cat /opt/etc/ipkg.conf | grep "src cs05q3armel"`
if [ -z "$ipkg_src" ]; then
  echo "src cs05q3armel" >>/opt/etc/ipkg.conf
  echo "OK"
  echo "OK"

echo -n "Updating ipkg... "
/opt/bin/ipkg update -V0
echo "OK"

echo -n "Installing coreutils... "
cd ${opt_mountpoint}/optware
/opt/bin/ipkg update -V0
/opt/bin/ipkg install -V0 coreutils
echo "OK"

echo -n "Symlinking coreutils-nohup to /usr/bin/nohup... "
ln -sf /opt/bin/coreutils-nohup /usr/bin/nohup
if [ -f "/usr/bin/nohup" ]; then
  echo "OK"
  echo "FAIL: could not symlink /usr/bin/nohup."
  exit 1

end_time=`date "+%F %r"`
echo "Coreutils setup completed at ${end_time}"