How to set up Nas, Optware, etc, FOR TOTAL NOOBS


How to set up you NAS and Optware for Total Noobs
Peliminary tutorial:

The first step is to get yourself a linux environment.
I suggest using a noob friendly build like Ubuntu.
You can use it as live distro, install it, or create a virtual machine.
As this is a totalnoob guide, I am inclined to think all of you reading this come from windows, so the easiest way is to make a live cd, live usb, and work from there, I suggest using Ubuntu.
For this guide to work correctly, or just to work, you need internet connection.

1. Setting up you linux environment:
2. Setting up your usb drive correctly:
3. Set Tomato to work with your drive:
4. Tweak your usb HD:
5. Putty:
6. Installing the prerequisites for Optware:
7. Installation of popular Optware packages:
……..Transmission………Plowshare………NTPD server………rtorrent+rutorrent
8. Samba File sharing:
……..VPN (File sharing through WAN)
9. Ftp server
10.Media server:
12.If you want an specific optware guide ask for it here:

Setting up you linux environment: (Return to top) (if you are using any linux distro, go skip step 1 :p)
1. Just go into, download it, and follow the tuto to create a live cd, or live pendrive.
2. Once on linux, connect the usb drive you want to format.

Setting up your usb drive correctly: (Return to top)

If you just want to share your drive, and not install Optware, skip this.

1. Go to system, Administration and Gparted Partition Editor, if you haven’t got it installed, install it through synaptic package manager.
2. Select you drive on Gparted, and now Delete all partitions.
3. Create a new partition with 512mb using linux-swap format, and call it SWAP, this partition should be the first on the drive (if you preffer using other names on the partitions, feel free to use them, but remember to change them everywhere where you see the names I use)
4. On the space left you have two options, make a big partition with all the space, to share and install optware, or make different partitions one to share, and the other just for optware ( I sugest using one big partition for everything, and then on the nas, jus show the folders you want restricting the acces, or eliminating visibility)
If you want to follow my approach youll have to select the unformatted space and create a new partition, name it OPTWARE, use ext3 as format (if on pendrive use ext2).
5. When Gparted finishes, unplug extract the drive and plug it in your router.

Set Tomato to work with your drive:: (Return to top)

1. Log into your Tomato router, go to USB and NAS and check Core USB Support, USB 2.0 Support, if you are going to use usb 1.1 also check those boxes, the same as usb printer support, just if you are going to use it, check the filesystems that you will be using, in this case if you did what I said and aren’t going to plug any other drives, just check Ext2/Ext3.
Also check Automount.

If you dont want to install Optware, and just share your drive you are done, skip this.

2. If you want to use complex setups, with multiple HDDs, multiple swap partitions, etc, and dont want to go mad adding all the partitions on fstab, a much safer a easier way of making your setup work correctly is using autoexecutable files on the root of each HDD, which will modifie fstab automaticly with the settings for the drive plugged in.
For more info on this method go to:

3. If you are going to use simple setups with one drive or multiple, but only one swap, and only one drive for optware, follow this method.

4. If you cheked automount on USB & NAS>USB support and attached your drive, you should see at the bottom of the page on attached Devices, your drive, with the partitons you made, you'll also see swap is not mounted.
5. Use telnet or ssh and log to your router.
6. Type:

vi /etc/fstab

7. Now lets introduce our custom Fstable, copy the selected to the opened table with the right click and paste (If you have more partitions or drives, or different naming scheme, mount their labels accordingly, and don’t mount for example two diferent drives on /opt at the same time!, also remember, all this is case sensitive).

#device Mountpoint FStype Options Dump Pass#

LABEL=SWAP none swap sw 0 0

LABEL=OPTWARE /opt ext3 rw,noatime 1 1

8. Now press esc twice, and type:


This will save the fstab temporarily on your router ram.

9. To make it permanent type:

nvram setfile2nvram /etc/fstab
nvram commit

10. When rebooted, log with telnet or ssh and type :


It should show your mounted partitions, it will look something like:
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                 5568      5568         0 100% /
tmpfs                    30984       628     30356   2% /tmp
devfs                    30984         0     30984   0% /dev
/dev/sda2            480204528  18649556 437161912   4% /opt

If you log on tomato web ui you will see that swap is mounted, and that your ext3 partition is mounted as /opt.

11.Now on USB and NAS, USB Support, Run after mounting:

led usb on

12. If you want it to automaticaly start optware, add what you would use to launch it on telnet or ssh.

13.Now on USB and NAS, USB Support, Run before unmounting, type

# Unmount Opt from flash drive
umount /swap
umount /opt
sleep 10
led usb off

14. If you installed optware as transmission or plowshare also kill them before unmounting, so type for example:

