Optware, the Right Way

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 08:40, 10 December 2009 (edit)
Masterman (Talk | contribs)
(Using PuTTy to enable/disable Services)
← Previous diff
Revision as of 08:47, 10 December 2009 (edit) (undo)
Masterman (Talk | contribs)
(Ensure Partitions are mounted)
Next diff →
Line 164: Line 164:
 +
 +
 +'''Important''' To keep track of your drives free space, issue the command '''df -h'''
 +
 +
 +
 +You will get an output like this:
 +
 +
 +
 + root@Asus:~# df -h
 + Filesystem Size Used Avail Use% Mounted on
 + rootfs 5.7M 5.7M 0 100% /
 + /dev/root 5.7M 5.7M 0 100% /
 + /dev/discs/disc0/part1
 + 756M 215M 534M 29% /opt
 + /dev/sda4 293G 173G 117G 60% /mnt
 + /dev/sda3 504M 17M 483M 4% /tmp/c
 + root@Asus:~#
Line 209: Line 228:
This service MUST be enabled for '''Network Printing, etc.''' This service MUST be enabled for '''Network Printing, etc.'''
 +
 +
 +'''NOTE''' Twonky Media Server (google it) is enabled by default. It is a massive resource hog and will bog down even the most powerful routers.
 +
 +
 +To disable it, enter '''service twonky stop''' followed by '''service twonky off'''

Revision as of 08:47, 10 December 2009

Contents

Frater's no hassle, newbie friendly Optware

This is the latest, greatest and easiest way to enable Optware on your Router. It is recommended that you have a router with USB capable storage (Harddisk, flashdrives etc.), although the SD/MMC Method is working, as well as the LATEST stable build!. For USB users, you wont be needing JFFS2, so DISABLE it! Another aspect to note is that some of these service (i.e Twonky) consume alot of CPU resources, so make sure you check your resource consumptions.


UPDATE For everyone using K26 builds or builds that were compiled in December, you will no longer need a startup or shutdown script. Use the Automount feature in Services->USB and mount to /opt in the drop down menu.


For users with small /opt partitions, use this as your start-up script:


mount -o noatime -t ext3 /dev/scsi/host0/bus0/target0/lun0/part1 /opt &


Remove the shutdown script as well.


I suggest a clean install of optware as Frater has made some recent changes..


To get printing to work, do this:


mknod -m 660 /dev/usb/lp0 c 180 0


Services that will be installed:


  • Bash instead of shell in busybox (LFS support)
  • Automounting and unmounting of storage device partitions
  • Network printing
  • Watchprinter
  • Torrent transmission with watchdog
  • Hotmount
  • Pre-configured samba share
  • Reverse proxy featuring pound
  • Service tool
  • Xinetd
  • Pound
  • Asterisk
  • Lighttpd
  • Vlighttpd
  • Countryblock
  • AsiaBlock
  • Services running as other users than root
  • Vim with proper terminal support
  • Twonky Media
  • News Server
  • Other various useful tools


In my opinion, Everyone with a router that has storage device capabilities should take advantage of this! You will NOT regret it, even if it can be a time consuming process! If you are worried about formatting to a Linux filesystem and it's compatibility with windows, there are several third-party drivers out there that will read and write on a Windows OS. Just google it!

Getting Started

If starting from scratch, you will need to first format and partition your harddisk, flashdrive or SD card to an EXT2 or EXT3 Linux filesystem. It is much easier than you think, and can be accomplished via a Linux Live boot-CD. There will be NO changes to your PC whatsoever, and it is very simple to implement.

Drive Preparation and Prerequisites

Before you can utilize this extremely beneficial addition to your USB capable router, you must follow these important instructions:

How to - Format and Partition External Storage Device


Connecting the Drive to your Router

1. In the DD-WRT web GUI screen, on the Services USB tab enable the options for:

  • Core USB support
  • USB 2.0 support (Asus WL520gU routers must use USB 1.1 drivers only!)
  • USB storage support
  • Printer Support (optional)
  • ext2/ext3 File System support
  • FAT File system support (optional)
  • Automatic Drive Mount
  • In the Disk Mount Point drop-down menu, mount to /opt


