Giuseppe Parrello

 

How to install Entware on a NAS device


In this section I describe how to install Entware on a NAS device (Synology DS412+).
Firstly we access the NAS via SSH or Telnet. We create a new folder on "volume1" of the first disk (where Synology's DSM is installed), we remove the old "/opt" folder (in following example "/opt" folder does not exist), and we link the "/opt" folder to the new created folder :

root@DS412:~# mkdir -p /volume1/@entware/opt
root@DS412:~# rm -rf /opt
rm: cannot remove ‘/opt’: Device or resource busy
root@DS412:~# mkdir -p /opt
root@DS412:~# mount -o bind /volume1/@entware/opt /opt

Now we have to know the correct Entware's platform to use, according to NAS device we have. Firstly we have to know all the basics informations of NAS :

root@DS412:~# uname -a
Linux DS412 3.10.35 #5967 SMP Fri Nov 3 17:20:59 CST 2017 x86_64 GNU/Linux synology_cedarview_412+

In the following table we can know all the output's form - for Synology devices we can have additional informations on this website :

OutputMeaning
LinuxOperating System's name
DS412Host's name
3.10.35Operating System's release
#5967 SMP Fri Nov 3 17:20:59 CST 2017Operating System's version
x86_64The machine (hardware) type
GNU/LinuxOperating System
synology_cedarview_412+Synology's Hardware Architecture

Briefly we can know the current Hardware Type with following command line :

root@DS412:~# uname -m
x86_64

Briefly we can know the current Kernel version with following command line :

root@DS412:~# uname -r
3.10.35

Then we open a browser, we go to this website and we find some subfolders, we have to choose one of those folders in order to install Entware. This is the list of the most important subfolders we can have, please be careful to choose the proper subfolder according to above-mentioned output for Hardware Type and Kernel version :

SubfolderHardware Type + Kernel versionSynology's Package Arch
aarch64-k3.10armv8 - kernel 3.10 and higherrtd1296
armv5sf-k3.2armv5 - kernel 3.2 and higher88f628x
armv7sf-k2.6armv7 - kernel 2.6.36 and higher 
armv7sf-k3.2armv7 - kernel 3.2 and higherArmada*, Alpine*, Comcerto*
mipselsf-k3.4mipsel - kernel 3.4 and higher 
mipssf-k3.4mips - kernel 3.4 and higher 
x64-k3.2x86_64 - kernel 3.2 and higherAll Intel CPU Models except X86

For device Synology DS412+ we have to choose "x64-k3.2" subfolder, so we execute the following command line in order to install Entware (instead you have to replace "x64-k3.2" with your subfolder) :

root@DS412:~# wget -O - http://bin.entware.net/x64-k3.2/installer/generic.sh | /bin/sh

--2018-06-06 10:56:50-- http://bin.entware.net/x64-k3.2/installer/generic.sh
Resolving bin.entware.net... 81.4.123.217
Connecting to bin.entware.net|81.4.123.217|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2208 (2.2K) [application/octet-stream]
Saving to: 'STDOUT'
Info: Checking for prerequisites and creating folders...
Warning: Folder /opt exists!
2018-06-06 10:56:50 (125 KB/s) - written to stdout [2208/2208]

Info: Opkg package manager deployment...
--2018-06-06 10:56:50-- http://bin.entware.net/x64-k3.2/installer/opkg
Resolving bin.entware.net... 81.4.123.217
Connecting to bin.entware.net|81.4.123.217|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 158016 (154K) [application/octet-stream]
Saving to: '/opt/bin/opkg'
2018-06-06 10:56:51 (796 KB/s) - '/opt/bin/opkg' saved [158016/158016]

--2018-06-06 10:56:51-- http://bin.entware.net/x64-k3.2/installer/opkg.conf
Resolving bin.entware.net... 81.4.123.217
Connecting to bin.entware.net|81.4.123.217|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 182 [application/octet-stream]
Saving to: '/opt/etc/opkg.conf'
2018-06-06 10:56:51 (9.48 KB/s) - '/opt/etc/opkg.conf' saved [182/182]

--2018-06-06 10:56:51-- http://bin.entware.net/x64-k3.2/installer/ld-2.27.so
Resolving bin.entware.net... 81.4.123.217
Connecting to bin.entware.net|81.4.123.217|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 157488 (154K) [application/octet-stream]
Saving to: '/opt/lib/ld-2.27.so'
2018-06-06 10:56:51 (662 KB/s) - '/opt/lib/ld-2.27.so' saved [157488/157488]

--2018-06-06 10:56:51-- http://bin.entware.net/x64-k3.2/installer/libc-2.27.so
Resolving bin.entware.net... 81.4.123.217
Connecting to bin.entware.net|81.4.123.217|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1759664 (1.7M) [application/octet-stream]
Saving to: '/opt/lib/libc-2.27.so'
2018-06-06 10:56:52 (1.65 MB/s) - '/opt/lib/libc-2.27.so' saved [1759664/1759664]

--2018-06-06 10:56:52-- http://bin.entware.net/x64-k3.2/installer/libgcc_s.so.1
Resolving bin.entware.net... 81.4.123.217
Connecting to bin.entware.net|81.4.123.217|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 92560 (90K) [application/octet-stream]
Saving to: '/opt/lib/libgcc_s.so.1'

--2018-06-06 10:56:53-- http://bin.entware.net/x64-k3.2/installer/libpthread-2.27.so
Resolving bin.entware.net... 81.4.123.217
Connecting to bin.entware.net|81.4.123.217|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 106152 (104K) [application/octet-stream]
Saving to: '/opt/lib/libpthread-2.27.so'

2018-06-06 10:56:53 (734 KB/s) - '/opt/lib/libpthread-2.27.so' saved [106152/106152]

Info: Basic packages installation...
Downloading http://bin.entware.net/x64-k3.2/Packages.gz
Updated list of available packages in /opt/var/opkg-lists/entware
Installing entware-opt (227000-3) to root...
Downloading http://bin.entware.net/x64-k3.2/entware-opt_227000-3_all.ipk
Installing libc (2.27-8) to root...
Downloading http://bin.entware.net/x64-k3.2/libc_2.27-8_x64-3.2.ipk
Installing libgcc (7.3.0-8) to root...
Downloading http://bin.entware.net/x64-k3.2/libgcc_7.3.0-8_x64-3.2.ipk
Installing libssp (7.3.0-8) to root...
Downloading http://bin.entware.net/x64-k3.2/libssp_7.3.0-8_x64-3.2.ipk
Installing librt (2.27-8) to root...
Downloading http://bin.entware.net/x64-k3.2/librt_2.27-8_x64-3.2.ipk
Installing libpthread (2.27-8) to root...
Downloading http://bin.entware.net/x64-k3.2/libpthread_2.27-8_x64-3.2.ipk
Installing libstdcpp (7.3.0-8) to root...
Downloading http://bin.entware.net/x64-k3.2/libstdcpp_7.3.0-8_x64-3.2.ipk
Installing entware-release (1.0-2) to root...
Downloading http://bin.entware.net/x64-k3.2/entware-release_1.0-2_all.ipk
Installing zoneinfo-asia (2018e-1) to root...
Downloading http://bin.entware.net/x64-k3.2/zoneinfo-asia_2018e-1_x64-3.2.ipk
Installing zoneinfo-europe (2018e-1) to root...
Downloading http://bin.entware.net/x64-k3.2/zoneinfo-europe_2018e-1_x64-3.2.ipk
Installing findutils (4.6.0-1) to root...
Downloading http://bin.entware.net/x64-k3.2/findutils_4.6.0-1_x64-3.2.ipk
Installing terminfo (6.1-1) to root...
Downloading http://bin.entware.net/x64-k3.2/terminfo_6.1-1_x64-3.2.ipk
Installing locales (2.27-8) to root...
Downloading http://bin.entware.net/x64-k3.2/locales_2.27-8_x64-3.2.ipk
Installing grep (2.26-1) to root...
Downloading http://bin.entware.net/x64-k3.2/grep_2.26-1_x64-3.2.ipk
Installing libpcre (8.41-2) to root...
Downloading http://bin.entware.net/x64-k3.2/libpcre_8.41-2_x64-3.2.ipk
Installing opkg (2011-04-08-9c97d5ec-17b) to root...
Downloading http://bin.entware.net/x64-k3.2/opkg_2011-04-08-9c97d5ec-17b_x64-3.2.ipk
Installing entware-upgrade (1.0-1) to root...
Downloading http://bin.entware.net/x64-k3.2/entware-upgrade_1.0-1_all.ipk
Configuring libgcc.
Configuring libc.
Configuring libssp.
Configuring libpthread.
Configuring librt.
Configuring terminfo.
Configuring libpcre.
Configuring grep.
Configuring locales.
Entware uses separate locale-archive file independent from main system
Creating locale archive - /opt/usr/lib/locale/locale-archive
Adding en_EN.UTF-8
Adding ru_RU.UTF-8
You can download locale sources from http://pkg.entware.net/sources/i18n_glib227.tar.gz
You can add new locales to Entware using /opt/bin/localedef.new
Configuring entware-upgrade.
Upgrade operations are not required
Configuring opkg.
Configuring zoneinfo-europe.
Configuring zoneinfo-asia.
Configuring libstdcpp.
Configuring entware-release.
Configuring findutils.
Configuring entware-opt.
Info: Congratulations!
Info: If there are no errors above then Entware was successfully initialized.
Info: Add /opt/bin & /opt/sbin to your PATH variable
Info: Add '/opt/etc/init.d/rc.unslung start' to startup script for Entware services to start
Info: Found a Bug? Please report at https://github.com/Entware/Entware/issues

Now we have to create a script that our NAS must execute whenever it is restarted.
Firstly we must create the following file "/etc/rc.entware" :

#! /bin/sh

if test -z "${REAL_OPT_DIR}"; then
   REAL_OPT_DIR=/volume1/@entware/opt
fi

case "$1" in
     start)
          echo "Starting Entware."
          if test -n "${REAL_OPT_DIR}"; then
               if ! grep ' /opt ' /proc/mounts >/dev/null 2>&1 ; then
                    mkdir -p /opt
                    mount -o bind ${REAL_OPT_DIR} /opt
                    /opt/etc/init.d/rc.unslung start
               fi
          fi
     ;;
     reconfig)
          true
     ;;
     stop)
          echo "Shutting down Entware."
          true
     ;;
     *)
          echo "Usage: $0 {start|stop|reconfig}"
          exit 1
