OpenWrt Forum Archive

Topic: install packages on USB-Stick ? [TL-MR3020]

The content of this topic has been archived on 5 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello everybody,
i want to know if it is possible to install packages like "radvd", "openvpn" etc on an USB-Stick, because the Memory of my TL-MR3020 is very small and  also full know!
If it is possible could someone please tell me how i could do this, that opkg install openvpn will be installed on an external USB-Stick!

Greetz
Patrick

Yes it's possible and it's great!

1. First make sure you have full working USB support: install these packages (on the device)
kmod-usb-storage
block-mount
block-hotplug
kmod-fs-ext2

2. prepare an USB stick by formating it with an ext2 filesystem - you won't be able to do this from the router itself (installing the filesystem tools packages takes too much space), either:
a) do it from Windows with various tools, for example: EASEUS Partition Master 9
b) do it from some other Linux with: mke2fs /dev/<usb device>

3. plug the stick in the router and mount it:
mount -t ext2 /dev/<usb device> /mnt/usb/
<usb device> usually it's sda1
/mnt/usb must be first created with mkdir, or you can use /mnt directly - from now on i'll assume /mnt/usb/ was used

4. prepare opkg for external installs
edit /etc/opkg.conf and add an extra line that maps the destination "usb" to the path where you mounted the stick
dest usb /mnt/usb/

5. prepare the extra paths for executables and libraries:
export USB=/mnt/usb
export PATH=$PATH:$USB/usr/bin:$USB/usr/sbin
export LD_LIBRARY_PATH=$USB/lib:$USB/usr/lib

6. install whatever you want on the external storage with:
opkg install <package> -d usb

so "-d usb" is the key, make sure you don't forget it otherwise packages will be installed in the router storage itself and will quickly fill it up leading to corruption!

NOTES:
* you will want to automate steps 3 and 5 somehow otherwise on the next reboot it won't work and you'll have to run them again
for #5 edit /etc/profile and add the variables there

* some programs need additional config files to run, you will have to create links between the root filesystem and the usb one
for example for successfully running Midnight Commander after installing it on usb run:
ln -s $USB/usr/share/terminfo/ /usb/share/
ln -s $USB/etc/mc /etc/mc

Enjoy!

(Last edited by valentingalea on 1 Apr 2012, 10:33)

Hello valentingalea,
thank you for your very helpful and detailed explanation!

Greetz
Patrick

hi, everybody,
I've just seen these posts and I'm wondering which "strategy" to adopt regarding the "right way for doing" Flash File extension.

I explain :
I was also disapointed by the amount of on board FLASH and decided to switch it to an external (recycled) Ext4 64Mb USB pen drive.

On board 4Mo are really too small and I even had to first remove few packages before being able to start pivoting the overlay (the USB packages are really hungry smile
I followed the Extroot howto and every thing runs well ! http://wiki.openwrt.org/doc/howto/extroot

The purpose seems to be more or less equivalent for what I can name : "user space extension " but i'm sure there are other counterparts I haven't identified.
So, this leads me to ask myself  and you guys if I did well and if it can't be somewhat dangerous e.g. to much W/R access(?)

Appart from the fact that once I've pivoted the overlay i don't need to bother with opkg destination extension and PATH exports, what else  may be taken into account for a box that should run some CRON'ed scripts and acts as a datalogger (Sqlite3 cli) with mutliwan connection (Eth +3G backup) for  downloading the database dump daily ?

thanks for any hints you may provide
Eric

(Last edited by RicoCoco on 29 Jun 2012, 14:48)

The discussion might have continued from here.