LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   rsync - problem connecting to network external drive (https://www.linuxquestions.org/questions/linux-software-2/rsync-problem-connecting-to-network-external-drive-947052/)

Polymorph 05-26-2012 10:03 PM

rsync - problem connecting to network external drive
 
I have an external USB 350MB external drive connected to a Wireless Modem/Router. The drive is formatted ntfs and is almost empty. I can use Krusader or Dolphin to access and transfer files to and from the drive from any computers on the network. The address of the drive is smb://readyshare/USB_Storage/NetShare. The drive shows up correctly in Gigolo.

I want to set up an automatic backup procedure using rsync. I have the following code ;
Code:

#!/bin/bash
rsync -au --progress -s --exclude=.Trash-1000 /Common/.nts smb://readyshare/USB_Storage/NetShare/.nts

When I run this I get
Quote:


ssh: Could not resolve hostname smb: Name or service not known
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(605) [sender=3.0.9]

I have tried removing "smb" but it still doesn't work.

I am using bash in Xubuntu 12.04. rsynch works well across the network in all other cases but not to the USB drive.

allend 05-27-2012 02:38 AM

Try explicitly mounting your NTFS formatted external drive and using the mount point in place of smb://readyshare/USB_Storage/NetShare. This may help. https://help.ubuntu.com/community/Mo...dowsPartitions

Polymorph 05-27-2012 04:32 AM

I have already done this. I can use rsync to transfer files each way to the drive when mounted so the fact that it is ntsf does not seem to matter.

The modem will not recognise the drive if formatted to anything but ntfs or fat32.

I want the drive to be connected to the router so that it is a backup drive for each computer on the network and so that certain common files are available across the network.

Everything works fine when I use Dolphin, Thunar or Krusader. It is just rsync that it causing a problem.

Thanks for your reply

Alan

allend 05-27-2012 09:11 AM

I now have a better picture of your situation. You are going to need to rethink your strategy as rsync is not the tool to achieve your goal directly as it does not handle the SMB protocol.
Perhaps you could use rsync to build a directory on a computer on the network, then copy this directory to your external USB disk attached to the modem/router.

Polymorph 05-27-2012 09:48 AM

Yes I will do that. I was hoping to use rsync in a script that could be run automatically under cron.

I will play around a bit more and try your strategy.

Thanks for your help

sysfce2 05-27-2012 11:54 AM

Is there any reason that you cannot mount the network share in your cron script just before running rsync and umounting it after?

toothandnail 05-27-2012 11:05 PM

Quote:

Originally Posted by Polymorph (Post 4688758)
Yes I will do that. I was hoping to use rsync in a script that could be run automatically under cron.

You can do that easily enough - use the script to mount and unmount the drive. If nothing else, it allows you to capture errors should the mount fail. I use something like this to run an rsync backup from cron:

Code:

mount -t cifs -o guest //192.168.0.225/bantam /mnt/smb
sleep 4
if [ -d /mnt/smb/backup ]; then
        <rsync commands go here....>
        sleep 20
        umount /mnt/smb; exit
else
        echo "`date +%m-%d-%H:%M` Mount failed, backup aborted" >> /var/log/rsync.log
fi

That works fine. In this instance, the backup is being done to a Zyxel NAS. Should the NAS be unavailable, I get a log entry so I can see that there has been a problem.

Paul.

Polymorph 05-28-2012 07:29 PM

@toothandnail
Thanks for your reply. I can not get the external drive to mount. I am using a Netgear DGND3700 wireless modem/router.
The IP address of the modem is 192.168.0.1 - that is what I use to get in from Firefox.

In the "USB Storage Advanced Settings" I have:
Network/Device Name: readyshare
Access Method: Network Connection: Link: \\readyshare
Available Network Folders: Shared Name: readyshare\USB
I assume that the back slashes are for Windows users and have used forward slashes instead.

I created a mount point mkdir USB - then I tried:

mount -t vfat -o guest //192.168.0.1//readyshare/USB USB
mount -t vfat -o guest //192.168.0.1//readyshare USB
mount -t vfat -o guest //192.168.0.1/readyshare/USB USB
mount -t vfat -o guest //192.168.0.1/readyshare USB

In all cases I get
Quote:

mount: special device //192.168.0.1//readyshare/USB does not exist
As I said earlier I can access the drive through Dolphin, Krusader and Thunar from each or the computers on the network.

Any other suggestions?

TIA

Alan

allend 05-28-2012 07:39 PM

I have a Netgear DG834GUv5 wireless modem/router. The external USB drive is only accessible by FTP. I think that your Netgear DGND3700 wireless modem/router will be similar in that the external USB drive cannot be remotely mounted.

Polymorph 05-28-2012 07:46 PM

@toothandnail
Thank you for your reply and suggestion. I cannot get the drive to mount.
I am using a Netgear DGND3700 wireless Modem/Router. Its IP address is 192.188.0.1 which is what I use to access the modem from Firefox. For testing I am using a 4GB USB Flash drive formatted to fat32.

In the Modem I have:
Quote:

USB Storage: Advanced Settings: Network/Device Name: readyshare
Access Method: Network Connection: \\readyshare
Available Network Folders: Shared Name: \\readyshare\USB
I assume the backslashes are for Windows users and have used forward slashes instead.

I created a mount point in my home directory - mkdir USB - then I tried
Quote:

sudo mount -t vfat -o guest //192.168.0.1//readyshare USB
sudo mount -t vfat -o guest //192.168.0.1//readyshare/USB USB
sudo mount -t vfat -o guest //192.168.0.1/readyshare/USB USB
sudo mount -t vfat -o guest //192.168.0.1/readyshare/USB USB
In each case I got -
Quote:

mount: special device //192.168.0.1/readyshare/USB does not exist
As I said earlier, I can access the drive through Thunar, Dolphin and Krusader from each of the computers on the network. The address in Krusader is
Quote:

smb://readyshare/USB
What am I doing wrong?

TIA, Alan

Polymorph 05-28-2012 08:44 PM

Sorry about the double post - I don't know what went wrong!!

@allend
As I said I can access the drive through the file managers and the address in there is smb://readyshare/USB. I can transfer files each way by dragging and dropping them without using ftp

Within the modem settings there are optioins and addresses for accessing the drive directories directly, through http (directly), https (over the Internet), ftp (directly) and ftp (over the internet). Since the file managers find the drive directly using smb, I want to do the same by mounting it and accessing it.

sysfce2 05-28-2012 09:46 PM

Try using mount -t cifs.

Polymorph 05-28-2012 10:11 PM

This is what I get -
Quote:

sudo mount -t cifs -o guest //192.168.0.1//readyshare/USB USB

Retrying with upper case share name
mount error(6): No such device or address
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
The man pages didn't give me anything useful.

toothandnail 05-29-2012 01:34 AM

Looking at what you've posted, I think you're addressing the device incorrectly:

Code:

USB Storage: Advanced Settings: Network/Device Name: readyshare
Access Method: Network Connection: \\readyshare
Available Network Folders: Shared Name: \\readyshare\USB

From that, I would think the mount command you should be using would be either of these:

Code:

mount -t smb //readyshare/USB USB -o guest
or

Code:

mount -t smb //192.168.0.1/USB USB -o guest
Though it both instances, I would use an absolute path to your share directory. I would also use cifs rather than smb. smb is deprecated and has a file size limit of 2GB.

I've not used a Netgear router for a while, but from what I remember, it should provide local DNS, so you could check it. If you've got Samba installed, try entering 'smbtree' from the command line. Hit return when it prompts for a password, and see what the command shows for your network. If it shows the readyshare name, you should be able to mount it using the name direcdtly, if not, you will need to use the IP. But using both is most likely the reason the network can't locate the device.

Edit/ Sorry, just had a closer look at your first mount command. '-t vfat' is definitely wrong. When you're accessing the device over the network, it will be either 'smb' or 'cifs', the latter being the best option. /Edit

Paul.

Polymorph 05-29-2012 01:47 AM

Fantastic!!!!
From your example I got
Quote:

mount: unknown filesystem type 'smb'
So I tried smbfs after consulting man mount.

Quote:

sudo mount -t smbfs //192.168.0.1/USB USB -o guest
The above works perfectly - I get the Warning message
Quote:

Warning: mapping 'guest' to 'guest,sec=none'
but the drive is mounted.

So I tried without -o guest and it mounted without the Warning message

I am going to try it in fstab

In fstab I tried
Quote:

//192.168.0.1/USB USB smbfs defaults 0 0
. It did not work. I can live with that and can mount it in a script as in your first post - thanks

Is there any startup script that I could put the mount statement into to get the drive mounted on startup? I have tried ~/.profile and /etc/bash.bashrc but I am just guessing


Thanks for all your help

toothandnail 05-29-2012 02:17 AM

:) Glad it worked....

