BTRFS – How to Modify a BTRFS Filesystem UUID

btrfsuuid

I've made backups of my BTRFS filesystem using Clonezilla, and have restored one of those backups to a file named 2013-11-29.sda3.img.

I need to get some files out of this backup, but there's a hitch. Since the backup is of this machine, I cannot mount the backup anywhere on my filesystem, as its UUID matches the UUID of /.

Is there a way that I can change the UUID of the backup volume? As I understand it, BTRFS stores UUID information in every block on the filesystem, which complicates things for my purposes. However, is there a way that I could modify this? I understand that it'd probably take a long time to do, but that doesn't concern me. My main concern is keeping the server online. The backup is fairly large, so transferring it to another machine would take quite a while.

What are my options?

Best Answer

There is no way to do that for the moment. Actually, the volume UUID is used in each node of the chunk tree. You'll have to change them in there also assuming that the headers of the chunks/device are not hashed. BTRFS was really not design to allow this kind of backup.

This is really sad, but the easiest way to handle that is to use another computer.

If I may, I'd like to suggest you to stop backuping your data this way.

  1. If your partitions are important as a whole, backup with dd/clonezilla. When you need to restore your backups, restore the whole partition at once. Don't do this kind of hybrid backups: you specifically saved your partitions at the bloc level. So you have to restore it at the bloc level. Otherwise, you are using a spoon to cut the meat. As you certainly noticed, this solution is usually not used because it offers no versatility.

  2. If your data are important, backup with rsync or a similar tool on another disk : your data will always be accessible, you backup exactly what you want, you are backuping at the file level, etc.

Note that BTRFS has some (now limited) backuping features. BTRFS is moving fast, I guess more backuping features will come out in the future.

Oh, you've been warned already ;) Automated Clonezilla backup and GPG encryption

BTW, encryption is easier to apply on files using either LUKS for partition-based encryption or EnFS or EncryptFS for file-based encryption.

Related Question