Monday, March 4, 2013

Installing packages into USB on TL-WDR4300 OpenWRT

   

    Subsequently of my buying TP-LINK TL-WDR4300 router, due to the good old Linksys WRT54GL hasn't enough FLASH/RAM/CPU, the first thing I did was to try installing OpenWRT on it.

   Turned out that it was easier than I thought, you could just flash Attitude Adjustment 12.09rc1 from the web GUI of the factory firmware. Detailed instruction here for where to download the image.

   Secondly I installed packages required for using USB storage, this process was simple enough if you understand how to format your usb to specific preferred filesystems (ext2,3,4) I use gparted [just sudo apt-get install gparted, on a debian dist]. VFAT and NTFS are not agreeably supported due to their slowness, such and such. Also to my understanding, you'd need ext2,3,4 filesystems if you were to install packages on them.

Steps:

1.) USB storage required packages
2.) How to install (other) packages to your USB device

What I've learned:

There are three files you need to configure in order for this to work every time even after a router reboot. 
  • /etc/config/fstab  (this is my configuration):
  config mount                    
        option target   /mnt/usb  # Don't forget to mkdir -p /mnt/usb first
        option device   /dev/sda1
        option fstype   ext2  
        option options  rw,sync
        option enabled  1     
        option enabled_fsck 0

  • /etc/profile : [These three lines are preferably added below the existing export(s)]
export USB=/mnt/usb
export PATH=$PATH:$USB/usr/bin:$USB/usr/sbin # This PATH is dependent on existing $PATH
export LD_LIBRARY_PATH=$USB/lib:$USB/usr/lib

  • /etc/opkg.conf : [Just change this line]
dest usb /mnt/usb
# this is to indicate that there is a destination you'd like to install your packages to named "usb"

    Now with all that done, insert your usb (up to this point I assume that you must have installed the packages required in the first step).

To start using the usb run:


root@router~#: /etc/init.d/fstab start


To auto-mount usb to fstab every time the router starts(or restarts) run
:

root@router~#: /etc/init.d/fstab enable

You might as well want to source the /etc/profile so that the paths can be used instantly:

root@router~#: source /etc/profile



Then run these commands to update and install packages

opkg update
opkg install -d usb PACKAGENAME

Well that should do it. After a few poking around, I have now python2.7 able to run from my router.
Note that you'd better check that your USB functions well and isn't damaged.



Have fun!