2. From the DD-WRT web GUI screen, click on Apply Settings. This will reboot the router.


3. If everything was done correctly, this should appear on your Services -> USB Tab:

Image:Drivemount2.jpg

Executing the Script

Start a terminal session to your router with the command telnet 192.168.1.1, followed by login (root) and your routers password, or use a program like PuTTY if using Windows.

NOTE When entering your password into the Telnet or SSH terminal, the characters will notshow up. This is normal for security. Just make sure you don't make a typo when entering it.


First issue these commands to ensure /opt is mounted:

root@DD-WRT:~#mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
none on /dev type devfs (rw)
proc on /proc type proc (rw)
ramfs on /tmp type ramfs (rw)
devpts on /proc/bus/usb type usbfs (rw)
/dev/scsi/host0/bus0/target0/lun0/part1 on /opt type ext3 (rw)
root@DD-WRT:~#



Enter the following commands into Busybox/Telnet:


wget -O /tmp/prep_optware http://wd.mirmana.com/prep_optware 

sh /tmp/prep_optware

This will load all the necessary optware and supporting scripts that Frater wrote from the ground up.


This will take about 10-20 mins depending on your connection and your router CPU clock. Close your Web Interface as this consumes precious memory and CPU resources


Once everything has completed, wait for a minimum of 1 minute, then type reboot into either the BusyBox/Telnet Shell (why not, your right there) or through the Web Interface.

Important Wait at least another minute before logging back into the Telnet/SSH session!

Ensure Partitions are mounted

In either telnet or SSH, enter the command mount , if everything is working properly, it should look like this:


Image:Mount.jpg



Important To keep track of your drives free space, issue the command df -h


You will get an output like this:


root@Asus:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
rootfs                5.7M  5.7M     0 100% /
/dev/root             5.7M  5.7M     0 100% /
/dev/discs/disc0/part1
                     756M  215M  534M  29% /opt
/dev/sda4             293G  173G  117G  60% /mnt
/dev/sda3             504M   17M  483M   4% /tmp/c
root@Asus:~#



Using PuTTy to enable/disable Services

Image:Service.jpg



The BusyBox/Telnet Commands to enable/disable the services are are follows:

service - show all services (enabled/disabled)
service <service name> - if "status" is supported it will run the service-script with "status" asparameter. 
service <service name> on - Enable the script, allowing execution (chmod +x  /opt/etc/init.d/S<servicescript>)
service <service name> off - Disable the script, disallowing execution (chmod -x  /opt/etc/init.d/S<servicescript>)
service <service name> start - Start/execute the script, as long as service is enabled (i.e. permissions allow execution)
service <service name> stop Stop/kill the script, if the service is running
service <service name> <parameter> - Run the script with the parameter.


  • Once you enable a service with the on parameter, you will also need to issue a start directly proceeding it to initiate the service.


Examples:

service - 
service xinetd
service xinetd off
service xinetd on
service xinetd start
service xinetd stop
service xinetd restart

NOTE Xinetd will need to be started after the optware has been installed and the router has rebooted.

Issue: service xinetd start

This service MUST be enabled for Network Printing, etc.


NOTE Twonky Media Server (google it) is enabled by default. It is a massive resource hog and will bog down even the most powerful routers.


To disable it, enter service twonky stop followed by service twonky off


service automount start - mount all partitions
service automount stop - umount all partitions instead of the one to /opt
service automount status - show all partitions
service automount unmount <partition|mountpoint> - unmount that partition and remove it fromautomount
service automount nomount <partition> - Do not automount this partition
service automount nonomount <partition> - remove this partition from the nomount list


NOTE

