Samba3

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 12:40, 13 October 2010 (edit)
Masterman (Talk | contribs)
m (Let's begin!)
← Previous diff
Current revision (20:29, 22 June 2012) (edit) (undo)
Glenn (Talk | contribs)
(+ Category:Samba)
 
(9 intermediate revisions not shown.)
Line 10: Line 10:
Tested on: Tested on:
* DD-WRT v24-sp2 SVN 14848 NEWD-2 K2.6 mini usb ftp (7/27/2010) * DD-WRT v24-sp2 SVN 14848 NEWD-2 K2.6 mini usb ftp (7/27/2010)
-* Frater's Optware the right way Versioned: Sat Jun 19 10:22:03 CEST 2010+* DD-WRT v24-sp2 SVN 15962 NEWD-2 K2.6 Mega ((12/24/10))
 +* Frater's Optware the right way Versioned: Sat Jan 10 10:22:03 CEST 2011
-Prerequisite:+Prerequisites:
-* Install [http://www.dd-wrt.com/wiki/index.php/Optware%2C_the_Right_Way Frater's Optware the right way]. Do not proceed any further if you haven't installed it successfully.+* Install [http://www.dd-wrt.com/wiki/index.php/Optware%2C_the_Right_Way Frater's Optware the right way]. Do '''NOT''' proceed any further if you haven't installed it successfully.
 +* Know how to use [http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe PuTTy] , a portable Telnet/SSH program that does NOT need installation.
 +
 +* Make sure SSH is enabled under the Services tab in the routers Web-Interface.
For users who don't know how to edit files with vi: For users who don't know how to edit files with vi:
Line 24: Line 28:
==Let's begin!== ==Let's begin!==
 +Open Putty and make sure SSH is enabled on your router under Services -> SSH Management
Make a copy of smb.conf file and S80samba to a temporary location, we will edit those files later. Make a copy of smb.conf file and S80samba to a temporary location, we will edit those files later.
Line 55: Line 60:
hosts allow = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 127.0.0.0/8 hosts allow = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 127.0.0.0/8
- [homes]+ [homes]
valid users = %S valid users = %S
read only = No read only = No
Line 68: Line 73:
use client driver = Yes use client driver = Yes
browseable = No browseable = No
- 
[PUBLIC] [PUBLIC]
path = /mnt path = /mnt
Line 91: Line 95:
-Remove samba 2 and install samba 3.5 +Remove samba 2 and install samba 3.5 and SWAT
ipkg-opt remove samba2 ipkg-opt remove samba2
- ipkg-opt install samba 3.5+ ipkg-opt install samba35
- + ipkg-opt install samba35-swat
Line 120: Line 124:
= Partition and format your USB drive = = Partition and format your USB drive =
 +
 +'''NOTE''' This does not pertain to frater's [[Optware, the Right Way]]
 +
 +
You need to first partition and format your drive You need to first partition and format your drive
: This can be done by attaching the drive to an other system like: : This can be done by attaching the drive to an other system like:
Line 135: Line 143:
= Prepare for samba3 = = Prepare for samba3 =
 +
 +'''NOTE''' This does not pertain to frater's [[Optware, the Right Way]]
 +
 +
* 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) * 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 Mini_usb_ftp version your partition must be ext3
Line 198: Line 210:
= Install samba3 = = Install samba3 =
 +
 +'''NOTE''' This does '''NOT''' pertain to [[Optware, the Right Way]]
<nowiki>wget -O /tmp/ConfSamba3.usb http://www.dd-wrt.com/phpBB2/download.php?id=11668</nowiki> <nowiki>wget -O /tmp/ConfSamba3.usb http://www.dd-wrt.com/phpBB2/download.php?id=11668</nowiki>
Line 213: Line 227:
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'' 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 [http://www.dd-wrt.com/phpBB2/viewtopic.php?t=59668 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 S80samba). 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 S80samba. 
- 
- #!/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 S80samba), and run the script (root@WRT610N:# /opt/etc/init.d/S80samba) 
- 
-*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! 
[[Category:Samba]] [[Category:Samba]]

Current revision

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

[edit] Upgrading to Samba 3.5

Based on HDsamba2 update to samba3


Tested on:

  • DD-WRT v24-sp2 SVN 14848 NEWD-2 K2.6 mini usb ftp (7/27/2010)
  • DD-WRT v24-sp2 SVN 15962 NEWD-2 K2.6 Mega ((12/24/10))
  • Frater's Optware the right way Versioned: Sat Jan 10 10:22:03 CEST 2011


Prerequisites:

  • Know how to use PuTTy , a portable Telnet/SSH program that does NOT need installation.
  • Make sure SSH is enabled under the Services tab in the routers Web-Interface.

For users who don't know how to edit files with vi:

  • On your computer create a network drive to your shared usb partition (ex 192.168.1.1/public). That way you can access and edit samba configuration files using your favorite text editor (ex wordpad).


[edit] Let's begin!

Open Putty and make sure SSH is enabled on your router under Services -> SSH Management

Make a copy of smb.conf file and S80samba to a temporary location, we will edit those files later.

For vi users:
   cp /opt/etc/samba/smb.conf /opt/etc/samba/smb.conf.copy
   cp /opt/etc/init.d/S80samba /opt/etc/init.d/S80samba.copy
 
For users who want to edit those files on their computers:
   cp /opt/etc/samba/smb.conf /mnt/smb.conf.copy
   cp /opt/etc/init.d/S80samba /mnt/S80samba.copy 


Edit smb.conf.copy with your editor of choice and add the following line under the [global] section. Note: replace 192.168.1.1 with your router's ip address if different.

interfaces = 192.168.1.1/24

You smb.conf should look like this:

[global]
       server string = DD-WRT-NAS
       interfaces = 192.168.1.1/24
       security = SHARE
       encrypt passwords = No
       log file = /opt/var/log/samba/log.%m
       max log size = 50
       socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
       printcap name = /dev/null
       dns proxy = No
       wins support = Yes
       remote announce = 192.168.x.255
       hosts allow = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 127.0.0.0/8
 [homes]
       valid users = %S
       read only = No
       browseable = No
[printers]
       comment = All Printers
       path = /opt/var/spool/samba
       read only = No
       guest ok = Yes
       printable = Yes
       use client driver = Yes
       browseable = No
[PUBLIC]
       path = /mnt
       valid users = www-data, nobody, root
       force user = root
       read only = No
       create mask = 0765
       guest ok = Yes


Skip the following step if you used vi to edit your files. Otherwise if you used the network drive to access and edit smb.conf.copy, move the files somewhere safe as we're about to stop samba2 and unmount your usb drive.

mv /mnt/smb.conf.copy /opt/etc/samba/smb.conf.copy
mv /mnt/S80samba.copy /opt/etc/init.d/S80samba.copy


Stop existing samba services.

service samba stop
service samba off


Remove samba 2 and install samba 3.5 and SWAT

ipkg-opt remove samba2 
ipkg-opt install samba35
ipkg-opt install samba35-swat


Copy smb.conf.copy and S80samba.copy back where they belong.

 cp /opt/etc/samba/smb.conf.copy /opt/etc/samba/smb.conf
 cp /opt/etc/init.d/S80samba.copy /opt/etc/init.d/S80samba


Delete S08samba which was created by the Samba 3.5 install, as well as the S80samba.copy (or move it out of /opt/etc/init.d).

rm  /opt/etc/init.d/S08samba 
rm /opt/etc/init.d/S80samba.copy


Restart samba services .

service samba on
service samba start


Reboot, and enjoy Samba 3.5!

reboot

[edit] Partition and format your USB drive

NOTE This does not pertain to frater's Optware, the Right Way


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.

[edit] Prepare for samba3

NOTE This does not pertain to frater's Optware, the Right Way


  • 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

[edit] Install samba3

NOTE This does NOT pertain to Optware, the Right Way

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.

[edit] 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