DockStar AutoMount for USB mass storage and Samba setup

AutoMount for USB mass storage

Original description.

The intention was to have an auto mount of any USB mass storage, like harddisk or USB-stick. As soon as you connect a device to an USB port, it will be mounted to /media/usb0(-7), and the first device will be mapped to /media/usb. As soon as you unplug the device from the USB port, it will be unmounted. The installation is very simple:

$ apt-get install usbmount

Path to the file lists: /var/lib/dpkg/info/*.list

The configuration can be found in the file: /etc/usbmount/usbmount.conf.
It contains detailed information about the parameters.

In order to improve security the parameter FS_MOUNTOPTIONS can be modified:
  FS_MOUNTOPTIONS="-fstype=vfat,gid=floppy,dmask=0007,fmask=0117"
It means that only users from the group "floppy" are allowed to read/write to the device, if it has type=vfat.
To incorporate users in the group "floppy" type:
$ usermod -a -G floppy user_name

USB-stick operation:
If you like to use an USB-stick for frequent use, you can omit the word "sync" from parameter MOUNTOPTIONS,
which reduces the wear from the flash memory. But then you have to type "sync" before removing the USB-stick.
Otherwise you may loose data after a write operation to the USB-stick.

An example for the mount:
root@FADS90:/etc/samba# mount
...
/dev/sdb1 on /media/usb0 type vfat (rw,sync,nodev,noexec,noatime,nodiratime,gid=25,fmask=0117,dmask=0007,allow_utime=0020,codepage=cp437,iocharset=utf8,shortname=mixed,errors=remount-ro)

The media will be seen in folder /media:
root@FADS90:/etc/samba# ls -l /media  # one media is mounted, usb0 is mapped to usb
insgesamt 44
lrwxrwxrwx 1 root root       4 12. Sep 10:43 usb -> usb0
drwxrwx--- 5 root floppy 16384 13. Sep 10:11 usb0
drwxr-xr-x 2 root root    4096 12. Sep 10:43 usb1
drwxr-xr-x 2 root root    4096 12. Sep 10:43 usb2
drwxr-xr-x 2 root root    4096 12. Sep 10:43 usb3
drwxr-xr-x 2 root root    4096 12. Sep 10:43 usb4
drwxr-xr-x 2 root root    4096 12. Sep 10:43 usb5
drwxr-xr-x 2 root root    4096 12. Sep 10:43 usb6
drwxr-xr-x 2 root root    4096 12. Sep 10:43 usb7

Samba Server

Introduction

Samba (server) is used to access a file system mounted at the DockStar from a Windows PC or Linux.

The difficulty is to make the access to the data of the mounted file system as easy as possible, on the other hand to allow only authorized people the access to the data. In my case I do not want to access the mounted file system from the Internet, my priority was easy access.

Installation

You have to install 3 packages:

$ apt-get install samba
$ apt-get install samba-common-bin  # smbpasswd
$ apt-get install sambaclient       # for tests

Setting a password for user authorizing:
$ smbpasswd -a            # for root
$ smbpasswd -e
$ smbpasswd -a user_name  # windows password
$ smbpasswd -e user_name

Edit the configuration file /etc/samba/smb.conf to add your share:
add below the [homes] part:
   # for using USB media
   [media]
       comment = USB drive
       path = /media/usb
       browsable = yes
       printable = no
       writable = yes
       guest ok = yes
       force create mode = 666
       force directory mode = 777
$ /etc/init.d/samba restart  # activate new configuration

Plugin your USB mass storage.
Check smb.conf for valid parametrs
$ testparm.samba3         # test /etc/samba/smb.conf parameters
$ smbclient -L localhost  # show shares

Troubleshooting

In case of troubleshooting or tuning Samba it is useful to know which parameters are set. The utility testparm is used for this purpose. Unfortunately testparm will not show its options via -h or --help, you have to use man testparm. In order to search quick for the setting of a parameter do:

e.g. searching for TCP_NODELAY

root@FADS90:~# testparm -sv | grep NODELAY
Load smb config files from /etc/samba/smb.conf
rlimit_max: rlimit_max (1024) below minimum Windows limit (16384) *
Processing section "[homes]"
Processing section "[media]"
Processing section "[printers]"
Processing section "[print$]"
Loaded services file OK.
Server role: ROLE_STANDALONE
        socket options = TCP_NODELAY

* The message "rlimit ..." is not important for the function or speed of Samba

options:
  -s = no prompt for ENTER
  -v = show ALL options (verbose)

Usage

If you are looking from Windows with the Explorer to the DockStar and it does not show up in the "workgroup", right click on network and on "computer search". Then type in field "computer name" the IP address and hit Enter. After a few seconds the DockStar should show up.

The transfer speed with an attached USB 2.0 harddisk 500 GB (Samsung HD502HJ, 7200 rpm) over Gigabit network to a Windows XP PC with the Explorer was:

Getting test program "atop": apt-get install atop 
# atop daemon logs heavily in /var/log/atop.log (up to 700 KB/day), even if it is not in use.
# So if you do not need it any longer, 
# deactivate it by removing the links /etc/rc2.d/s02atop, /etc/rc3.d/s02atop, /etc/rc4.d/s02atop, /etc/rc5.d/s02atop

File size: 430 MB, using atop 5 (5 s interval)
  CPU load 23% smbd
Read from DockStar NET so 21,6 MB/s
Write to  DockStar NET si  9,0 MB/s  # with MOUNTOPTION sync in file /etc/usbmount/usbmount.conf
Write to  DockStar NET si 13,0 MB/s  # no sync

If you do not use sync there is the danger of data corruption, if the USB disk is suddenly removed. That is the disadvantage of a removable disk.

Gigabit network speed

Because the Samba transfer was lower than I expected, I searched for the bottleneck.

First I looked about the Gigabit network speed. Because I could not compile the source code of netio, I searched for a armel binary and found it at nslu2-linux.org in the package netio_123-3_arm.ipk. Then I checked from a Windows XP PC the speed:

DockStar side:
$ netio -s

Windows XP side:
G:\INSTALL\Netzwerk\NetIO>netio.exe -t 192.168.17.90

NETIO - Network Throughput Benchmark, Version 1.26
(C) 1997-2005 Kai Uwe Rommel

TCP connection established.
Packet size  1k bytes:  63773 KByte/s Tx,  56591 KByte/s Rx.
Packet size  2k bytes:  87994 KByte/s Tx,  66134 KByte/s Rx.
Packet size  4k bytes:  94670 KByte/s Tx,  73266 KByte/s Rx.
Packet size  8k bytes:  97378 KByte/s Tx,  83069 KByte/s Rx.
Packet size 16k bytes:  102684 KByte/s Tx,  92270 KByte/s Rx.
Packet size 32k bytes:  108665 KByte/s Tx,  92216 KByte/s Rx.
Done.

This could not be the reason for the bottleneck in the Samba transfer rate.

USB Harddisk speed test, Windows XP

I liked to know what the maximum transfer speed of a USB harddisk (Samsung HD502HJ) is, on a Windows XP PC. The benchmark program was H2testw from www.heise.de.

Test file size: 430 MB
Read speed    :  31 MB/s
Write speed   :  24 MB/s

USB Harddisk speed test, Linux Debian Squeeze

I liked to know what the maximum transfer speed of a USB harddisk (Samsung HD502HJ) is, on the DockStar. The benchmark program was dd.

Test file size: 430 MB
Write to disk:
root@FADS90:~# dd if=/dev/zero of=/media/usb/test.file bs=1024k count=430
450887680 Bytes (451 MB) kopiert, 14,6675 s, 30,7 MB/s

Read from disk:
root@FADS90:~# dd if=/media/usb/test.file of=/dev/zero bs=1024k count=430
450887680 Bytes (451 MB) kopiert, 13,9301 s, 32,4 MB/s

Read speed    :  32,4 MB/s
Write speed   :   7,1 MB/s  # in file /etc/usbmount/usbmount.conf with MOUNTOPTION sync 
Write speed   :  30,7 MB/s  # no sync

List of pages in this category:

-- RudolfReuter 2010-09-13 10:07:26


Go back to CategoryDockStar or FrontPage ; KontaktEmail (ContactEmail)

DockStarAutoMountSamba (last edited 2011-03-23 05:39:24 by dslb-084-058-142-238)