|Blog personal: El hilo del laberinto|
Última Actualización: 31 de mayo de 2012
I use several levels of backup, from rsync to an external disk to rsync+ZFS over a remote computer. One of the backups I do is a -from time to time- "dd" from my laptop harddisk to an external USB attached (connected only for the duration of the backup procedure). I do this, for instance, before taking my laptop for a trip.
This procedure worked well for ages. Until I started using LVM on my laptop.
If you use LVM on your computer, you copy your harddisk using "dd" (booting from a LiveCD) and you plug the external harddisk while the computer is running normally, later, YOU WILL CORRUPT YOUR DATA, EVEN LOSE ALL YOUR FILESYSTEM BEYOND ANY REPAIR!!!.
Why?. Because when you plug the external harddisk the OS will see the same LVM configuration in both disks and will naively assume that both disks are the same, accessible via a multipath link, so it will spread reads and writes between both disks, irredeemably corrupting BOTH. You will trash both your live data and your backup!.
This happened to me once. I lost data. I had other backups, for a few days before, so I didn't lose anything very important, but it was quite annoying and exposed a flaw in my backup strategy.
Solution: Make sure the LVM configuration in the backup disk is different. The problem is... How to do it?
I posted the question on superuser.com (Stack Exchange) but I didn't get any good answer. So I developed my own procedure and, after more than a year of battletesting it, I am posting it here and closing the original question:
This is necessary because you can corrupt BOTH disks if you reboot with the backup disk attached before completing the procedure.
Something to try in the future would be to use LVM snapshots to be able to do the backup while I am using the computer, but then I have the duplicate LVM issue, that I am trying to avoid here. Another option would be to reconfigure LVM to mirror the data live to the external harddisk, and break the mirror after the sync is complete. But that sounds risky, and wouldn't backup my Windows partition or the data I don't keep in LVM volumes.
Your external USB harddisk must be, AT LEAST, as big as your internal harddisk. It is obvious, isn't it?
The system knows which partitions are physical volumes because the partition type and because you executed "pvcreate" when you created the LVM.
You will see that Logical Volumes UUIDs are the same in both Volume Groups, but that doesn't seem to cause any problem, and I don't know how to change them.
Donación BitCoin: 19niBN42ac2pqDQFx6GJZxry2JQSFvwAfS