From DD-WRT Wiki

Revision as of 05:50, 18 November 2009 by Baltico (Talk | contribs)
Jump to: navigation, search

Since samba2 has issues with files of size >2Gb and <4Gb you may want to use samba3. It is more resource consuming though, and you probably will need a swap if your router has less than 32Mb RAM or running other RAM consuming programs


Partition and format your USB drive

You need to first partition and format your drive

This can be done by attaching the drive to an other system like:
  • a PC running linux (maybe from a LiveCD)
  • a Windows PC using a partitioning tool
  • a windows PC with VirtualBox running a Linux guest system
  • Some have been able to use their iPod.

First partition on your drive needs to be ext2 or ext3. ext3 is more fault tolerant, so could be a better choice in general.

For use with Eko Mini_usb_ftp, the first partition needs to be ext3,
for use with Mega builds, the first partition can be formatted as ext2 or ext3

You do not need more than one partition on you USB drive to use Samba3, but you may also use it with a three partition drive, as is common place when used with a HD.

Prepare for samba3

  • Tested with Eko 24-sp2 (09/01/09) mini-usb-ftp - build 12774M NEWD.
  • For Mini_usb_ftp version your partition must be ext3
  • For Mega version your partition can be either ext2 or ext3

Enable USB in web-GUI and set

enable USB1.1, USB2 as neded for your router and usb drive
enable "USB Storage Support"
enable "ext2 / ext3 File System Support"
enable "Automatic Drive Mount"
set "Run-on-mount Script Name" to /mnt/
set "Disk Mount Point" /mnt

For good meassure you should also set shutdown commands in web-GUI

tab: Administration -> tab: Commands -> text field: Commands ->
write this line
 sh /jffs/usr/bin/unplug.usb
Click "Save Shutdown"

Prepare your router to install Optware For simplicity you may just create folder /mnt/opt and in terminal run

mount /mnt/opt /opt 
wget -O - | tr -d '\r' > /tmp/
sh /tmp/

It may be a good idea to set up a swap file

Create script file /mnt/ with something like this:

mount /mnt/opt /opt
sleep 2
# if you need SWAT, uncomment the following^
#/bin/sh /opt/etc/init.d/S10xinetd 

It will launch samba daemon automatically every time after disc mounting. SWAT is Samba Web Admin Tool. You can use it at

Create script file /jffs/usr/bin/unplug.usb with something like this:

#=========stop samba============
echo "Stopping smbd:"
killall smbd
echo "Stopping nmbd:"
killall nmbd
#==========stop xinetd==========
echo "Stopping xinetd:"
killall xinetd 

make both scripts executable

chmod +x /jffs/usr/bin/unplug.usb
chmod +x /mnt/

Install samba3

wget -O /tmp/ConfSamba3.usb
chmod +x /tmp/ConfSamba3.usb
sh /tmp/ConfSamba3.usb

type ps in terminal to check out if processes smbd, nmbd and optionally xinetd are running.


You may tweak performance in the /opt/etc/samba/smb.conf file in this line

	socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 

Bigger values for SO_xxxBUF usually mean slightly better performance. For D-Link_DIR-320, for example, increasing those values to 65536 gives 20% writing speed boost

You may check out resource consumption using top command If you don't need symbolic names and can use samba by IP address ( e.g. like \\\data ) You do not need nmbd. So you may tweak scripts to not load it or to kill it right after it was loaded by /opt/etc/init.d/S08samba through killall nmbd