# Unmount Opt from flash drive
killall screen
killall transmission-daemon
sleep 5
umount /swap
umount /opt
sleep 10
led usb off

Congratulations, now you are ready to start installing optware and start setting up your nas samba share, ftp, media server etc.

Tweak your usb HD: (For k26 builds only, if not, skip all this) (Return to top)

Lets add spindown if possible and modify swapiness on tomato.
1. Log on tomato web ui and go to USB and Nas, File Sharing, enable file sharing with no Authentification to start, when finished change it as you like, and add acces to /opt or /mnt if you dont want optware.
2. Log on telnet or ssh to your router, and type:

scsi-stop /dev/sda

You should hear your drive spinning down.

3. Now go into your share and copy something or open something and you will hear the drive spinning up.
4. Try again spinning it down and then up for a few times, to make sure everything is ok.
If your drive is not compatible it wont work, just forget about it and continue.
5. Optional, onn telnet or ssh typing:

dmesg | tail

You can look at the kernel messages. Make sure there are no scary warning/error messages about USB drives or devices.
12. Once done this download this file:
and paste the sd-idle-2.6 somewhere on your /opt or /mnt partition.
13. Go to tomato web ui, into administration, scripts and Init.
Input the following:


/opt/any folder you created for the program, or not/sd-idle-2.6


/mnt/any folder you created for the program, or not/sd-idle-2.6

For example my script looks like:



Remember to type the folders exactly as their name is, with lower and upper case letters.

14. To make sure you have permission to autorun the file type on telnet or ssh:

chmod +x /opt/(or /mnt)any folder you created for the program, or not/sd-idle-2.6


chmod +x /opt/share/spindown/sd-idle-2.6

15. Now reboot. To change settings on the idle program, if you used the same directory setup as I did use this, if not change accordingly:

root@unknown:/tmp/home/root# cd /opt/share/spindown
root@unknown:/opt/share/spindown# sd-idle-2.6 --help
Usage: ( runs as a daemon )
  sd-idle-2.6 [ -d devices ] [ -i idletime ] [ -c checktime ] [ -h --help ] [ -v --version ]
    -d  [a-z]+   include where a => /dev/sda, b => /dev/sdb (default is all disks)
       ![a-z]+   exclude
    -i n         n seconds a disk must be idle to spin it down (default 900, min 300)
    -c n         n seconds to sleep between idle checks (default 30, min 5)
    -h --help    usage
    -v --version version
  for example:
    sd-idle-2.6        will manage all disks with default times
    sd-idle-2.6 -d bc  will manage /dev/sdb, /dev/sdc with default times
    sd-idle-2.6 -d !bc will manage all disks except /dev/sdb, /dev/sdc with default times
    sd-idle-2.6 -i 600 will manage all disks spinning down after 600 seconds or 10 minutes

As you can see, for example if you type:
/opt/share/spindown/sd-idle-2.6 -i 600

Your drives will spindown with 5 minutes of inactivity, the minimun time accepted.

16. Now lets change swapiness, all this is of course is optional.
Swapines is how linux determines when to start swaping pages to swap, I have mine set to 75, so when my memory drops down to 75 avaylible, tomato starts swapping.
To check your swapiness type on telnet or ssh:

cat /proc/sys/vm/swappiness

17. To change your swapiness for example to 75 type:

echo 75 > /proc/sys/vm/swappiness

When rebooting this seting will be lost and it will be reverted to default swapiness.
18. To make the changes we are doing permanent the easy way, go to tomato web ui, into administration, scripts and Init.
Input the following under the already written:
echo 75 > /proc/sys/vm/swappiness

Some people like this value low so their ram is kept fully usen and everything is snappy, I like it high so that tomato uses the Ram for what is really important, you can play with this number and see how it goes.
19.Reboot. Your done.

5. Putty: (Return to top)
If you are sick of having to log into telnet or ssh each time, try this method:
1. Download putty:
2. Unzip the file in a folder and open Puttykygen, generate a key, and dont give it a password.
3. Click save private key, and save publick key, and save both, dont close Puttykygen yet.
4. Now go into tomato weui and into admin acces.
5. Enable SSH Daemon enable at startup and Allow Password Login, now go to Authorized Keys and copy all the key from Puttykygen, from the first number or leterr to the las you see, and save.
6. Go to putty, type your router ip, select ssh, now go to Conection, SSH, to Auth, and on Private key select your previously saved key.
7. Now go to Session, on Saved Sessions type a name for this config (I have it as TOMATO), and click on save.
8. Now create a shortcut for putty, right click on it, properties, and at the end of the path type -load "TOMATO" (or the session you just created), apply, accept, and your done, you can now enter tomato without logging in, and with a little security.
9. If you dont need remote acces to ssh, disable it, I think this approach is much more safe, than adding the hostnam, username, and password at the end of the shortcuts path.

