-   Linux - Server (
-   -   Mounting multiple NFS or Samba shares: client-side or server-side? (

mariogiov 03-29-2012 08:12 PM

Mounting multiple NFS or Samba shares: client-side or server-side?
Hi all,

I've got a LAN here with about 10 Win7 boxes (and soon 10 RedHat boxes), all of which regularly produce experimental data that I sync to a central RedHat server.

The way I'm doing this right now is to have the central server mount each of the shared folders from the Windows machines (mount.cifs) and then periodically check for files that are both new and haven't been modified for a few minutes (experiment is complete, data is done being written).

This works fine for the moment; however, I wonder if it's the best way to do this, especially as things scale up. Is there a big difference, for example, if each of the Windows shares mounts a Samba share from the Linux server and writes to it directly? That seems like a worse idea to me, but I don't know a great deal about how all this works at a low level.
Additionally, when I add the Linux boxes I was planning on using NFS to share files to the central server. Is it possibly a better idea to just deal in Samba -- maybe less work for the central server than dealing with NFS as well?
Are there other options I'm missing that might be better than either of these?

Thanks for your thoughts,


chrism01 03-29-2012 08:40 PM

I'd have the central server permanently mount the remote cifs & nfs disks from the other systems, but have the copy cmds check by trying to eg cd into those before trying to move data.
You can also add mount cmds to the copy scripts if original cd fails, so that they can re-mount without you.
Consider that when cxns disappear (& they will) you don't want experimental data lost because you can't write to a remote (central server) disk.

mariogiov 03-30-2012 02:03 PM

Hey Chris,

Yeah the way I have it set up at the moment is to have cron execute this every five minutes:


mount -a 2>/tmp/error.txt; if [ $? = 1 ]; then echo -en "\n\nERROR: `date`: " >> /home/server/Desktop/workstation_data/`date +%Y%m%d`_mount.err; cat /tmp/error.txt >> /home/server/Desktop/workstation_data/`date +%Y%m%d`_mount.err; fi

IFS=$(echo -en "\n\b")

for FILE_PATH in `find /mnt/station*/Public/Documents/ -type f -ctime -3 -mmin +10 -print | grep -v "National Instruments"`; do
  FILE=$(echo $FILE_PATH | cut -d / -f 6)
  YEAR=$(echo $FILE | perl -lne 'if ( $_ =~ m/Expt_(\d{2})\d{2}\d{2}/ ) { print $1 }')
  MONTH=$(echo $FILE | perl -lne 'if ( $_ =~ m/Expt_\d{2}(\d{2})\d{2}/ ) { print $1 }')
  DAY=$(echo $FILE | perl -lne 'if ( $_ =~ m/Expt_\d{2}\d{2}(\d{2})/ ) { print $1 }')
  mkdir -p /home/server/Desktop/workstation_data/by_date/20$YEAR/$MONTH/$DAY
  echo -en "Syncing file:\t"; echo $FILE_PATH
  rsync -aPv $FILE_PATH /home/server/Desktop/workstation_data/by_date/20$YEAR/$MONTH/$DAY/$FILE 2>/tmp/error.txt
  if [ $? != 0 ]; then
      echo -en "\n\nERROR: `date`: " >> /home/server/Desktop/workstation_data/`date +%Y%m%d`_rsync.err
      cat /tmp/error.txt >> /home/server/Desktop/workstation_data/`date +%Y%m%d`_rsync.err


(I added the -ctime -3 in case a workstation goes down over the weekend when I'm not here.) I'm considering that as I add more workstations this may get a little out of hand. You're right however that when the connection goes down it's imperative to have a local copy of the data on each workstation.

Any thoughts on using both NFS and CIFS? Really I suppose the bottlenecks will be network bandwidth and disk writes rather than CPU in any event, so perhaps this is a moot point.

Thanks again,


chrism01 04-02-2012 09:57 PM

Well, for the Linux boxes, NFS, but try to use latest ie NFS v4 which uses TCP and is much more reliable.
For MS boxes, your choice ... Traditionally Samba / CIFS, but it can be fiddly, or you can add SFU (Services for Unix) which should give you nfs client sw.
More consistent for management purposes, in fact you could probably automate some of the setup; just have a list of wkstns and get the server to automatically create/export nfs shares.
If you go Samba, I'd avoid having CIFS+NFS shares on the same disks/mnts....

The RHEL manual here explains (HOWTO) NFS + CIFS pretty well

Reuti 04-03-2012 09:11 AM

Besides mounting in any direction, one could also enable an SSH server on the central machine (most likely it's running already) and allow the 20 clients to transfer the file by scp by hostbased or passphraseless ssh-key authentication (while preventing them to log in via ssh).

If I get the problem right, you only want to push data from the 20 clients to the server.

All times are GMT -5. The time now is 05:59 AM.