I suspect the reason it failed to work in fstab is the lack of an absolute path, but there might also be issues with network startup on boot.

Anyhow, great that you've to it working.

Paul.

toothandnail 05-29-2012 02:33 AM

Quote:

Originally Posted by Polymorph (Post 4689995)
Is there any startup script that I could put the mount statement into to get the drive mounted on startup? I have tried ~/.profile and /etc/bash.bashrc but I am just guessing

Sorry, missed this. The normal place for that type of command in a Debian based system would be /etc/rc.local The mount command requires root access, and rc.local will run with the correct access.

There may be a problem with the network layer not being fully operational when rc.local is run. I suspect that would depend mainly on whether you're using a wired or wireless connection to the router. If its wireless, the mount command in rc.local will probably not work - Network Manager will only run when you log in as a user, which will be after rc.local has run.

Quote:

Thanks for all your help
You're welcome.

Paul.

Polymorph 05-29-2012 09:35 AM

I found this - http://opensuse.swerdna.org/susesambacifs.html#fstab

I put
Quote:

//192.168.0.1/USB /USB cifs guest,_netdev 0 0
into /etc/fstab and the USB drive mounts on startup without any problem.

I will have to switch the modem on and let it boot fully so that the drive is available before starting the computers. No problem!!

Thanks again.

Alan


All times are GMT -5. The time now is 12:52 PM.