Sometimes you come to an issue of moving raw volume from one server to another. Now this can be pretty complicated thing. You could make a snapshot of LV or make an image file, which you would copy then to another server, but that takes ages. When creating image you also need almost double the disk space, depending on, if you use compression or not. Either way, we want this to be as painless as possible. We would just want to transfer our LV from one server to another without any hassle. We can achieve this by simply piping whole LV thru ssh. Yes, it’s as easy as this:
dd if=/dev/VolumeGroup/LogicalVolume | ssh 192.168.0.20 dd of=/dev/VolumeGroup/LogicalVolume
Assuming that you already created logical group and volume on the new server. Of course it has to be the same size as on first server, not to break something.
One of downsides of this transfer is, you don’t know how much you transferred, what’s the speed etc. This can be solved by simply piping pv to the command. You may also want to do yourself a favor and increase block size of transfer, to make chunks larger than usual, to increase speed of transfer like this:
dd if=/dev/VolumeGroup/LogicalVolume bs=4096 | pv | ssh [email protected] dd of=/dev/VolumeGroup/LogicalVolume bs=4096