Configure Samba in Linux

From DD-WRT Wiki

Jump to: navigation, search

In this HOWTO we're going to prepare a Samba Filesystem Samba share specific for JFFS. This will work in several GNU/Linux distributions.


[edit] Install Samba

Open a terminal and write this:

On Ubuntu:

sudo aptitude install samba

On Debian (as root):

aptitude install samba

On Fedora (as root):

yum install samba

On Suse (as root):

smart install samba

[edit] Configuring Samba

First do a backup of the default configuration:

mv /etc/samba/smb.conf /etc/samba/smb.conf.backup

Then open the configuration file with your favorite text editor (vim, nano, emacs, gedit, kate)

vim /etc/samba/smb.conf

And write this:

  workgroup = CHANGETHIS
  server string = %h server
  log file = /var/log/samba/log.%m
  security = user
  invalid users = root
  load printers = no

  comment = JFFS for DD-WRT
  path = /mnt/jffs
  browseable = no
  valid users = jffsuser
  read only = no

Now you have to restart samba service

In Debian (as root): /etc/init.d/samba restart

In Ubuntu:

sudo /etc/init.d/samba restart

In RPM based distributions like RedHat, Suse, CentOS, Fedora (as root):

service samba restart 

or maybe

service smb restart

[edit] Extra commands

With the configuration file we've done before, you've to create the directory for the mount:

mkdir /mnt/jffs

Then create the user in the system, assign it a password and answer several questions. We're also saying that his home directory is /mnt/jffs (same location that we put in the configuration file) and that he doesn't have a valid shell:

adduser jffsuser --home /mnt/jffs --shell /bin/false

As the output should tell you, home directory doesn't have the right permissions, let's change it (as root, of course):

chown jffsuser:jffsuser /mnt/jffs

At the end you should create the password for Samba access. It can (and should) be different from the user system password. As this is the first time we've assign the user a Samba password, you must use -a:

smbpasswd -a jffsuser

[edit] Test it

You can test it by entering this in direction bar in Konqueror or Nautilus:




Then you can create a file (eg: lala.txt) and check it:

$ls -l /mnt/jffs
total 4
-rwxr--r-- 1 jffsuser jffsuser 2 2009-03-04 06:39 lala.txt*

[edit] Troubleshooting

Check if user is created in the system:

$ grep jffs /etc/passwd

Check if the directory is created and have right permissions:

$ ls -ld /mnt/jffs 
drwxr-xr-x 2 jffsuser jffsuser 4096 2009-03-13 21:55 /mnt/jffs/

Change Samba password to the user:

smbpasswd jffsuser 

Check smb.conf syntax: