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) or to a flash drive in port 2 (sda2)
  • You have your user permissions set up for drive access working in the Linksys web interface
  • Your ipkg is current (ipkg update)


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))

Samba configuration (smb.conf, smbpasswd)

If you've done the copying of the Samba 2 configuration to the new Samba 3 directory, you will find that /opt/etc/samba/smb.conf and /opt/etc/samba/smbpasswd are just links to /share/hdd/conf/share/. After each reboot, the smb.conf and smbpasswd files in /share/hdd/conf/share/ are overwritten; files residing directly in /opt/etc/samba/ are not.

Samba 3 will read its configuration from /opt/etc/samba/, but the Linksys web interface will modify the Samba configuration in /share/hdd/conf/share/. This leaves the following options:

Option A: Remove the symlinks.

No diversion script is required. However, you lose the ability to modify the configuration via the Linksys web interface. In the future, modify the Samba configuration either by directly editing /opt/etc/samba/smb.conf or via the SWAT web interface.

To remove the symlinks, execute 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 .

then update the /opt/etc/samba/smb.conf for Samba 3 as shown in the next section.

Option B: Diversion script.

When rebooting the system the symlinked smb.conf and smbpasswd will be overwritten with the original Samba 2 version. To keep the Samba 3 files, you need a copy of them in a location where they will not be touched. The best spot for this is /unslung/

First, copy the original files to /unslung/:

cp /share/hdd/conf/share/smb.conf /unslung/
cp /share/hdd/conf/share/smbpasswd /unslung/

You will need to remove the link to the old file and point to the new file with a diversion script.


ln -sf /unslung/smb.conf /opt/etc/samba/smb.conf
ln -sf /unslung/smb.conf /etc/samba/smb.conf
ln -sf /unslung/smbpasswd /opt/etc/samba/smbpasswd
ln -sf /unslung/smbpasswd /etc/samba/smbpasswd
return 1

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

smb.conf modifications for Samba 3

Next, you will need to edit the smb.conf file so it will work with samba 3.0. The Samba project has a smb.conf man page which explains each of the parameters in detail. It is a useful reference to have while working on the configuration.

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
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 =
# the networks you want to allow connections from
hosts allow = 10.0.0. 10.0.1. 10.0.2.
hosts deny =
# ------------------

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

valid users=@"administrators"
read only=yes
write list=@"administrators"
[DISK 1]
valid users=@"administrators",@"everyone",@"linux"
comment=For everyone
browseable = yes
read only=yes
write list=@"administrators",@"everyone",@"linux"

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


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

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

The file is configured with three accessible shares. 1. A users 'home' folder, 2. a 'public' folder which can be accessed by any connecting client using netbios, and 3. 'read only' access to the full NSLU-2 directory structure.

The file configures Samba in 'User' mode. In this mode, a users 'home' folder is only accessible if the 'user name' and 'password' are identical on both the server and client.

A users 'home' folder and read only access to the full Linux directory tree 'ADMIN 1' are only accessible by using mapping on the client (for security they are non browseable).

Mapping example using the NSLU-2 netbios name - \\netbios_name_goes_here\ADMIN 1

Mapping example using the NSLU-2 IP address - \\\user_name_goes_here

For non-unslung firmware, like openwrt, you need to change guest account = nobody and force group = nogroup.

The directory /opt/var/spool/samba may need to be created and flagged chmod 755 (there may be other Samba working directories missing).

I recommend using the below conf file, change your workgroup name, the interface IP to your NSLU2 IP, hosts allow to your client IP range, don't use the Admin1 or Disk1 sections here. Instead copy only those 2 sections out of your old version 2 smb.conf file. If you do this, you should see the same shares behavior out of your Samba 3 install as you saw from Samba 2

# Samba config file created using SWAT
# from (
# Date: 2008/09/10 21:01:20

	workgroup = MSHOME
	server string = %h Server
	interfaces =, ixp0, lo
	bind interfaces only = Yes
        security = USER
	map to guest = Bad Password
	null passwords = Yes
	guest account = guest
	log file = /opt/var/samba/log.%m
	max log size = 10
	smb ports = 139
	name resolve order = wins bcast
	socket options = SO_SNDBUF=8192 SO_RCVBUF=8192
	load printers = No
	dns proxy = No
	kernel oplocks = No
	ldap ssl = No
	config file = /opt/etc/samba/smb.conf
	invalid users = root
	create mask = 0771
	force create mode = 0660
	force directory mode = 0771
	hosts allow =,,, localhost

	comment = Users Home Directories
	path = /%S
	valid users = %S
	read only = No
	create mask = 0700
	directory mask = 0700
	browseable = No

	comment = Print Spooler Directory
	path = /opt/var/spool/samba
	create mask = 0700
	printable = Yes
	browseable = No

	comment = Full Data Partition
	path = /
	valid users = @administrators
	write list = @administrators
	browseable = No

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

