Compress stream when copying linode disk image over ssh

Hi,

the tutorial for copying a disk image over ssh can take a very long time depending on the size of the linode.

The command shown in the tutorial does not do any compressing:

ssh root@123.45.67.89 "dd if=/dev/xvda " | dd of=/home/archive/linode.img

Is it possible to compress the stream of data that is transferred from the linode to the receiving machine before it is being sent and then decompress it locally before it's passed to the dd?

What would the revised command need to be?

Thanks!

Torsten

5 Replies

ssh -C root@123.45.67.89 "dd if=/dev/xvda " | dd of=/home/archive/linode.img

The -C adds ssh compression.

What's the block size used for SSH compression? It's possible that it might be terribly inefficient compared to a larger blocksize with better compression. For example, this article compares the effect of blocksize for dd via bzip2 over netcat, although unfortunately it doesn't compare SSH with compression on (only off):

http://www.ndchost.com/wiki/server-admi … t-over-ssh">http://www.ndchost.com/wiki/server-administration/netcat-over-ssh

man ssh says > Requests compression of all data (including stdin, stdout,

stderr, and data for forwarded X11 and TCP connections). The

compression algorithm is the same used by gzip(1), and the

``level'' can be controlled by the CompressionLevel option for

protocol version 1. Compression is desirable on modem lines and

other slow connections, but will only slow down things on fast

networks. The default value can be set on a host-by-host basis

in the configuration files; see the Compression option.
So you can change the compression performance. Of course it depends what you're transferring if you're transferring a large MySQL database for example the -C flag on it's own vastly improves performance. I have my ssh_config file turn compression on my default.

Sure, but gzip isn't as efficient as bzip, and if SSH is using 1500 byte blocks, while the alternative is using, say, 4MB…

True bzip isn't as efficient as gzip but you could also say bzip isn't as efficient as 7zip in general adding the -C flag isn't a bad idea, a better command would be

ssh root@123.45.67.89 "dd if=/dev/xvda | bzip2 " | bunzip2 | dd of=/home/archive/linode.img

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct