NSLU2-Linux
view · edit · print · history

Installing Samba >=3.0.14a-4 on Unslung 4.2x beta or later

Assumptions for these instructions

  • You have installed unslung 4.20 or later
  • You have unslung to the first disk drive (sda1)
  • You have your user permissions set up for drive access working in the Linksys web interface
  • Your ipkg is current (ipkg update)

I've not tested any of this on pre 4.2 releases.

Install

 
ipkg install samba

Post-install setup

First, copy the default samba config files over to the new samba directory:

 
cp -pR /etc/samba /opt/etc

(Please note that on OpenSlug, the config file is on /usr/lib/smb.conf (old) or /etc/samba (new))

Next, you will need to edit the /opt/etc/samba/smb.conf file so it will work with samba 3.0.

If you're new to Linux editors, the vi editor which comes standard with UnSlung is very unfriendly (google "vi" to learn the basics). The nano editor ("ipkg install nano") is much more intuitive. Alternatively use your favourite editor on your favourite operating system and ftp the resulting file to the nslu2.

 An example smb.conf file that works is:
 
# sample samba 3.0 conf file
[global]
log level = 1

# CHANGE these settings to match your network/workgroup setup
# ------------------
workgroup = WORKGROUP
server string = NSLU Network Drive
netbios name = usbdrive
# your wins server ip address
wins server = 10.0.0.1
# the networks you want to allow connections from
hosts allow = 127.0.0.1 10.0.0. 10.0.1. 10.0.2.
hosts deny = 0.0.0.0/0
# ------------------

config file=/opt/etc/samba/smb.conf
os level = 8
load printers = no
max log size = 10
security = user
encrypt passwords = yes
smb passwd file = /opt/etc/samba/smbpasswd
socket options = TCP_NODELAY SO_KEEPALIVE SO_SNDBUF=16384 SO_RCVBUF=16384
preferred master = no
local master = yes
dns proxy = no 
preserve case = yes
short preserve case = yes
default case = upper
case sensitive = no
mangled names = yes 
null passwords = yes
username map = 
dos filetimes = yes
force directory mode=771
force create mode=660
create mask=771
map system=yes
map to guest=Bad User
guest account=guest
guest ok = yes
bind interfaces only = yes
interfaces = ixp0 lo
winbind use default domain = no

[ADMIN 1]
valid users=@"administrators"
comment=
path=/share/hdd/data/
read only=yes
write list=@"administrators"
[DISK 1]
valid users=@"administrators",@"everyone",@"linux"
comment=For everyone
path=/share/hdd/data/public/
browseable = yes
read only=yes
write list=@"administrators",@"everyone",@"linux"

Another second example smb.conf file generated using the Swat utility. Optimised for Unslung firmware (added by RobHam Sept 2007).

Note - for Debain firmware change the interfaces line to interfaces = eth0, lo

Also note - for non-unslung firmware, like openwrt, you need to change guest account=nobody from guest

 
# Samba config file created using SWAT
# from 192.168.2.50 (192.168.2.50)
# Date: 2007/09/25 20:35:19

[global]
	workgroup = MSHOME
	server string = Samba %v Network Drive
	interfaces = ixp0, lo
	bind interfaces only = Yes
	map to guest = Bad User
	null passwords = Yes
	guest account = guest
	log file = /opt/var/samba/log.%m
	max log size = 10
	name resolve order = wins bcast
	socket options = SO_SNDBUF=8192 SO_RCVBUF=8192
	load printers = No
	printcap name = /opt/etc/printcap
	dns proxy = No
	ldap ssl = no
	config file = /opt/etc/samba/smb.conf
	lock directory = /var/samba3
	pid directory = /var/samba3
	create mask = 0771
	force create mode = 0660
	force directory mode = 0771
	hosts allow = 192.168., 172., 10., localhost

[ADMIN 1]
	comment = Full Data Partition
	path = /
	valid users = @administrators
	write list = @administrators

[DISK 1]
	comment = Public Folder Tree For Everyone
	path = /public/
	valid users = @administrators, @everyone
	write list = @administrators, @everyone
	read only = No
	guest ok = Yes

Finally, edit /opt/etc/init.d/S08samba, remove comments:

 
#!/bin/sh

# please remove '#' to activate the start script.

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 --configfile=/opt/etc/samba/smb.conf;
echo "Starting smbd:"
 /opt/sbin/smbd -D --configfile=/opt/etc/samba/smb.conf;

Now you are ready to restart

 
cd /opt/etc/init.d
./S08samba

If all goes well, the stock samba will stop and your new samba will start. Don't be suprised if running a "ps" shows two smbd & nmbd tasks, compared to one each previously. This is normal.

(On OpenSlug, you need to use /etc/init.d/samba restart)

I've tested this setup, it seems to work correctly and maintain compatibility with the Linksys web interface and the Storage Link windows tray app that mounts USB Memory sticks when inserted into slot 2.

From FVH: On my setup (Unslung 5.5 with Samba 3.0.21) the following diversion scripts / update tricks were not required. Samba 3 functions correctly after reboots. Getting Samba 3 running was literally as simple as: ipkg update ; ipkg install samba ; create /opt/etc/samba/smb.conf ; edit /opt/etc/init.d/S08samba. Then restart. That's all.

Update: Thanks to Inge Bjørnvall Arnesen
Reference links: AddPrinter EnableWinsServer

