Samba3

From DD-WRT Wiki

Revision as of 20:53, 6 April 2010 by Cjason (Talk | contribs)
Jump to: navigation, search

Since samba2 has issues with files of size >2Gb and <4Gb and has no unicode support, 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!

Be sure to also check out the HDsamba script located in the forums if you want an all in one installation!

Contents

Installing Samba 3.5 Manually [LATEST (13/3/10)]

Tested on Frater's Optware: The Right Way (Optware is MANDATORY!) under K2.6 (13972)

  • Step 1: If you have not already got optware (I recommend Frater's optware script, do install it now before proceeding.
  • Step 2: Run this command to download and install samba 3.5:
 ipkg-opt install samba35
  • Step 3 [optional]: When that has finished installing, if you want SWAT (Samba Web Administration Tool), run the command:
 ipkg-opt install samba35-swat
  • Step 4: You will notice that samba isn't working out of the box. Go into /opt/etc/samba , and paste the following in a new file called smb.conf :
 [global]
       server string = ROUTER NAME HERE
       interfaces = br0, lo, 192.168.1.1/24
       security = SHARE
       remote announce = 192.168.1.255
       hosts allow = br0, lo, 192.168.1.1/24

This is the bare minimum that Samba/SWAT needs to work (especially the interfaces it interacts on). Please edit the IP addresses to match yours (most users shouldn't need to change this on Linksys routers).

  • Step 5: Go into /opt/etc/init.d , and look for a SXXsamba (Mine was called S08samba). Open up the script, and edit the samba_active=0 to samba_active=1. If this file doesn't even exist, paste the following into a new file called S08samba.
 #!/bin/sh
 # set samba_active=1 to activate samba
 # define NAME variable for the CLI "service" command to list samba status
 NAME=samba
 samba_active=1
 [ 1 = $samba_active ] || exit 0
 if [ -n "`pidof smbd`" ] ; then
     echo "Stopping smbd:"
     killall smbd
 fi
 if [ -n "`pidof nmbd`" ] ; then
     echo "Stopping nmbd:"
     killall nmbd
 fi
 sleep 2 
 echo "Starting nmbd:"
 /opt/sbin/nmbd -D
 echo "Starting smbd:"
 /opt/sbin/smbd -D
  • Step 6: Make sure that your startup script has an executable and read permission (chmod +rx S08samba), and run the script (root@WRT610N:# /opt/etc/init.d/S08samba)
  • Step 7: It is recommended that new comers (especially those with no experience) use SWAT. Head your browser over to http://your-routers-ip:901, and set up accordingly. If you are an advanced user, and can navigate through samba's configuration file with ease, directly edit the smb.conf file (/opt/etc/samba/smb.conf)

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. Also working on K2.6 kernel (13972 BS std-ftp-usb)
  • 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/mounted.sh
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 /tmp/umount.sh
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 http://www.3iii.dk/linux/optware/optware-install-ddwrt.sh -O - | tr -d '\r' > /tmp/optware-install.sh
sh /tmp/optware-install.sh

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

Create script file /mnt/mounted.sh with something like this:

#!/bin/sh 

mount /mnt/opt /opt
sleep 2
cp /mnt/umount.sh /tmp/umount.sh
chmod +x /tmp/umount.sh

# /opt/bin/busybox swapon /mnt/myswap.swp

/opt/etc/init.d/S08samba 
# if you can use IP machine identifications e.g. \\192.168.1.1\ uncomment the following
# killall nmbd
# 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 http://192.168.1.1:901/

Create script file /mnt/umount.sh with something like this:

#!/bin/sh 
#=========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 /mnt/umount.sh
chmod +x /mnt/mounted.sh

Install samba3

wget -O /tmp/ConfSamba3.usb http://www.dd-wrt.com/phpBB2/download.php?id=11668
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.

Tweaks

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 \\192.168.1.1\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


Alternative Way of Installing Samba 3

Tested on Frater's Optware: The Right Way (Optware is MANDATORY!) under K2.6 (13972)

Since there were many users having problems installing it, I have decided to put up these instructions.

  • Step 1: If you have not already got optware (I recommend Frater's optware script, do install it now before proceeding.
  • Step 2: Assuming you have Samba 2 uninstalled (ipkg-opt remove samba2), go ahead and run the command:
 ipkg-opt install samba
  • Step 3 [optional]: When that has finished installing, if you want SWAT (Samba Web Administration Tool), run the command:
 ipkg-opt install samba3-swat
  • Step 4: You will notice that samba isn't working out of the box. Go into /opt/etc/samba , and paste the following in a new file called smb.conf :
 [global]
       server string = ROUTER NAME HERE
       interfaces = br0, lo, 192.168.1.1/24
       security = SHARE
       remote announce = 192.168.1.255
       hosts allow = br0, lo, 192.168.1.1/24

This is the bare minimum that Samba/SWAT needs to work (especially the interfaces it interacts on). Please edit the IP addresses to match yours (most users shouldn't need to change this on Linksys routers).

  • Step 5: Go into /opt/etc/init.d , and look for a SXXsamba (Mine was called S08samba). Open up the script, and edit the samba_active=0 to samba_active=1. If this file doesn't even exist, paste the following into a new file called S08samba.
 #!/bin/sh
 # set samba_active=1 to activate samba
 # define NAME variable for the CLI "service" command to list samba status
 NAME=samba
 samba_active=1
 [ 1 = $samba_active ] || exit 0
 if [ -n "`pidof smbd`" ] ; then
     echo "Stopping smbd:"
     killall smbd
 fi
 [ -n "`pidof nmbd`" ] ; then
     echo "Stopping nmbd:"
     killall nmbd
 fi
 sleep 2 
 echo "Starting nmbd:"
 /opt/sbin/nmbd -D
 echo "Starting smbd:"
 /opt/sbin/smbd -D
  • Step 6: Make sure that your startup script has an executable and read permission (chmod +rx S08samba), and run the script (root@WRT610N:# /opt/etc/init.d/S08samba)
  • Step 7: Depending on if your confident enough, SWAT should now work. Head your browser over to http://your-routers-ip:901, and set up accordingly.

I hope this works for many other people and not just myself!