esac

exit 0

In the above-mentioned file, the line "/opt/etc/init.d/rc.unslung start" is required to automatically start the Entware services. If you do not want to automatically start the Entware services, you can remove that line. Eventually instead of that line, you can manually insert the services to be started during boot.
Then we add the following single line to file "/etc/rc.local" - if this file does not exist, we create it :

#!/bin/sh

[ -x /etc/rc.entware ] && /etc/rc.entware start

exit 0

Now we have to add the folders "/opt/bin" and "/opt/sbin" at the end of the PATH environment variable, using one of the files "/root/.profile" or "/etc/profile" ("/etc/profile" for DSM6), this is an example of PATH line:

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin:/opt/bin:/opt/sbin
export PATH

Please do not add the above-mentioned folders at the beginning of the PATH line to avoid any problems for NAS device. Remember that Entware is just an additional environment for the NAS, so it is better to let NAS find its own files inside the standard PATH folders before Entware folders.
Please reboot the NAS device so to test all the changes you have done.
After rebooting the NAS device, we can install all the Entware packages we need, for example if we want to install "Nano" editor, we can use the command "opkg install nano".

root@DS412:~# opkg install nano
Installing nano (2.9.6-1) to root...
Downloading http://bin.entware.net/x64-k3.2/nano_2.9.6-1_x64-3.2.ipk
Installing libncursesw (6.1-1) to root...
Downloading http://bin.entware.net/x64-k3.2/libncursesw_6.1-1_x64-3.2.ipk
Installing zlib (1.2.11-2) to root...
Downloading http://bin.entware.net/x64-k3.2/zlib_1.2.11-2_x64-3.2.ipk
Installing file (5.25-2) to root...
Downloading http://bin.entware.net/x64-k3.2/file_5.25-2_x64-3.2.ipk
Installing libmagic (5.25-2) to root...
Downloading http://bin.entware.net/x64-k3.2/libmagic_5.25-2_x64-3.2.ipk
Configuring libncursesw.
Configuring zlib.
Configuring libmagic.
Configuring file.
Configuring nano.