Diversion script

You will find that the smb.conf file does stick and revert to orginal during a turn off/turn on... You have to set a diversion script in /unslung Create a file rc.samba to include the below

 
#! /bin/sh
# Diversion script: customize before starting crond
#
#

# Make sure we have a backup copy of /etc/samba/smb.conf
if [ ! -e /etc/samba/smb.conf.orig ]; then 
  cp -p /etc/samba/smb.conf  /etc/samba/smb.conf.orig 
fi

return 1

Alternate Update Method

When rebooting the system the file smb.conf will be overwritten with the original samba 2 version. To keep the version 3 file, you need a copy of it in a location where it will not be touched. The best spot for this is /unslung Once you have created your smb.conf, you will need to remove the link to the old file and and point to the new file with a diversion script.

rc.samba

 
#!/bin/sh
ln -sf /unslung/smb.conf /opt/etc/samba/smb.conf
ln -sf /unslung/smb.conf /etc/samba/smb.conf
return 1

This should allow you to fully use the web interface, keep both file locations intact and not have to start the v2 server before starting the v3.

Alternate update method 2

After each reboot, the smb.conf and smbpasswd files in /opt/etc/samba directory are overwritten. Having a look closer, you can see that :

  • /opt/etc/samba/smb.conf and /opt/etc/samba/smbpasswd are just links to /share/hdd/conf/share/
  • links in /opt/etc/samba/ are never overwritten
  • only files in /share/hdd/conf/share/ are overwritten at each boot

No script is required (that's why I think it's easier than writing a diversion script). Just type the following commands :

  
cd /opt/etc/samba
rm smb.conf
rm smbpasswd
cp /share/hdd/conf/share/smb.conf .
cp /share/hdd/conf/share/smbpasswd .
 

and then only I update the /opt/etc/samba/smb.cong file as shown below.


Be aware of ipkg upgrade of samba package to 3.0.14a-5. It may break your existing samba configuration and make files unsharable.


Make sure you edit the "hosts allow = 127.0.0.1 10.0.0. 10.0.1. 10.0.2." section to include your network.

sample:

 
host allow: 127.0.0.1 10.0.0. 10.0.1. 10.0.2. 192.168.0. 192.168.1.

Alternate update method 3

I created the smb.conf file in /opt/etc/samba and started the slug. There was no need for a diversion script. Running Unslung 6.8 and samba 3.0.25a


If your users can´t connect to their shares and you see errors like "Can't become connected user!" in the log-file (/opt/var/samba/log.smbd) and you use the alternate update method: copy /etc/smbpasswd to /unslung/ and add the following lines to your diversion script

Please note that on OpenSlug, the log file is on /var/log/log.smbd.

(rc.samba):

 
ln -sf /unslung/smbpasswd /opt/etc/samba/smbpasswd
ln -sf /unslung/smbpasswd /etc/samba/smbpasswd

SAMBA web config tool

If you want to enable SWAT, the Samba web config tool included in the package, you should edit your rc.xinetd diversion script. The diversion script should be in your Unslung directory.

Warning : If you already created a rc.xinetd diversion script, you should only add the part from 'if' to 'fi' and insert it before the 'return 1' in your orginal script. Deleting or editing the other content may result in disabled services, which for example could disable your telnet access.

If you add the following content, SWAT should work out of the box:

  
#!/bin/sh
# Diversion script: /unslung/rc.xinetd
# Customize for your own use, do not delete your original content!
#

if ( [ ! -f /etc/inetd.conf ] || !(grep swat /etc/inetd.conf -q) ) then
  echo "swat stream tcp nowait root /opt/sbin/swat swat" >>/etc/inetd.conf
fi

return 1
 

Once that is done just point your browser to http://IP-address-of-your-slug:901, and enjoy. More info on Samba 3 (inclusing SWAT) can be found on the web at: http://us3.samba.org/samba/docs/man/

Full control off SWAT is only given if you logon as root, otherwise functionality will be limited! A normal user only get the buttons: Home, Status, View and Password. The root users also gets the buttons to manage shares.

International character support or Unicode support

If you want to store files from Windows using foreign characters from languages like Chinese, Japanese, Korean, etc you definitely need Samba 3, as it supports this out of the box.

Here is what you should add to [global] section of the smb.conf for Samba 3.X.X to enable Cyrillic (Russian) support for Windows XP clients

 
unix charset = UTF-8
display charset = UTF-8
dos charset = 866
 

I use these settings for support of Norwegian and Portugeese characters in filenames under Unslung 6.8 (samba 3): unix charset = UTF-8 dos charset = CP850 display charset = ISO-8859-1 I put these settings into /unslung/smb.conf and put the rc.samba in the same directory (comment away the first line). You also have to change the config file name in /unslung/smb.conf.

File size >= 2G and remote smbfs mount

When mounting smbfs the default does not include large file support, which limits files to less than 2 gigs. Using the lfs option will include large file support. Google "smbfs lfs option", since it seems to be missing from most documentation.

A better option is to use cifs, if it's supported by your kernel/distribution/version. When mounting cifs, large files are supported by default.

So either : mount -t smbfs //server/share /mountpoint -o lfs other-options or mount -t cifs //server/share /mountpoint -o options

Page last modified on March 05, 2008, at 12:42 AM