Optware Installation — TomatoUSB

Статья последний раз была обновлена 04.03.2023



How to Install Optware on TomatoUSB

This tutorial lets you install Optware onto an external USB drive, either a hard disk or a pendrive.

The tutorial is optimized to be really simple without any bells and whistles, and to use as little NVRAM as possible.

Disk formatting

It is recommended that you format your USB storage device to ext3 (for HDDs) or etx2 (for flash drives, to minimize writes to the flash and avoid wearing it too much). If you are unfamiliar with Linux disk formatting tools (fdisk and mkfs), it is suggested that you format the disk using a graphical tool from a Linux desktop (such as Ubuntu).

The suggested size for the partition is max 1 Gbyte, or even less (512Mbyte is already more than enough). While formatting, use the label "optware" for the partition that you intend to use for Optware.

If you want to store additional data in the USB key, you can simply use a different partition (or store it within the Optware’s partition, if you want to).

ЧИТАЙТЕ ТАКЖЕ:  Проблема при загрузке страницы

Router configuration

  1. Log into your router with the web interface. Usually http://192.168.1.1
  2. Go to USB and NAS » USB Support
  3. Enable "Core USB Support", "USB 2.0 Support", "USB Storage Support", All "File Systems Support", and also enable "Automount",
  4. Go to Administration » Scripts » Init and add the following line, then click [SAVE]:
echo "LABEL=optware /opt ext3 defaults 1 1" >> /etc/fstab

This tells Tomato to automatically mount the partition named "optware" in /opt. You can change the filesystem from "ext3" to "ext2" in case you formatted it with ext2.

Checking configuration

  1. Reboot your router.
  2. Plug the USB disk/pendrive if you have not already
  3. In the web interface, go to USB and NAS » USB Support » Attached Devices and check the list. There should be your USB drive, with a text like Partition "optware" ext3 is mouned on /opt.
  4. You can mount/umount the partition from the web interface.

First optware bootstrap

If everything is mounted correctly, open a telnet session to the router and run the following code:

wget http://tomatousb.org/local--files/tut:optware-installation/optware-install.sh -O - | tr -d 'r' > /tmp/optware-install.sh
chmod +x /tmp/optware-install.sh
sh /tmp/optware-install.sh

Automatic package updater (optional)

Go to Administration » Scheduler and add the following line to the "Command" field of Custom 1, 2, or 3 (just use one that’s available). Select the desired frequency (once a day is usually sufficient):

ipkg update | logger -t Optware

How optware integrates with TomatoUSB

TomatoUSB already has some transparent support for optware. For instance, it automatically adds /opt/bin to the system PATH. Moreover, it will use the /opt/etc/config directory to look for administrative scripts:

  • /opt/etc/config/*.fire: All executable files matching this pattern will be executed whenever the firewall needs to be (re-)configured. You can store your firewall configuration here instead of using the web interface (Administration » Scripts » Firewall), to save precious NVRAM space.
  • /opt/etc/config/*.wanup: All executable files matching this pattern will be executed whenever the WAN interface goes up. You can store your WAN-dependent configuration here instead of using the web interface (Administration » Scripts » WAN Up), to save precious NVRAM space.
ЧИТАЙТЕ ТАКЖЕ:  Tomato by Shibby » Router List

The only issue with using these files is that there is a possible race condition at startup: if firewall/wan goes up before optware is mounted (USB can be slow..), those scripts will not have their chance to be executed.

To workaround this race condition, create the file /opt/.autorun, with the following contens:

#!/bin/sh
if [ -f /var/notice/wan ]; then
   for s in /opt/etc/config/*.wanup; do $s; done
   for s in /opt/etc/config/*.fire; do $s; done 
fi

Remember to make the file executable: chmod +x /opt/.autorun. This file is automatically executed by TomatoUSB when the partition is mounted (nothing specific with Optware, this is just Tomato’s USB subsystem), and will execute the scripts if the WAN is already up by the time it is executed.

Further references

Originally DD-WRT Optware Installation Tutorial please refer to the DD-WRT Optware Installation Wiki.

If you have any questions refer to this form post.


http://tomatousb.org/tut:optware-installation

Губарь Маргарита Александровна