Entware Installation on DD-WRT
This is a quick bullet list of steps to install Entware on DD-WRT
History
Entware's origins can be traced back to Optware and the Linksys NSLU2 NAS
Introduction
I've seen a bunch of different tutorials on installing Entware, many quite good. The intent of this guide is to provide a quick step by step set of instructions. It is assumed that readers are experienced users as granular detailed instructions are not provided (but you can Google them if you don't know how to do it.
Hardware
Hardware: Buffalo WZR-600DHP with 128 MB of RAM, 32 MB of non-volatile Flash Memory, gigabit switch, and a USB port with a MIPS based CPU and Atheros Wireless Chipset
These installation instructions should work for any hardware that can be flashed with DD-WRT and has a USB Port.
Instructions
- Flash the router with DD-WRT firmware (see, I wasn't kidding about not providing granular instructions), make sure it has internet access and that you have command line access via telnet or SSH.
- Plug in a USB Flash Drive or USB mechanical disk drive or SSD. I prefer a Flash Drive. I also prefer formatting the drive with two primary partitions, a small one for the Entware OS and a large one for general file storage. Formatting with NTFS means that the drive can be plugged into a Windows computer to retrieve anything stored there (Windows has no built in method of reading EXT2 partitions). The other smaller partition I prefer to format as an EXT2 partition. It's simple, fast, and EXT3 doesn't provide any advantages in this instance. The Entware partition can be small, but I like to think about future expansion so on a large disk or flash drive I allocate 8 GB to it. And remember, you can't partition and format with any built in DD-WRT commands. Most websites that note that end the conversation there, which I find depressing as there is no satisfactory conclusion. I discovered several tutorials about a minimal size version of Entware that can be installed on a JFFS partition (if your router supports that) which will then in turn allow you to download the tools needed to partition and format. Still looking for where I found it as of the writing of this, but haven't located it. Try a Google search with: entware minimal install jffs.
Special Note in regards to the above bullet point: Make sure Entware is installed on an EXT2 partition. Installing it on an NTFS partition doesn't allow things to work correctly (mount points, etc.)
- To make things easier, make sure the stock DD-WRT firmware has the drive mounted as /opt via the GUI interface. Quick Tip: If you do as I do with the multiple partition setup, put the EXT2 partition first and the NTFS partition last. The reason is that DD-WRT only mounts the first partition via the GUI interface. This is important, which is why I wrote it twice.
- Download the Entware installer (use WGET or share out the /opt directory to a Windows computer and copy it there) from their repository for the hardware your router is based on (look for a file named "generic.sh" in a sub-directory named "installer": http://bin.entware.net/
- Change the permissions on the installation script file: chmod 777 generic.sh (you could set it something to less permissive, but typing 777 is faster and the script can be deleted after Entware Installation)
- Run the script: ./generic.sh (it should download all of the necessary files and install it in the /opt directory (which is your disk or flash drive). Be patient as it might take a couple of minutes, depending on your router's CPU speed, to unpack everything and install it.
- And now it works. NOT! One of the final output lines of the installation script says something like "Congratulations...", but before that is are a couple of lines about changing or adding to the $PATH variable. If you check the $PATH variable after installation it will show that the "/opt paths" where Entware is installed are in the path. But there's a problem. They're at the end of the path which means any binaries or programs that are included with the DD-WRT firmware will be used before the Entware versions. The result is that stuff just doesn't work from the command line properly. Even changing the $PATH variable with: export PATH=/opt/bin:/opt/sbin:/opt/usr/sbin:/opt/usr/bin will not help the situation after a reboot. Simply setting the $PATH variable in a startup script via the GUI won't help either in terms of issuing Entware commands at the command line. WTF!? It has to do with the "profile" variable (DD-WRT default path: /etc/profile).
- Solution for the above mentioned problem? Create a file in the /opt Directory named ModifiedProfile (or anything you want) using VI (and copy and paste the below code) or copy an existing script file, then edit the contents (erase original contents and paste the below code) and save it. I share the /opt directory, access it via Windows, and edit it with TextPad. But do NOT create a script file via a Windows share (see Other Thoughts below), because it won't work with BASH.
export PATH=/opt/bin:/opt/sbin:/opt/usr/sbin:/opt/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin:/jffs/sbin:/jffs/bin:/jffs/usr/sbin:/jffs/usr/bin:/mmc/sbin:/mmc/bin:/mmc/usr/sbin:/mmc/usr/bin
export LD_LIBRARY_PATH=/lib:/usr/lib:/jffs/lib:/jffs/usr/lib:/jffs/usr/local/lib:/mmc/lib:/mmc/usr/lib:/opt/lib:/opt/usr/lib
export PS1='\u@\h:\w\$ '
reboot() {
for f in /opt/etc/init.d/S*
do
[ -x "$f" ] && "$f" stop
done
echo "#!/bin/sh" > /tmp/.rc_shutdown
echo "$(nvram get rc_shutdown)" >> /tmp/.rc_shutdown
if [ -f /tmp/.rc_shutdown ]; then
chmod +x /tmp/.rc_shutdown
/tmp/.rc_shutdown
fi
/sbin/reboot
}
service() {
[ -f "/opt/etc/init.d/$1" ] || {
echo "Typing the SERVICE command with no additional parameters displays a list of available services;"
ls "/opt/etc/init.d"
return 1
}
/opt/etc/init.d/$@
}
- Next, save the following as a StartUp Script;
mount -o bind /opt/ModifiedProfile /etc/profile
sleep 1
/opt/etc/profile
- I know I said I wouldn't explain things in
OpenWRT Choice
Of course you could always install OpenWRT instead of DD-WRT and none of the above is necessary. But that opens a whole new can of worms with different problems. For instance, installing the latest (as of 1.2020) version of OpenWRT on a Linksys WRT3200ACM router, which is at the very top end of DD-WRT / OpenWRT hardware, there is no facility within the GUI as it is initially installed to mount, share, or do anything with a USB or eSATA drive. All of that functionality, which has to be added to OpenWRT via a command line is available from DD-WRT right out of the box. Once you know what you're doing, both firmware choices are equally configurable, in an equally easy fashion, in their own unique ways, each with their own advantages and disadvantages. Apples and Oranges. Your choice.
Other Thoughts
If you're like me and working from Windows and also like to take advantage of all those nice little GUI perks like network file sharing (SAMBA in the linux) world, there's one thing (well, lots, but just pointing out one here) to watch out for. Do not create a script file in Windows via a shared network directory on the router and expect it to run as a bash login script. It won't work. Also there are differences in text files including 'carriage return / line feed' in Windows and just 'line feed' in Linux among several others that will prevent the Linux OS from "reading" the script file properly, so don't edit in notepad. Once the file is created in Linux (or copied from another Linux OS) editors like TextPad work great.
Even though it never seems to be explicitly stated, NVRAM and JFFS sizes are determined by the hardware's capabilities and set in the firmware. Both NVRAM (where startup scripts and commands are stored) and JFFS content are stored on the flash chips inside the router. But what if I don't want to use JFFS and want to increase available NVRAM. I haven't found a way to decrease the amount of flash memory allocated or reserved for to / for JFFS (even if it isn't utilized) and reallocate it to NVRAM. Both are stored on the flash chips in the router, so this is completely valid thought from a technical perspective. However, because the size of each storage area seems to be hard coded in the firmware (which I sort of confirmed by researching and finding anecdotal comments that implied these limits are set in firmware, but nothing explicit), one is SOL if one wants to change the settings. For my WZR-600DHP router, there is 64 KB of NVRAM and just under 20 MB of JFFS storage space available. 64K of storage is all of the RAM my Commodore 64K had. It seemed like so much then, and thinking about it now, they really made efficient use of that small amount of RAM (large in those days). Ah, the good 'ole days, but I digress.
Another small item to watch out for (at least on the firmware version of my router) is the way the GUI displays information about the mounted drives. If there is more than one partition on a drive, by default DD-WRT will only mount one of them (the first one). But the way the GUI displays the information is a bit misleading. It shows the information about both partitions, then notes the mount point (/mnt, /opt, etc.) at the end. This might lead one to believe the second, third or whatever last partition listed is the one mounted. Nope. It's the first one that's mounted. No line breaks or listing the mounted partition directly after the displayed information about that specific partition, there's nothing to indicate the last partition isn't the one mounted.