Giuseppe Parrello

 

How to install Entware on a router


In this section I describe how to install Entware on a router (Asus RT-AC56U).
Firstly almost all Asus routers come with a built-in Optware package manager. This package manager is outdated, all packages are not updated anymore. For this reason, a new package manager (Entware) has been created in order to replace Optware. Unfortunately Entware and Optware share some libraries, so we cannot install them at the same time. Some features of Asus routers are not compatible with Entware packages, for example "Media Server", "Asus AiCloud" and "Download Master". Until these packages are built-in in the router, they are still available, while if they are installed into an external drive, they must work only with Optware as they are not compatible with Entware (we cannot mix the libraries of Entware with the libraries of Optware). While "Media Server" and "Download Master" may be replaced with some Entware's packages (for example respectively with "Minidlna" and "Transmission"), "Asus AiCloud" cannot be directly replaced, so we have to consider this matter before upgrading to Entware.
The first step of upgrading to Entware is to install a router's built-in package, for example "Download Master". We use an external drive (for example USB Pendrive), we format it using ext2/ext3 file system, we insert it into router's USB socket, and we install "Download Master". After doing this, we uninstall "Download Master" (we don't need it anymore). In this way the router has created a folder into the external drive, this folder name depends on the router we are using (for example for RT-AC56U this folder is named "asusware.arm"). After doing this, we open Telnet, we go to "/opt" folder and we delete all files included in that folder, except the file ".asusrouter" as this file is used by the router to mount the "/opt" folder. Now the "/opt" folder is empty (except the file ".asusrouter").
Now we have to know the correct Entware's platform to use, according to router we have. Firstly we have to know all the basics informations of router :

root@RT-AC56U:/# uname -a
Linux RT-AC56U 2.6.36.4brcmarm #19 SMP PREEMPT Wed Apr 19 16:20:58 CEST 2017 armv7l GNU/Linux

In the following table we can know all the output :

OutputMeaning
LinuxOperating System's name
RT-AC56UDevice's name
2.6.36.4brcmarmOperating System's release
#19 SMP PREEMPT Wed Apr 19 16:20:58 CEST 2017Operating System's version
armv7lThe machine (hardware) type
GNU/LinuxOperating System

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

root@RT-AC56U:/# uname -m
armv7l

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

root@RT-AC56U:/# uname -r
2.6.36.4brcmarm

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 version
aarch64-k3.10armv8 (ARM 64 bit) - kernel 3.10 and higher
armv5sf-k3.2armv5 - kernel 3.2 and higher
armv7sf-k2.6armv7 - kernel 2.6.36 and higher
armv7sf-k3.2armv7 - kernel 3.2 and higher
mipselsf-k3.4mipsel - kernel 3.4 and higher
mipssf-k3.4mips - kernel 3.4 and higher
x64-k3.2x86_64 - kernel 3.2 and higher
x86-k2.6x86 - kernel 2.6 and higher

Once the proper subfolder is selected, we must select the "installer" subfolder and download the "generic.sh" script. For example for the Asus RT-AC56U router we select the subfolder "armv7sf-k2.6":

root@RT-AC56U:/# cd /tmp

root@RT-AC56U:/tmp# wget http://bin.entware.net/armv7sf-k2.6/installer/generic.sh
Connecting to bin.entware.net (104.27.177.50:80)
generic.sh           100% |*********************************|  2205   0:00:00 ETA

root@RT-AC56U:/tmp# chmod +x generic.sh

After download the above-mentioned script, we have to execute it. This is a sample output of above-mentioned script:

root@RT-AC56U:/tmp# ./generic.sh

Info: Checking for prerequisites and creating folders...
Warning: Folder /opt exists!
Warning: If something goes wrong please clean /opt folder and try again.
Info: Opkg package manager deployment...
Connecting to pkg.entware.net (81.4.123.217:80)
opkg                 100% |**************************|   124k  0:00:00 ETA
Connecting to pkg.entware.net (81.4.123.217:80)
opkg.conf            100% |**************************|   142   0:00:00 ETA
Connecting to pkg.entware.net (81.4.123.217:80)
ld-2.23.so           100% |**************************|   139k  0:00:00 ETA
Connecting to pkg.entware.net (81.4.123.217:80)
libc-2.23.so         100% |**************************|  1198k  0:00:00 ETA
Connecting to pkg.entware.net (81.4.123.217:80)
libgcc_s.so.1        100% |**************************| 39632   0:00:00 ETA
Info: Basic packages installation...
Downloading http://pkg.entware.net/binaries/armv7/Packages.gz.
Updated list of available packages in /opt/var/opkg-lists/packages.
Installing entware-opt (222108-5) to root...
Downloading http://pkg.entware.net/binaries/armv7/entware-opt_222108-5_armv7soft.ipk.
Installing libc (2.23-6) to root...
Downloading http://pkg.entware.net/binaries/armv7/libc_2.23-6_armv7soft.ipk.
Installing libgcc (6.3.0-6) to root...
Downloading http://pkg.entware.net/binaries/armv7/libgcc_6.3.0-6_armv7soft.ipk.
Installing libssp (6.3.0-6) to root...
Downloading http://pkg.entware.net/binaries/armv7/libssp_6.3.0-6_armv7soft.ipk.
Installing librt (2.23-6) to root...
Downloading http://pkg.entware.net/binaries/armv7/librt_2.23-6_armv7soft.ipk.
Installing libpthread (2.23-6) to root...
Downloading http://pkg.entware.net/binaries/armv7/libpthread_2.23-6_armv7soft.ipk.
Installing libstdcpp (6.3.0-6) to root...
Downloading http://pkg.entware.net/binaries/armv7/libstdcpp_6.3.0-6_armv7soft.ipk.
Installing ldconfig (2.23-6) to root...
Downloading http://pkg.entware.net/binaries/armv7/ldconfig_2.23-6_armv7soft.ipk.
Installing findutils (4.6.0-1) to root...
Downloading http://pkg.entware.net/binaries/armv7/findutils_4.6.0-1_armv7soft.ipk.
Installing terminfo (6.0-1c) to root...
Downloading http://pkg.entware.net/binaries/armv7/terminfo_6.0-1c_armv7soft.ipk.
Installing locales (2.23-6) to root...
Downloading http://pkg.entware.net/binaries/armv7/locales_2.23-6_armv7soft.ipk.
Installing opkg (2011-04-08-9c97d5ec-17) to root...
Downloading http://pkg.entware.net/binaries/armv7/opkg_2011-04-08-9c97d5ec-17_armv7soft.ipk.
Configuring libgcc.
Configuring libc.
Configuring libssp.
Configuring libpthread.
Configuring librt.
Configuring terminfo.
Configuring ldconfig.
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_glib223.tar.gz
You can add new locales to Entware using /opt/bin/localedef.new
Configuring opkg.
Configuring libstdcpp.
Configuring findutils.
Configuring entware-opt.
Updating /opt/etc/ld.so.cache... done.
Info: Congratulations!
Info: If there are no errors above then Entware-ng 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-ng services to start
Info: Found a Bug? Please report at https://github.com/Entware-ng/Entware-ng/issues

We can use the command "opkg --help" to see if we have properly installed Entware on the router.
If we give a look to above-mentioned output, we note the line "Info: Add /opt/bin & /opt/sbin to your PATH variable". We do not need to add these folders to the PATH variable as these folders are automatically added into PATH variable by the router whenever "/opt" folder is mounted. We also note the line "Info: Add '/opt/etc/init.d/rc.unslung start' to startup script for Entware-ng services to start". We consider this line if we want to execute a script whenever we insert the USB external drive. Normally on Asus router the services are automatically enabled due to some features of Optware, these features allow to execute services included in folder "/opt/etc/init.d". Unfortunately with Entware we have to use another way to automatically execute a script after mounting the "/opt" folder. We are lucky to see that router included a "nvram" key in order to automatically execute a script. This key is named "script_usbmount", normally this key is empty. For example if we want to use the script "/opt/etc/autorun.sh", we have to write the following commands:
nvram set script_usbmount=/opt/etc/autorun.sh
nvram commit
To check the above-command, we have to write:
nvram show | grep -i autorun.sh
It returns:
script_usbmount=/opt/etc/autorun.sh
Inside the above-mentioned script file "autorun.sh" we can enable services (remember that services' scripts are in folder "/opt/etc/init.d") or execute other scripts or commands.
There is another "nvram" key called "script_usbumount", this key is similar to the above-mentioned key "script_usbmount" but its value is used before the USB external drive is to be unmounted, in this way we can stop services or execute other scripts or commands before removing the USB external drive.
After installing Entware, we can install all the packages we need, for example if we want to install "Nano" editor, we can use the command "opkg install nano". Note that the command for Entware is "opkg", while we used "ipkg" command for Optware. The syntax of "opkg" command is similar to the syntax of "ipkg" command, so we do not need to start over.
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@RT-AC56U:/tmp# opkg update

Downloading http://bin.entware.net/armv7sf-k2.6/Packages.gz
Updated list of available packages in /opt/var/opkg-lists/entware

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

root@RT-AC56U:/tmp# 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*'