Moving logical volume (LVM) over network

sshot4d33ca58bce04

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

Leave a Reply

help-hint.png
Purpose of the commenting system is to share your experience. I encourage you to post feedback with your own suggestions, ideas or optimizations regarding the topic of a blog post. What commenting system isn't for, is asking questions about similar issues of yours and requesting support for it. Blog post is provided as is and I am not here to solve all your problems. Please bear that in mind and try to avoid posting such comments. I do take privilege to remove comment from my blog for any reason whatsoever. Usually I do it when I sense a comment was posted only for spam/seo reasons or is out of blog post's topic. Thank you for reading this, now you may continue :)
 

Your email address will not be published. Required fields are marked *