Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to back up an LVM volume using Duplicity (note: not just the file contents of the volume, but the actual volume itself, byte-for-byte).

The best way I've so far found is to dd all the data on the LVM volume to a temporary file, include that file in the backup set, and delete it after the backup is made. This seems horribly inefficient, though: I'm needlessly thrashing the disk and duplicating all the data.

What would seem to be needed is a way to do essentially the opposite of mount -o loop. In other words, I don't want to mount a file as a block device: instead, I want to 'mount' a block device as a regular (read-only) binary file — one that Duplicity will then read from and back up for me.

Is there any way to achieve this?

share|improve this question
    
Sure you can, remember that in Unix "everything is a file" (almost). I don't know Duplicity, but just including the relevant /dev/mapper/... file might be enough. But this will copy everything, including spaces never used and remnants of deleted files. To back that up only makes sense for forensic purposes. –  vonbrand Jan 29 '13 at 16:20
    
Hi @vonbrand — yes, that's what I was hoping too. So perhaps Duplicity has built-in special treatment for block devices which is screwing this use-case up. –  George Jan 29 '13 at 16:59

2 Answers 2

That's how block devices already work by default. They can be read by any program – after all, dd uses just the standard open() and read() functions to create the image.

share|improve this answer
    
Hmm — it definitely doesn't work with Duplicity. Perhaps the problem is that Duplicity has built-in special treatment for block devices. –  George Jan 29 '13 at 16:09

This is the normal way things already work.

Just add -r or -o ro to the mount options to make it read-only.


Man mount

 ro      The same as -r; mount the file system read-only 
         (even the super-user may not write it).
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.