The Linux device mapper provides a “snapshot” capability which makes it possible to cheaply get a copy of a block device by using copy-on-write to only store the modified sections of the device. Systems like LVM and EVMS use this to provide a temporary copy of a filesystem for back-up while other software continues to modify the original. However it has some other interesting uses.
I’ve been using the software RAID feature of the Linux kernel for more than a decade on many machines. A couple times I have found myself in the unfortunate situation of having a failed software RAID from which I would like to retrieve data. (Of course one should rely on backups as much as possible, but sometimes it’s still beneficial to get at the very last contents of the disk on a server.) While doing this, you want to avoid any accidental modification of the original disks (or copies of their contents if you’re working from disk image files). One way to do this is with the device mapper’s snapshot capability. Using it this way is not well documented, so I thought I’d write up how I did this.