To update all packages we will use the two commands "opkg update" and "opkg upgrade" (the first command updates the Internet source of packages, the second one upgrades only the updated packages). We need to take care about the upgrade of packages, because it is happened to me in the past that some configurations files (changed by me) were overwritten by the default configuration files. My suggestion is to make a backup of all "/opt" folder before upgrading the packages (but also periodically in order to have a backup copy of Entware installation whenever we need to restore some files).
Another my suggestion is to use the parameter "--noaction" with the command "opkg upgrade", in this way we may see a simulation (testing) of the upgrading procedure, just to know in advance which packages will be upgraded, which files will be overwritten and if there is something we have to do in advance in order to have a full-functional Entware environment after upgrading the packages.

This is a sample output of command "opkg update":

root@DS412:~# opkg update

Downloading http://bin.entware.net/x64-k3.2/Packages.gz
Updated list of available packages in /opt/var/opkg-lists/entware

This is a sample output of command "opkg --help":

root@DS412:~# opkg --help

usage: opkg [options...] sub-command [arguments...]
where sub-command is one of:

Package Manipulation:
	update 		 	Update list of available packages
	upgrade 	 	Upgrade installed packages
	install <pkgs> 	 	Install package(s)
	configure <pkgs> 	Configure unpacked package(s)
	remove <pkgs|regexp> 	Remove package(s)
	flag <flag> <pkgs> 	Flag package(s)
	 <flag>=hold|noprune|user|ok|installed|unpacked (one per invocation)