Installing the prerequisites for optware: (Return to top)
For optware installation, first we need to select which packet managet to use IPKG, or OPKG and what repository to download files from.
IPKG: (Return to top)
For optware installation, first we need ipkg and Uclib, for this just type the following on telnet or ssh:

wget -O - | tr -d '\r' > /tmp/
chmod +x /tmp/
sh /tmp/
sleep 5
ipkg update
sleep 5

This will install and update IPKG to use the default ddwrt repository.

To change this:
OPKG: (Return to top)

Your done, allready!! Now to install Optware, you just need to install the package you want and of course its dependencies.

Installation of popular Optware packages: (Return to top)
Here we will revise some basic installation and configuration of popular Optware.
Remember that before you unplug the usb hd or reboot the router, it is recomemded to kill all optware running, so add the necessary commands on run before unmounting, like:

killall screen
killall transmission-daemon
sleep 2
umount /opt

1. To install Plowshare, which is a really efficient command line downloader uploader, first you install the program:
ipkg install plowshare

2. Now install all its dependencies, and screen, which will help us managing and monitoring plowshare:

ipkg install libtool
ipkg install tesseract-ocr
ipkg install imagemagick
ipkg install coreutils
ipkg install py25-pil
ipkg install ossp-js
ipkg install recode
ipkg install screen
sleep 10

3. To start a daemon for plowshare:

screen -dmS plowshare

And to attach to the daemon for plowshare:

screen -r plowshare

When you close telnet or ssh, and want to see how plowshare is doing just type:

screen -r plowshare


creen ls
screen -x screen_session_name

4. When you are done with it, or it finished downloading or uploading, type:

Killall screen

5. To download to a folder, with a text file that has multiple links for example from megaupload I use:

plowdown -a user:password -m "/opt/Optware/Downloads/Download_link_list.txt"

6. To upload from a folder with multiple files and to wright the links from the upload on a text file, for example uploading to megaupload I use :

cd /Path of your folder/
for i in *; do plowup -a User:Password -d "Description" "$i" megaupload; done >> /Path of your folder/megaupload.txt
exit 0

7. For more info ask, or go to
Transmission: (Return to top)
1. To install Transmission a popular torrent downloader type:

ipkg install transmission
sleep 5

2. For it to create the necessary config files to run type:

/opt/bin/transmission-daemon -g /mnt/data/torrents/.config/transmission-daemon
killall transmission-daemon
sleep 2

3. To modify this settings type:

vi /mnt/data/torrents/.config/transmission-daemon/settings.json

Once u’r done press esc twice and type:


You can also modify them if you have share enabled on /opt with a program like WinVi32, dont use notepad because when saving will make the file to loose format.
Remember to disable whitelist or to add your ip, or your lan (192.168.1.*) if not you wont be able to acces the webui.
4.You can add a torrent watch folder adding and replacing this lines at the bottom of the config file:

    "upload-slots-per-torrent": 14,
    "watch-dir": "/opt/Optware/Torrents",
    "watch-dir-enabled": true

5. You need to forwar Transmissions ports so go to tomato web ui, into administration, scripts and Firewall.
Input the following to forward transmissions ports:

# for Transmission (BitTorrent client)
iptables -I INPUT -p tcp --dport 65534 -j ACCEPT
iptables -I INPUT -p udp --dport 65534 -j ACCEPT
iptables -I INPUT -p tcp --dport 51413 -j ACCEPT
iptables -I INPUT -p tcp --dport 9091 -j ACCEPT
Now reboot.

6. To run transmission type:

/opt/bin/transmission-daemon -g /mnt/data/torrents/.config/transmission-daemon

7. To acces the webui go to
Remember you can change download folder, activate and change incomplete download folder, etc.

NTPD server: (Return to top)

rtorrent+rutorrent: (Return to top)

ipkg install lighttpd php-fcgi php-gd php-mbstring openssh-sftp-server sqlite microperl tar nano adduser which coreutils procps grep screen gawk
ipkg install rtorrent

/opt/etc/init.d/S99rtorrent start

/opt/etc/init.d/S80lighttpd start

Samba File sharing: (Return to top)
To enable file sharing through samba (accessible on all oses) go to:
1. Tomato web ui USB and NAS, USB Support, File sharing, and enable file sharing, with or without authentification, that’s up to you, (for the first try ill try without authentification).
2. At the bottom of the page, you can mount the directories, or partitions you want to be seen or shared, and you can select to make them visible or not, writable, or not, etc, is quite self explanatory.
I usually create a folder on /opt, called optware, through telnet:

cd /opt
Mkdir optware

