Syncing Files Between Linux & Windows

Systems

PC running Fedora Core 4
PC running Windows XP SP2

Software

Windows - Services for Unix 3.5, NFS
Fedora - Rsync, NFS

The Idea

Mount the Windows XP drive in Fedora read only via NFS and use rsync
to sync the files between both systems. These files are non-system files.
Most likely the windows drive will be mounted via automount since the
windows pc isn’t powered on less frequently than the linux pc.

Setup and Implementation

Setup Services for Unix
Using SFU to serve NFS home dirs
NasLite

So now I was able to mount the windows share in linux and browse as the mapped user created.

[nigelp@scoobay sysconfig]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      107G  8.6G   93G   9% /
/dev/hda1              99M   29M   66M  31% /boot
/dev/shm              506M     0  506M   0% /dev/shm
/dev/sda1             294G  119G  160G  43% /mnt/share
/mnt/share/media/mov/jkr-stealth.img
                      4.4G  4.4G     0 100% /mnt/share/media/mov/movie
madsick:/windows      299G  136G  163G  46% /mnt/sfunfstest

[nigelp@scoobay sysconfig]$
[nigelp@scoobay sysconfig]$ cd /mnt/sfunfstest/
[nigelp@scoobay sfunfstest]$ ls
applications  docs   info     mac   p2p   RHCE    school  utilities
codecs        games  jornada  misc  pics  router  treo
[nigelp@scoobay sfunfstest]$

Since the windows box won’t be up and running 24/7 i decided to use automount
to mount the drives in linux. Below are the entries made to enable this functionality

The next step will be to setup rsync to copy over the files from the windows side
to the linux side. Most of the file downloads are done on the windows hence the
reason for this setup.


[root@scoobay etc]# mkdir /mnt/sfunfs

added the following line to /etc/auto.master


/mnt/sfunfs     /etc/auto.sfunfs --timeout=120

created /etc/auto.sfunfs with the following contents.


windows -fstype=nfs,ro,soft,intr,rsize=8192,wsize=8192,nosuid madsick:/windows
linux   -fstype=nfs,ro,soft,intr,rsize=8192,wsize=8192,nosuid madsick:/linux
mov     -fstype=nfs,ro,soft,intr,rsize=8192,wsize=8192,nosuid madsick:/mov
music   -fstype=nfs,ro,soft,intr,rsize=8192,wsize=8192,nosuid madsick:/music
solaris -fstype=nfs,ro,soft,intr,rsize=8192,wsize=8192,nosuid madsick:/solaris

Next restarted and reloaded the daemons. (don’t know why restarting alone doesn’t work)


[root@scoobay etc]# /sbin/service autofs restart
Stopping automount:                                        [  OK  ]
Starting automount:                                        [  OK  ]
[root@scoobay etc]#

[root@scoobay etc]# service autofs reload
Checking for changes to /etc/auto.master ....
Reload map /usr/sbin/automount --timeout=60 /misc file /etc/auto.misc
Reload map /usr/sbin/automount --timeout=60 /net program /etc/auto.net
Reload map /usr/sbin/automount --timeout=120 /mnt/sfunfs file /etc/auto.sfunfs
[root@scoobay etc]#

[root@scoobay etc]# service autofs status
Configured Mount Points:
------------------------
/usr/sbin/automount --timeout=60 /misc file /etc/auto.misc
/usr/sbin/automount --timeout=60 /net program /etc/auto.net
/usr/sbin/automount --timeout=120 /mnt/sfunfs file /etc/auto.sfunfs

Active Mount Points:
--------------------
/usr/sbin/automount --timeout=60 /misc file /etc/auto.misc
/usr/sbin/automount --timeout=60 /net program /etc/auto.net
/usr/sbin/automount --timeout=120 /mnt/sfunfs file /etc/auto.sfunfs
[root@scoobay etc]#

Now the windows shares will be mounted on demand and unmounted when there
is no activity. I can also now do the sync based on the availibity for of
the shares. i.e.

My cron script and crontab entry.


#!/bin/sh

# script to sync windows disk with linux disk

if ping -c 3 madsick > /dev/null
then
  echo
  echo
  echo "Syncing /windows"
  /usr/bin/rsync -rtv /mnt/sfunfs/windows/ /mnt/share/data/windows/

  echo
  echo
  echo "Syncing /linux"
  /usr/bin/rsync -rtv /mnt/sfunfs/linux/ /mnt/share/data/linux/

  echo
  echo
  echo "Syncing /solaris"
  /usr/bin/rsync -rtv /mnt/sfunfs/solaris/ /mnt/share/data/solaris/

  echo
  echo
  echo "Syncing /mov"
  /usr/bin/rsync -rtv /mnt/sfunfs/mov/ /mnt/share/media/mov/

  echo
  echo
  echo "Syncing /music"
  /usr/bin/rsync -rtv /mnt/sfunfs/music/ /mnt/share/media/media/
else
  echo
  echo
  echo -n "Sync failed at: "
  date
  echo
fi


0 0,4,8,12,16,20 * * * /home/nigelp/bin/syncdisk

Note: Changed the rsync option from -a to -rtv because of the
uid/gid differences bet linux and windows. I noticed the problem
when i started deleting files on the source side it got permission
denied errors on the destination side. I could have gone about
having the same uid/gids with a lil research. But backing up and
retrieving the files was more important than ownership rights

Problems and Solutions

After following Microsoft’s SFU guide (skimming) I ran into the problem where
trying to browse the NFS Network | Default LAN showed no systems. I was able to
solve this using hints from the NasLite forum. I added a custom lan to the NFS Network
and was able to browse the nfs share that i had set up.

After mounting the nfs to a drive in windows per the SFU Setup guide. i was unable to
browse the mount.
Well this is weird. I just left it as is to return later. Now it works fine.

 
syncwinlin.txt · Last modified: 2006/04/13 23:17 by trinisan
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki