I recently tried using lvmsync to migrate a LVM-backed VM to an image file. The only thing that stops it from working is that destdevice is opened with the 'w+' mode, which truncates it if it's a file. If I change the mode to 'r+', syncing to a file works:
--- lvmsync-3.3.1/bin/lvmsync.orig 2015-03-08 12:55:07.000000000 +0100
+++ lvmsync-3.3.1/bin/lvmsync 2015-03-08 12:02:05.000000000 +0100
@@ -145,7 +145,7 @@
snapback.puts handshake if snapback
verbose "Writing changed data to #{destdev.inspect}"
- File.open(destdev, 'w+') do |dest|
+ File.open(destdev, 'r+') do |dest|
while header = instream.read(12)
offset, chunksize = header.unpack("QN")
offset = ntohq(offset)
I recently tried using lvmsync to migrate a LVM-backed VM to an image file. The only thing that stops it from working is that destdevice is opened with the 'w+' mode, which truncates it if it's a file. If I change the mode to 'r+', syncing to a file works:
Is there a reason not to use 'r+' here?