Entware Installation on DD-WRT: Difference between revisions

No edit summary
mNo edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
This is a quick bullet list of steps to install Entware on DD-WRT
ls This is a quick bullet list of steps to install Entware on DD-WRT


===History===
===History===
Line 8: Line 8:


===Hardware===
===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
My 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 and a Linksys WRT3200ACM with an unbelievable amount of RAM, NVRAM, a 2 core CPU, etc. (yup, quite a range there)


These installation instructions should work for any hardware that can be flashed with DD-WRT and has a USB Port.
These installation instructions should work for any hardware that can be flashed with DD-WRT and has a USB Port.
Line 24: Line 24:
*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.
*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).
*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.
*Solution for the above mentioned problem? Create a file in the /opt Directory named ModifiedProfile (or any other name 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.
<syntaxhighlight>
<syntaxhighlight>
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 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
Line 57: Line 57:
}
}
</syntaxhighlight>
</syntaxhighlight>
The above script does three things.  The top several lines set environment variables.  The reboot and service subroutines can be used as commands at the command prompt.  The reboot subroutine gracefully shuts down any Entware services and the Service subroutine controls services installed by Entware


*Next, save the following as a StartUp Script
*Next, save the following as a StartUp Script
Line 62: Line 63:
mount -o bind /opt/ModifiedProfile /etc/profile
mount -o bind /opt/ModifiedProfile /etc/profile
sleep 1
sleep 1
</syntaxhighlight>I know I said I wouldn't explain things, but it needs to be said for the above short script.
/opt/etc/init.d/rc.unslung start
</syntaxhighlight>I know I said I wouldn't explain things, but it needs to be said for the above short script. The mount command effectively replaces the DD-WRT version of the profile file (this is the BASH login script for users).  The rc.unslung start command is what the Entware installation script said to add to the Startup Script.  RC.UNSLUNG starts all the installed services for Entware.
 
===BusyBox===
 
*The first useful item to install is an updated version of BusyBox (Google it).  Use the below commands<syntaxhighlight lang="abap">
opkg update
opkg install busybox
</syntaxhighlight>One thing to keep in mind is that when a user logs in, the DD-WRT version of BusyBox is what starts things off, so it will report a different version than what Entware installs and is actively running.  Just type: busybox  That will display the version of BusyBox currently running.
 
===OPKG Note===
Unlike yum, the OPKG command doesn't seem to allow one to install packages by using a wildcard.  For instance, if one wanted to install all the PERL packages, this won't work: opkg install perl*  But [https://www.linuxquestions.org/questions/linux-newbie-8/how-to-install-a-package-using-opkg-from-a-piped-search-result-4175580790/ someone] wrote this cool little script;<syntaxhighlight lang="abap">
opkg list | grep WhatEverNamePackagesBeginWith| awk '{print $1}' | xargs opkg install
</syntaxhighlight>
 
===Other Really Useful Basic Command Additions===
Sometimes it's nice to type DIR instead of using the LS command, so install coreutils-dir.  For an enhanced version of lsmod, kmod.  For a text editor that makes way more sense than VI, nano.  And for an enhanced version of TOP that's essentially equivalent to a text version of Task Manager in Windows, htop. <syntaxhighlight lang="abap">
opkg install coreutils-dir
opkg install kmod
opkg install nano
opkg install htop
</syntaxhighlight>Remember, DD-WRT is designed to fit into limited storage space on routers.  The key word here is 'limited'.  But with a USB Drive, space isn't so much of an issue, so why not install the full version of all utilities that come with BusyBox and DD-WRT? <syntaxhighlight lang="abap">
opkg list | grep coreutils- | awk '{print $1}' | xargs opkg install
</syntaxhighlight>
 
===What about Virtual RAM (AKA, Swap, PageFile, etc.)?===
There's usually a limited amount of RAM available in a small router, so if you're using it for any intense stuff like OpenVPN and SOCKS, it will use the RAM up fast.  If it gets used up the router generally just reboots, and the cycle starts again.
 
The starting point for creating a swap file is the following command which creates a file filled with "zeros" that is 64K (65536 bytes) big, 1024 bytes at a time;<syntaxhighlight lang="abap">
dd if=/dev/zero of=/tmp/mnt/sda_part2/SwapFile bs=1024 count=65536
</syntaxhighlight>Next, install the necessary software;<syntaxhighlight>
opkg install swap-utils
</syntaxhighlight>The following command "formats" / prepares the RAW / Blank file as a swap file with the label SwapFile and the 'swap program' recommends the permissions be changed too;<syntaxhighlight lang="abap">
mkswap /tmp/mnt/sda_part2/SwapFile --label SwapFile
chmod 600 /tmp/mnt/sda_part2/SwapFile
</syntaxhighlight>And finally, add the following command to your Startup Script (use the swapoff command if you want to turn the swap file off);<syntaxhighlight lang="abap">
/tmp/mnt/sda_part2/sbin/swapon /tmp/mnt/sda_part2/SwapFile
</syntaxhighlight>All of the above paths are the ones in my environment, adjust them to suit yours.
 
To check the swap file, HTOP displays used / available swap file space.  Oh, and don't be misled by HTOP indicating the swap file is "OK" (oh kay).  It's actually displaying 0K (zero kay).  So if you see OK displayed by HTOP, the swap file isn't working.
 
Note, this creates a swap file, not a swap partition.  There are other tutorials on that (Google it).  In terms of speed, I haven't read anything about there being an advantage to one or the other on a flash drive.  On a mechanical disk drive, if a swap partition is created at the beginning / inner part of the disk, it will perform faster (although there are some arguments that point out the middle of the disk is the best compromise).  However, more than likely speed will be limited by the USB bus, flash, or disk drive speed. 


*
*
Line 71: Line 113:
===Other Thoughts===
===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.
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.
To create a zero byte file with DD-WRT's built in VI command, do the following: type vi WhatEverNameOfFile to start the editor, within VI type :x (that's a colon followed by an x), then press enter.  That file can be edited via a shared network directory with a program like TextPad.


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.
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.