# rsync very slow to start

## helio

I use rsync via ssh to transfer files between two remote linux machines. The rsync command quickly prompts me for password, but after the password is typed in, the rsync command just hangs there for a long time, anywhere between several minutes to an hour, before the file transfers actually start. The problem is puzzling and annoying. Any suggestions would be appreciated.

----------

## Hu

Before the data can be moved, rsync must identify what files need to be moved.  If your remote filesystem is complex, this could be a slow process.  What is the output of stat -f . ; find . -type f | wc on each of the top level directories?

----------

## helio

I only transfer files from a sub-directory, where the output of stat -f . ; find . -type f | wc is 

  File: "."

    ID: 8a26a76ed765061 Namelen: 255     Type: ext2/ext3

Block size: 4096       Fundamental block size: 4096

Blocks: Total: 12646301   Free: 1818999    Available: 1176601

Inodes: Total: 6426336    Free: 6247091

   1170    1170   32543

The output is instantly fast.

If I go to the home directory, the output of stat -f . ; find . -type f | wc becomes

  File: "."

    ID: 8a26a76ed765061 Namelen: 255     Type: ext2/ext3

Block size: 4096       Fundamental block size: 4096

Blocks: Total: 12646301   Free: 1818999    Available: 1176601

Inodes: Total: 6426336    Free: 6247091

  59136   63899 2898474

and the output takes a little longer, but still within 30 seconds. Could that be the source of the rsync problem?

 *Hu wrote:*   

> Before the data can be moved, rsync must identify what files need to be moved.  If your remote filesystem is complex, this could be a slow process.  What is the output of stat -f . ; find . -type f | wc on each of the top level directories?

 

----------

## Hu

What about the output for the other side of the transfer?  What is the output of date; time ssh remote-host 'date;find . -type f | wc;date'; date?  How are you using it for two remote machines?  The manual page specifically states:

```
       Rsync copies files either to or from a remote host, or locally  on  the

       current  host  (it  does  not  support copying files between two remote

       hosts).
```

----------

## helio

 *Hu wrote:*   

> What about the output for the other side of the transfer?  What is the output of date; time ssh remote-host 'date;find . -type f | wc;date'; date?  How are you using it for two remote machines?  The manual page specifically states:
> 
> ```
>        Rsync copies files either to or from a remote host, or locally  on  the
> 
> ...

 

An example for the output of "date; time ssh remote-host 'date;find . -type f | wc;date'; date" is

Tue Nov 29 22:06:55 CST 2011

Password: 

Tue Nov 29 22:04:47 CST 2011

  87512   92286 4409040

Tue Nov 29 22:04:47 CST 2011

real    0m4.518s

user    0m0.010s

sys     0m0.000s

Tue Nov 29 22:06:59 CST 2011

The output was again instantly fast, even though the rsync command still hang for a long time after the password was typed in.

Here is how I use rsync to transfer files between two remote hosts:

1) From my local host A, I ssh into my account on a remote host B. 

2) From host B, I use rsync via ssh to transfer files between B and another remote host C.

3) Sometimes from host B, I ssh to my account on host C.

4) From host C, I use rsync to transfer files between B and C.

Strictly speaking, I didn't use rsync to copy files between two remote hosts. When I use rsync from host B (C), I actually transfer files between the local host B (C) and the remote host C (B). So the puzzle still remains unresolved.

----------

