NSLU2-Linux
view · edit · print · history

Create A Single Samba Share For 2 Harddisks

This is so you be able to access both harddisk in Windows ("Map Network Drive") by using only one samba share. So you will only need to map 1 network drive letter for both harddisks attached to port 1 and 2 on the NSLU2.

Note:

This presumes that you have unslung 6.8 installed on your nslu2

Steps:

  1. Login to the NSLU2 using SSH or Telnet.
  2. Change to the /share directory:

    cd /share
  3. This directory contains two automatically created directories for mounting the harddisks attached on port 1 and 2:
    /share/hdd is for harddisk on port 1
    /share/flash is for harddisk on port 2
    Usually the default samba configuration will share /share/hdd as "DISK 1" and /share/flash as "DISK 2" automatically. The idea of this howto is to create your own share which will internally contain links to both /share/hdd and /share/flash.
    For this purpose we will create a new directory under /share and call it e.g. "public":

    mkdir /share/public
  4. Now you must change ownership of this directory to match those of the other two predefined folders (or you will not be able to access this directory using smb):

    chown admin:everyone /share/public
  5. After that we should change the access rights of this directory to read-only. This necessary because the /share/public directory is not actually on a harddisk but merely a directory on the linksys, so we need to prevent samba users from writing anything to this directory.

    chmod 555 /share/public
  6. Now we create symbolic links to the directories that you want to share. In our case it is the public share on both harddisks (but you can put links to anything else you like):

    ln -s /share/hdd/data/public /share/public/disk1
    ln -s /share/hdd/data/HDD_1_1_1 /share/public/disk1 *)
    ln -s /share/flash/data/public /share/public/disk2

    *) use this instead if you are using 6.8 Firmware with a NTFS disk in USB1 (see below)
  7. After that we have to add some lines to the samba configuration. But rather than writing to the default samba config /etc/samba/smb.conf, we will create a new file /etc/samba/user_smb.conf. This file is loaded automatically by the Linksys firmware right after loading the default /etc/samba/smb.conf. This file has the advantage that it will not get overwritten if you change something using the web interface:

    vi /etc/samba/user_smb.conf

    --insert--

    [share]
    valid users=@"administrators",@"everyone"
    comment=The share for everyone
    path=/share/public
    read only=yes
    write list=@"administrators",@"everyone"
  8. Optionally, if you want to disable the ugly built-in predefined shares by Linksys (ADMIN # and DISK #), you can add this to the user_smb.conf:

    [ADMIN 1]
    browsable=no

    [ADMIN 2]
    browsable=no

    [DISK 1]
    browsable=no

    [DISK 2]
    browsable=no

    NEW: I have Unslung 6.8 with the Boot Disk (the one with the ADMIN partition) plugged into the Disk2 USB socket and a second disk, formatted as NTFS, plugged into the Disk1 USB socket. With this configuration the NSLU2 now automatically itself creates the /etc/samba/user_smb.conf file and uses that to add the sharing definition for the NTFS disk which it calls HDD_1_1_1. You cannot remove the HDD_1_1_1 share by simply deleting the relevant lines as the NSLU2 will put them back on the next reboot. Changing the [HDD_1_1_1] to [DISK 1] will tidy up the share tempoarily, but the NSLU2 will put the [HDD_1_1_1] share lines back in the file on the next reboot.

    Solution - Create two duplicate share definitions for [HDD_1_1_1] and append browsable=no to the first leaving the second intact. The NSLU2 seems happy with that. (It doesn't work if you add it to the second). And don't forget the different step 5 above.
    My /etc/samba/user_smb.conf file looks like this:

    [DISKS]
    valid users=@"administrators",@"everyone"
    comment = For everyone
    path=/share/public
    read only = yes
    write list= @"administrators",@"everyone"

    [ADMIN 2]
    browsable=no

    [DISK 2]
    browsable=no

    [global]
    socket options = TCP_NODELAY SO_KEEPALIVE IPTOS_LOWDELAY SO_SNDBUF=65535 SO_RCVBUF=65535

    [HDD_1_1_1]
    valid users=@"administrators",@"everyone"
    comment = For everyone
    path=/share/hdd/data/HDD_1_1_1
    read only = yes
    write list= @"administrators",@"everyone"
    browsable=no

    [HDD_1_1_1]
    valid users=@"administrators",@"everyone"
    comment = For everyone
    path=/share/hdd/data/HDD_1_1_1
  9. Moreover, I found this somewhere in the wiki and found it to be usefull to increase reading and writing speed, but I haven't benchmarked it in an scientific way:

    [global]
    socket options = TCP_NODELAY SO_KEEPALIVE IPTOS_LOWDELAY SO_SNDBUF=65535 SO_RCVBUF=65535

Outcome

You don't have to reboot or anything after this. Just browse your network using Windows "My Network Places", find the NSLU2 and map the the folder "share" to a drive letter of your liking.

Under "share" you should see folders which internally links to the share on both of your attached harddisks.

view · edit · print · history · Last edited by StormLogiX.
Based on work by StormLogiX and thekitehunter.
Originally by StormLogiX.
Page last modified on May 05, 2006, at 08:55 PM