You can also turn a service on or off through the web interface command line in Administration-> Commands (for people who don't like the hassle of SSH):

Examples:

/opt/usr/sbin/service transmission-daemon on
/opt/usr/sbin/service transmission-daemon start
/opt/usr/sbin/service xinetd on
/opt/usr/sbin/service xinetd start


Choose the service(s) you wish to execute and click Run Commands in the Administration->Commands box.

You are ready to go! It is also wise to wait at least 30 seconds after enabling these services before accessing them.

Also, see NOTES at the bottom of this page for important/useful commands

Accessing services in Web browser

Swat/Samba - http://your.routers.ip:901

Torrent Transmission - http://your.routers.ip:9091

Twonky Media - http://your.routers.ip:9000


NOTE

If you find that you can't log in to SSH after installation, check that you're using a build greater than, and including 12827. The reason is that bash is used as shell after installation, but older firmware builds don't allow for shells other than /bin/sh to be used in SSH.

SD/MMC Method

After and including build 13309

  1. Make sure you have 13309 or higher on your router. Start with a fresh system 30/30/30 reset, a Clean formatted SD card in either ext2 or ext3 with a /jffs directory, then create /opt inside of /jffs. Ex. /jffs/opt.
  2. Boot router.
    1. Enable SD support.
    2. Enable jffs.
    3. Setup your internet connection.
    4. Save the following script to Startup in Administration->Commands.
      1. mount --bind /mmc/jffs /jffs
      2. mount -o bind /mmc/jffs/opt /opt
  3. Log into the router via Putty (SSH) and run fraters script below. This will take a while. It will tell you when it's finished.
    1. wget -O /tmp/prep_optware http://wd.mirmana.com/prep_optware
    2. sh /tmp/prep_optware
  4. When the script is done, it will tell you so and advise a reboot. (it is wise to wait ~1-2 mins after completion before rebooting)
  5. Reboot

Before build 13309

First off credit goes to frater for the optware script and the driver script credit goes to aszu and the startup script for the driver goes to phuzi0n. My hats off to you guys.

An update on my situation. The SD cards speeds were too slow and were overwhelming the router. I have steps for anyone using SD. It uses the new driver for the install. I have tested this 4 times on 2 different sd cards.

Start with a fresh system 30/30/30 reset, a Clean formatted SD card in either ext2 or ext3 with a /jffs directory, then create /opt inside of /jffs. Ex. /jffs/opt.

For some reason the later builds have a problem with formatting a card on setup, it screws the partition making the card invisible to the router. The above remedies this, and a service ticket has been submitted to fix this.


Continuing:

1.

  • Boot router.
  • Enable and setup GPIO's in the GUI for the SD Mod, because in the later builds auto GPIO is broken. Also setup your internet connection.
  • Enable jffs.
  • Copy the SDHC driver from HERE to the root directory of the MMC card via WinSCP
  • Save the following script to Startup in Administration->Commands. This Startup script will run the new SDHC driver all the time. It is only necessary until the release of a build with it all ready ported.


Code:

cp /mmc/sdhc-gpio2.o /tmp
umount /mmc
rmmod mmc
insmod /tmp/sdhc-gpio2.o
mount /dev/mmc/part1 /mmc/
mount --bind /mmc/jffs /jffs
mount -o bind /mmc/jffs/opt /opt


2. Log into the router via Putty (SSH) and run fraters script below. This will take a while. It will tell you when it's finished.


Code:

wget -O /tmp/prep_optware http://wd.mirmana.com/prep_optware
sh /tmp/prep_optware


3. Reboot (it is wise to wait ~1-2 mins after completion before rebooting)

Notes

Useful scripts

mount - Shows what disks/partitions are mounted
fdisk -l - Shows disk information
blkid - Shows disk information
df -h - Shows disk usage and available space.  Very important
lsusb - Shows devices in /dev/usb/ like printers, USB hubs etc.
top - Shows all running processes and resources as well as swap file usage and CPU-Memory usage.
htop - A more user friendly application that allows you to kill processes, change their "nice" value, etc.
netstat -lnp - Shows which ports are open and what services are using them.
cat /tmp/fdisk
cat /tmp/blkid
cat /opt/etc/automount
cat /opt/etc/nomount


  • To remove this optware completely (which should be done after a build upgrade, or if you don't need all of these services) do the following:
cd /opt
rm -r *


Many more exciting packages are in the works, so be sure to follow This forum thread and further help is always available on the forums.

Enjoy!