Informational Commands:
	list			List available packages
	list-installed 		List installed packages
	list-upgradable 	List installed and upgradable packages
	list-changed-conffiles 	List user modified configuration files
	files <pkg> 		List files belonging to <pkg>
	search <file|regexp> 	List package providing <file>
	find <regexp> 		List packages whose name or description matches <regexp>
	info [pkg|regexp] 	Display all info for <pkg>
	status [pkg|regexp] 	Display all status for <pkg>
	download <pkg> 		Download <pkg> to current directory
	compare-versions 	<v1> <op> <v2>
				compare versions using <= < > >= = << >>
	print-architecture 	List installable package architectures
	depends [-A] [pkgname|pat]+
	whatdepends [-A] [pkgname|pat]+
	whatdependsrec [-A] [pkgname|pat]+
	whatrecommends[-A] [pkgname|pat]+
	whatsuggests[-A] [pkgname|pat]+
	whatprovides [-A] [pkgname|pat]+
	whatconflicts [-A] [pkgname|pat]+
	whatreplaces [-A] [pkgname|pat]+

Options:
	-A 			Query all packages not just those installed
	-V[<level>] 		Set verbosity level to <level>.
	--verbosity[=<level>] 	Verbosity levels:
					0 errors only
					1 normal messages (default)
					2 informative messages
					3 debug
					4 debug level 2
	-f <conf_file> 		Use <conf_file> as the opkg configuration file
	--conf <conf_file>
	--cache <directory> 	Use a package cache
	-d <dest_name> 		Use <dest_name> as the the root directory for
	--dest <dest_name> 	package installation, removal, upgrading.
				<dest_name> should be a defined dest name from
				the configuration file, (but can also be a
				directory name in a pinch).
	-o <dir> 		 Use <dir> as the root directory for
	--offline-root <dir> 	 offline installation of packages.
	--add-arch <arch>:<prio> Register architecture with given priority
	--add-dest <name>:<path> Register destination with given path
	
Force Options:
	--force-depends		Install/remove despite failed dependencies
	--force-maintainer	Overwrite preexisting config files
	--force-reinstall	Reinstall package(s)
	--force-overwrite	Overwrite files from other package(s)
	--force-downgrade	Allow opkg to downgrade packages
	--force-space		Disable free space checks
	--force-postinstall	Run postinstall scripts even in offline mode
	--force-remove		Remove package even if prerm script fails
	--force-checksum	Don't fail on checksum mismatches
	--noaction		No action -- test only
	--download-only		No action -- download only
	--nodeps		Do not follow dependencies
	--nocase		Perform case insensitive pattern matching
	--size			Print package size when listing available packages
	--force-removal-of-dependent-packages
				Remove package and all dependencies
	--autoremove		Remove packages that were installed
				automatically to satisfy dependencies
	-t			Specify tmp-dir.
	--tmp-dir		Specify tmp-dir.
	-l			Specify lists-dir.
	--lists-dir		Specify lists-dir.

 regexp could be something like 'pkgname*' '*file*' or similar
 e.g. opkg info 'libstd*' or opkg search '*libop*' or opkg remove 'libncur*'