Slim samba2

From DD-WRT Wiki

Revision as of 01:31, 24 January 2009 by Alvin (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Contents

Slim Samba2 for USB

Based on the work of patwood I have made a quick-and-easy and slimmed down version of Optware Samba2. I call it "Slim Samba2 for USB", and it is only made for Broadcom MIPS-based CPU routers. This includes the Asus, Linksys, and Buffalo routers supported by dd-wrt. For other CPUs you need the full Optware Samba packages.

Out-of-the-box Slim Samba2 (v.4) has been designed to run on USB drive with one or three partitions.

Slim Samba it self is installed and run from the first partition (/mnt) on the USB drive, as this works well with the USB and NAS settings in the web-GUI.

With Slim Samba v.4 use of a three partition drive will automatically be detected, and /mnt/data will automatically be mounted on the third partition.

User data is ment to be in the folder /mnt/data. You may however adjust this to your hearts content, and smb.conf has been prepared such that you can just unmark (remove #) from several of the lines in smb.conf - but for standard file server, SlimSamba should work fine out-of-the-box


Prepare for slim-samba-usb

  • Tested with Eko version V24TNG-svn11218.
  • 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/samba.usb
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 /opt/usr/sbin/unplug.usb
Click "Save Shutdown"


In Services -> NAS -> ProFTPD

Anonymous Login can be enabled if desired
and "Anonymous Home Sub-directory" can be set to /data/public


Install slim-samba2-usb on a USB drive using you router and a terminal

In a (putty) terminal type in these commands

cd /mnt
wget http://www.3iii.dk/linux/dd-wrt/slim-samba-usb.tar.gz
tar xvzf slim-samba-usb.tar.gz 
./samba.usb

And you should be up and running!


USB is designed to be hot-plug, and everything will automatically start next time you boot the router, or next time you plug-in the USB drive.


Before you un-plug the USB drive from a live router you should however run the command:

 sh /tmp/unplug.usb

Just to make sure all files on your USB drive are closed properly.


Install slim-samba-usb on a USB drive using a Linux PC

a) Download the file http://www.3iii.dk/linux/dd-wrt/slim-samba-usb.tar.gz

b) Unpack the files from slim-samba-usb.tar.gz to the USB drive

c) You should minimum see the following in the root of your USB drive

folder:  data
folder:  opt
file:      samba.usb
file:      unplug.usb

d) You may want to change the workgroup name in /USBdrive/opt/etc/samba/smb.conf (see below for guide)

e) When you have set the web-GUI of you router, un-mount the USB drive from you Linux PC and plug it into your dd-wrt box. And you should be up and running.


Customise your slim-samba2-usb Windows Workgroup name

You may have to edit /opt/etc/samba/smb.conf to fit your Windows Workgroup name, or you could just use the default Windows workgroup name "workgroup" on your windows pc's.

To edit the smb.conf file in a terminal with the vi editor do the following

vi /opt/etc/samba/smb.conf

Find the line: workgroup=workgroup and change it to your windows workgroup name
If you workgroup name is "valhalla" you would change the line to: workgroup=valhalla

Note: vi hints:
When you open vi it is in command mode (you see a - at the bottom left of your screen)
  • press i to enter edit mode (you see an I at the bottom left of your screen)
  • press ESC to exit edit mode and enter command mode
When in command mode
  • press :wq ENTER to give the commands write and quit
  • press :q! ENTER to quit without saving changes
  • press :q ENTER to quit if you have made no changes
When you understand that vi has the two modes of operation, command mode and edit mode, and how :easy it is to switch between the two, vi can actually become one of your best Linux friends.
  • to delete a line - be in command mode - and press dd
google "linux vi command" for more vi commands
Note: You could also use WinSCP to locate and edit script files, as an editor is included in WinSCP.


How to access Samba shared drives from windows

If your pc is in the same workgroup as Samba (default: workgroup) then you just go to Neighbourhood in Windows Explorer and a new machine (default: DD-WRT) should appear.

You can also go directly to the Samba server in Windows by typing the IP number of your router in the address bar of Windows Explorer like: \\192.168.1.1

You should see data and printers folder


If your routers LAN IP does not begin with 192.168.

If you use an IP range for your network that is not in the 192.168.x.x range, you need to edit /opt/etc/samba/smb.conf line hosts allow = to include your IP range.

If you for example use 10.0.0.x for your local network, you could change the line to be

hosts allow = 192.168.  10.0.0.  127.

or simply

hosts allow =  10.0.0.  127.


Did everything go right

You can use one or more of the following commands to see if your slim-samba2-usb install went well

Check the active processes using the ps command

:~# ps
 PID USER       VSZ STAT COMMAND
        ~ snip ~
 163 root      1792 S    proftpd: (accepting connections)
        ~ snip ~
 224 root      3588 S    /opt/sbin/smbd -D
 231 root      2280 S    /opt/sbin/nmbd -D
        ~ snip ~

Check to see if /opt has been mounted using the ls, df or mount commands

:~# ls /opt
etc   lib   sbin  var
:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                 2304      2304         0 100% /
/dev/discs/disc0/part1  241116     10138    218530   4% /mnt
/dev/discs/disc0/part1  241116     10138    218530   4% /opt
:~# mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
none on /dev type devfs (rw)
proc on /proc type proc (rw)
ramfs on /tmp type ramfs (rw)
/dev/discs/disc0/part1 on /mnt type ext3 (rw)
/dev/discs/disc0/part1 on /opt type ext3 (rw)

A comment about PATH, LD_LIBRARY_PATH and a custom profile

So long as you use dd-wrt EKO svn11218 or newer, there should be no need to adjust anyting in the /etc/profile, as the new default profile is optimised to work better with Optware based packages.

Use command set to see how PATH and LD_LIBRARY_PATH already include /opt... paths