How to dd in Remote Network using SSH via Command Line

Posted on

In this article, the focus of the subject is about how to dd in remote network using SSH via command line. The command ‘dd’ itself is an utility which is used to convert and copy a file based on the manual page given. In the context of this article, ‘dd’ command is used to duplicate a logical volume partition in a server to another logical volume to anotherĀ  server which exist or located remotely over the network.

The command ‘dd’ itself, in the context of this article for the sake of remembering the function which can be achieved by the command itself can stands as ‘duplicate disk’. It is because the disk which given as an example follows is being duplicated from one server to another server. The disk itself is being duplicated from a logical volume partition in a server to another logical volume partition which exist in another server. So, the process is actually a duplicate disk process and it is done over the network remotely.

The pattern for doing ‘dd’ to copy or to duplicate something exist in a server or a host which the result of the duplication will be placed on another server or a host and the result of the duplication itself will be transferred via ssh can be shown below :

dd if=/logical_volume_partition_source | ssh user@xxx.xxx.xxx.xxx dd of=/logical_volume_partition_target

Description : 
dd : The command which is called or executed to duplicate the logical volume partition
if= : It is part of dd command which must be included and it must be followed directly with the logical volume partition source location
/logical_volume_partition_source : It is the location of the logical volume partition source
| : Pipe sign which is used to redirect the output generated from any command executed before the pipe sign to any target specified after the pipe sign
ssh : It is a command called to execute ssh remote connection
user@xxx.xxx.xxx.xxx : It is defining the user and the IP Address's host which is going to be used as the ssh command parameter
dd : It is the command for duplicating the logical volume partition
of= : It is part of the second dd command which is mainly responsible for writing into the logical volume partition's target
/logical_volume_partition_target : It is the location of the logical volume partition target.  

Below is the example of the executed command :

[root@host ~]# dd if=/dev/local_vms/virtual_app_server | ssh root@xxx.xxx.xxx.xxx dd of=/dev/local_vms/virtual_app_server
root@xxx.xxx.xxx.xxx's password:
419430400+0 records in
419430400+0 records out
214748364800 bytes (215 GB) copied, 35329,9 s, 6,1 MB/s
419430400+0 records in
419430400+0 records out
214748364800 bytes (215 GB) copied, 35323,6 s, 6,1 MB/s
[root@host ~]# pwd

Off course the above command can be successfully carried out to duplicate exactly the logical volume partition only and if only those two logical volume partitions has exist before with the same size.

One thought on “How to dd in Remote Network using SSH via Command Line

Leave a Reply