Then mount /opt/optware, and name it share, make it read/write and not hidden.
Then I acces that folder and create Downloads, Uploads, Torrents, Incoming, folders and set my optware to use those folders accordingly.
3. If you are not using Optware and havent configured manually your drive partitions (they are being managed by automaunt), your partition should be mounted as /mnt, so create folders on it, and make them visible through the method I exposed, or make visible all the partition.
VPN (File sharing through WAN): (Return to top)
Follow this method until I create my own tuto:

FTP server: (Return to top)
Tomato has an integrated FTP sever, so it is really simple to set it up within the gui, im adding this small tuto as some people have had problems setting up FTP….. allthough its pretty Public Root Directory.
1. Open tomatos web ui and go to USB and NAS, FTP server.
2. Once there you must select to enable the FTP server on Lan or also make it viawable on WAN.
3. Select your ftp port (I suggest leaving the default 21), and forward it if you want it to be seen on Wan. To forward it just go to port forwarding, basic, and on ext ports, type 21, on Int adress type, on description, name it as you like (FTP).
4. Now select if you want anonimus users to acces, to read, read and write, or just write.
5. I wouldnt allow Admin login, just my grain of salt.
6. On Directories select what directories you want who to see, for example I've got as Anonymous Root Directory: /opt/optware/Uploads, as Private Root Directory: /opt/(the private username), and as Public Root Directory: /opt/optware (private will create an exclusive directory on the directory and partition you select, with the name of the private user, and he/she will only be able to see that folder).
7. Enable the limit connection attemps.
8. Add users at the bottom of the page, and you are done with the basic config (private is on the same menu as read/write, etc).

Media Server: (Return to top)
1.To setup a Media server go to:
USB and NAS > Media Server tab and click on Media / DNLA Server and click Enable.
2. Once you have it enabled, you need to decide and setup where the database is saved for you media and other options. If you have very few music, pictures or videos then you can leave everything at default and just turn on "Scan Media at startup" and reboot.
If you have many media to share you will be better of designating a location on your “usb hd” orr jffs (I recommend doing it on your usb), to save the database, so create a Custom Database Path.
Doing this will ensure that you have enough space for your database.
4. On Database Location select "Custom Path" in the drop down box, and then enter the path to your hard drive, I suggest you create an specific folder for your database.



Depends on your config.
You can use any name you wish for the folder.
5. If you have a Tivo you can click on the Tivo Support and your Tivo will be able to connect to your hard drive and play TiVo compatible videos, music and display pictures.
6. The Strictly adhere to DLNA standards will allow server-side downscaling of very large JPEG images, which may hurt JPEG serving performance on (at least) Sony DLNA products.
I recommend leaving it off unless you are having a particular issue with Jpeg images.
7. On media directories if you want the whole hard drive to be scanned for media you can leave the directories at the default setting of /mnt or /opt
If you want to restrict the scan to specific directories or types of media then you can specify the type of media and the directory to scan specifically. The directory has to be exactly entered.
/mnt/videos    Video only

/opt/videos    Video only

8. Once you have everything set then click on Save.
Depending on the amount of files you have to be scanned and their types it could take some time for everything to show up on your DLNA client. In addition, depending on what DLNA client you are using you may need to force a re-scan on it also.

If you want an specific optware guide ask ofr it here: (Return to top)

Troubleshooting: (Return to top)
1. If by any means you get an error working with ipkg, like :

sh: wget: Permission denied
An error ocurred, return value: 1.
Collected errors:
ipkg_download: ERROR: Command failed with return value 127: `wget -q -P /opt/ipkg-znDmt5

or any other, just share opt and make it writable on the file sharing, go to /opt/etc/profile, and remove the following code:
PS1="[\u@\h \W]$ "


save and everything will be back to normal.
2.. If when you reboot, Transmission has been reset to default, change the directory of the settings from:


to something like

To do this:
Delete /mnt/data/torrents/.config/transmission-daemon and run on telnet or ssh:
/opt/bin/transmission-daemon -g /opt/.config/transmission-daemon
killall transmission-daemon
sleep 2

Once done, modify the new settings using WinVi32 or:
vi  /opt/.config/transmission-daemon/settings.json

Press Esc twice, then:

Now to run again Transmission but with the modified config directory type on telnet or ssh:

/opt/bin/transmission-daemon -g /opt/.config/transmission-daemon/

3. If when you run Plowshare you happen to get an error like:

/usr/bin/ line 250: /dev/fd/62: No such file or directory

Its missing a symlink.
ln -s /proc/self/fd /dev/fd

Remember that when you reboot the symlink will be gone, so add it to the init scripts on administration.
Now your ready to plowup and plowdown :p

Credit: (Return to top)
All the credits of this guide goes to:
karog for sd-idle-2.6 (
The creator of
Teddy_b for
Rasky for
Lost_Animal for
ray123 for his critic but helpfull comments.
jomcty for his automount script.
And the autor of

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License