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.

Using Linux, I have several backup levels. One of them is a periodical sector by sector copy (using dd) of my laptop harddisk to an external USB disk. Yes, I have other backups too, like remote rsync.

This approach (the disk dd) is OK when cloning a HDD with no LVM volumes, since I can plug the external disk anytime and mount the partitions simply mounting /dev/sdb* instead of /dev/sda*. Trivial and handy.

Today I moved ALL my harddisk (including the /boot) to LVM. Everything works fine. I will stress it for a couple of days, and then I will do a sector by sector copy to my external harddisk.

Now I have a problem, I guess.

If in the future I plug the external USB HDD to recover any file, the OS will detect a duplicate LVM configuration, with the same name and the same UUID. Even doing a vgrename (which LVM would be renamed, the internal HDD or the external HDD?), the cloned UUID will not change. Is there any command to change name and UUID? Ideally I would clone the HDD and then change the LVM group name and its UUID, but I don't know how to do it.

Another related issue would be...

In the past I have booted my laptop using the external disk, using the BIOS boot menu and changing GRUB entries manually to boot from /dev/sdb instead of /dev/sda. But now my current GRUB configuration boots directly from a LVM logical volume, something like: set root='(LVM-root)' in my grub.cfg. So... What is going to happen with duplicated volumes?

Any suggestion?

I guess I could repartition my external harddisk and change backup strategy from dd to rsync, but this disk has windows installed too, and I really would like to have a physical "real" copy.

share|improve this question
Maybe you could try some LVM mirroring tricks. –  Cristian Ciupitu Mar 11 '11 at 9:40
add comment

4 Answers

up vote 1 down vote accepted

Closing this issue, after a year. I have written the answer in my personal website. I hope it is useful to somebody else.

share|improve this answer
add comment

I agree with one of the previous answers -- running dd on the whole disk is not a great solution here. If the reason you're stuck on dd has to do with backing up another OS, then you can use dd only for those other OS partitions, and rsync for the linux partitions.

Part of the problem is that if you run dd of the whole disk while you have filesystems up and mounted from it, there is no way to ensure the backup is consistent. It may work 9 times out of 10, but under any load, the resultant backup could be corrupted. The only way to ensure this doesn't happen is to unmount all filesystems and deactivate all volume groups for the entire time that the dd is running. Not very convenient if your / is mounted from LVM.

In any event, if you insist on sticking with this approach, the tool you're looking for to rename a duplicated vg is called "vgimportclone". It's intended for use with device level snapshots, but it will work with dd as well.

share|improve this answer
Of course, the "dd" is done booting from a livecd. The disk is not mounted. –  jcea Dec 29 '11 at 4:52
Using "dd" has two problems, beside the LVM "cloning" effect: 1. Downtime (in my laptop, about FOUR hours. I do the backup when I don't need the computer, like when dining out) and 2. If the source disk has a read error the copy will fail and the destination (backup) disk will be inconsistent and unusable to recover the read-error in the master disk. This problem is MAJOR, but can easily solved using TWO backup disks, alternating backups on them. This way, if current backup fails and you can't not use it, you have the consistent previous backup. –  jcea Dec 29 '11 at 4:56
add comment

I don't really think dd is the best option for backups in most cases, for a number of reasons. One option as someone mentioned is to use LVM's mirroring. You can disconnect the external drive and when you reattach it it will resync without having to copy 100% of everything including empty sectors like dd would. But personally I think even better/simpler is to just use rsync to copy to your external drive. Not only will it be by faaaaaar the fastest, your backup is also immediately usable without any extra steps required at all. Combine this with LVM snapshots on the external drive and you have multiple point in time copies all of which can be used anytime without any extra trickery.

share|improve this answer
Tentacle, the "dd" is the last of THREE different backups schemas I have. The other two are rsync based. I need "dd" from time to time because my internal disk has several OSs installed. –  jcea Mar 30 '11 at 11:49
add comment

Studing the issue carefully, I think the right approach would be:

  1. Plug the external HD.

  2. Desactivate the LVM management of the second HD: "vgchange -a n /dev/LVM2".

  3. Clone the harddisk, with "dd".

  4. For every physical volume, generate new UUIDs for the clone disk, with "pvchange -u /dev/hdb*".

  5. Change the VG UUID with "vgchange -u LVM". This will change the UUID of one of the VG, could be the original or the clone. It doesn't matter. Being different is enough.

  6. Change the name of the VG of the cloned disk from "LVM" to "LVM2", with "vgrename". I don't know if this would work without a previous "vgscan" to "discover" the new VG.

Would this work?.

share|improve this answer
add comment

Your Answer


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.