Finally, edit /opt/etc/init.d/S08samba to activate Samba:


# set samba_active=1 to activate samba

[ 1 = $samba_active ] || exit 0

Starting Samba

Now you are ready to restart

cd /opt/etc/init.d

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)

Troubleshooting installation and configuration

Using server comment to gather version information

The NSLU2 web interface lets you set a "Server comment". This corresponds to the smb.conf parameter "Server string". This string will appear in browse lists next to the machine name.

Samba recognises two special strings. %v will be replaced with the Samba version number. %h will be replaced with the hostname. Thus, a Server comment like Server %h with Samba %v will give you basic information about what version of Samba is running on your Slug.

Resolving 'Unable to open printcap file /opt/etc/printcap for read'

Note that some users have reported seeing messages in the Samba error logs similar to 'Unable to open printcap file /opt/etc/printcap for read'. This is probably because Samba is trying to open a nonexistant file. Easily fixed by logging in as user 'root' at a console screen and then check if the file exists. If not, create a blank file using the two commands:-

touch /opt/etc/printcap
chmod 0644 /opt/etc/printcap

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

interfaces configuration (Dec 2008, od3-ripe)

For me on unslung SWAT started reporting smbd/nmbd "not running" though they actually did. Took me some time to figure out what fixes this behavior. After adding also "localhost" to:

interfaces = 127.0.01/24, <myEth-IP>, ixp0, lo

it works, again. (Also see note about adding <myEth-IP> below - looks like "ipx0" and "lo" no longer get properly translated!?)

interfaces configuration (Samba 3.2, July 2008)

This version of Samba seems to need an IP/mask pair added to the 'interfaces' config line in the 'Global' section to work properly with Unslung firmware. A typical config line (assuming the default NSLU2 IP address) is:-

interfaces =, ixp0, lo
bind interfaces only = Yes

Further, it seems you MUST have "bind interfaces only = yes" in smb.conf, or else nmbd chokes. You can see the problem by starting nmbd in interactive mode: "nmbd -i -d 5". nmbd cannot find the interface unless you ALSO include the "bind interfaces only" line.

See the smb.conf man page on bind interfaces only for details.

Unable to connect in Samba 3.2.1-1 (9/27/08)

After struggling for days on end to get Samba running in Unslung 6.10 with an NTFS disk on Disk 1, I ran across this: http://www.nabble.com/Can%27t-Get-Upgrade-to-Samba-3.2.x-Working-td19361476.html

Basically, ran "ipkg install gconv-modules" and now my shares are working.

unix extensions / wrong share permissions (Ingo Karkat, 25-May-2009)

After upgrading to Samba 3, files created by user A (from a Linux client which mounted the Samba shares via CIFS) suddenly were not writable by user B, even though the configured share permissions gave write access to both users, and this worked flawlessly with Samba 2. This was caused by the following:

With Unix extensions enabled (by default), a Unix (not Windows!) client can set arbitrary file permissions (when mounting as cifs, not smbfs). To prevent this, one could configure a 'force create mode' + 'force directory mode' on individual shares, but it seems clients would still be allowed to chmod() later on, so this isn't totally watertight. If you don't need these extensions, it is best to turn them off globally, restoring the plain functionality of Samba 2.

unix extensions = no 

Resolving issue that file modification times aren't preserved when copying files

After a) unslinging my NSLU2 and b) upgrading my Mac OS X machine from Mac OS X 10.3 to 10.5, I noticed that when I copied files from my computer to the NSLU2's share, the modification times for the files were no longer preserved. They were reset to the current time. Also, the touch -t command from the Mac OS X command line to a file on the NSLU2's share failed to set the modtime to the specified value.

Adding a %v to my server comment, I discovered that I was running Samba 3.0.11. I upgraded Samba to the current (as of December 2009) version in ipkg, which was 3.2.15-1. After this, my Mac OS X system preserved modtimes when copying files to the NSLU2's share. Also, the touch -t command now succeeded. -- Jim DeLaHunt?, Vancouver, Canada, December 2009.


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.

Configuring optional features

SWAT (Samba Web Administration Tool)

See the separate SWAT page.

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