Bug 1094857 - btrfs-progs should support setting the UUID
Summary: btrfs-progs should support setting the UUID
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: btrfs-progs
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: Eric Sandeen
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1094860
TreeView+ depends on / blocked
 
Reported: 2014-05-06 15:47 UTC by James (purpleidea)
Modified: 2014-06-21 23:50 UTC (History)
3 users (show)

Fixed In Version: btrfs-progs-3.14.2-3.fc20
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-06-21 23:50:06 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description James (purpleidea) 2014-05-06 15:47:55 UTC
Description of problem:

XFS and ext4 can both set the UUID. This is critical for management software that needs to *pick* and track a particular filesystem by UUID. It's also useful for other use cases like migrating filesystems, etc...

Eg:

xfs_admin -U <UUID>
mkfs.ext4 -U <UUID>

It's not clear how to do this in btrfs. Either at filesystem creation time, or as an operation that happens after the fact. Setting this at creation time would be sufficient.

Version-Release number of selected component (if applicable):
20+

How reproducible:
100%

Steps to Reproduce:
1. Try to set UUID.
2. Currently not possible.
3.

Actual results:
UUID is generated randomly.

Expected results:
Would like to pick a particular UUID.

Additional info:
Any work arounds to set a particular UUID would be appreciated!!

Thanks!

Comment 1 Eric Sandeen 2014-05-13 16:39:02 UTC
btrfs-progs-3.14.1 has been pushed to Fedora 19 and 20 for testing.

I frankly have no idea if this will resolve your bug or not, but if you test it and find that it does, please take the opportunity to close this bug.  :)

Thanks,
-Eric

Comment 2 James (purpleidea) 2014-05-13 23:06:09 UTC
(In reply to Eric Sandeen from comment #1)
> btrfs-progs-3.14.1 has been pushed to Fedora 19 and 20 for testing.
> 
> I frankly have no idea if this will resolve your bug or not, but if you test
> it and find that it does, please take the opportunity to close this bug.  :)
> 
> Thanks,
> -Eric

Thanks for the thought Eric, but I don't think it will. Cheers!

Comment 3 Eric Sandeen 2014-05-13 23:07:31 UTC
yeah, sorry, that was just a mass update.  Somebody should write a patch ... o_O

Comment 4 James (purpleidea) 2014-05-13 23:32:43 UTC
(In reply to Eric Sandeen from comment #3)
> yeah, sorry, that was just a mass update.
Oh cool, clever. I hope you're not a bot :)

>  Somebody should write a patch ...
> o_O

Actually, I would love this. I expect it might require some kernel bits too. I really don't know. Do you think you could ask someone with the btrfs know-how? I'm not sure who that is. Thanks!

Comment 5 Eric Sandeen 2014-05-14 00:41:05 UTC
Oh, ok - so, checking with Zach, the UUID is in every metadata block on the filesystem.

Changing the UUID after the fs has been populated is decidedly nontrivial, because of that.  It's _everywhere_

# blkid fsfile
fsfile: UUID="87642f76-977a-4eb5-99b6-9b5e961bcdc3" UUID_SUB="4b2f70c4-e35c-44ac-92ae-0c54d53b696e" TYPE="btrfs" 

# hexdump -C fsfile | grep "87 64 2f 76 97 7a 4e b5  99 b6 9b 5e 96 1b cd c3" | wc -l
844

and that's just for a filesystem populated with an e2fsprogs tree...

Comment 6 James (purpleidea) 2014-05-14 00:46:39 UTC
(In reply to Eric Sandeen from comment #5)
> Oh, ok - so, checking with Zach, the UUID is in every metadata block on the
> filesystem.
> 
> Changing the UUID after the fs has been populated is decidedly nontrivial,
> because of that.  It's _everywhere_
> 
> # blkid fsfile
> fsfile: UUID="87642f76-977a-4eb5-99b6-9b5e961bcdc3"
> UUID_SUB="4b2f70c4-e35c-44ac-92ae-0c54d53b696e" TYPE="btrfs" 
> 
> # hexdump -C fsfile | grep "87 64 2f 76 97 7a 4e b5  99 b6 9b 5e 96 1b cd
> c3" | wc -l
> 844
> 
> and that's just for a filesystem populated with an e2fsprogs tree...

So I feared something like that, which is why I mentioned that "Setting this at creation time would be sufficient." ... Since internally there's probably some kernel equivalent to `uuidgen`, they should (if there isn't already) be a way to choose what UUID instead of using the random one... Which is the feature I need.

Hopefully it exists, or is an easy patch that someone with kernel magic powers can look into. Thanks again :)

Comment 7 Eric Sandeen 2014-05-14 00:52:19 UTC
Oh, yeah, doing it at creation time should be trivial.  Sorry I missed that.  But is that really useful?  If so I can probably hack up the patch.  I just didn't think that was a thing anyone would need...

Comment 8 James (purpleidea) 2014-05-14 00:59:31 UTC
(In reply to Eric Sandeen from comment #7)
> Oh, yeah, doing it at creation time should be trivial.  Sorry I missed that.
Please don't be sorry :)

> But is that really useful?  If so I can probably hack up the patch.  I just
> didn't think that was a thing anyone would need...

Oh yeah, it would be especially useful!! (IMO) anyways. I can obviously refer you to my specific use case, but I'm sure if we dug around in the archives of why ext4 or xfs did it, then we'd probably find even better examples.

This type of patch is probably worth a few $beverages from my personal account, or more if I can find a willing/unsuspecting manager to cover them :)

Comment 9 Eric Sandeen 2014-05-14 01:04:38 UTC
In that case I am all over it.  ;)

Comment 11 Eric Sandeen 2014-05-14 01:10:05 UTC
# ./mkfs.btrfs -U 12345678-abdc-1234-1234-123456789abc fsfile 

...

# blkid fsfile 
fsfile: UUID="12345678-abdc-1234-1234-123456789abc" UUID_SUB="2895068e-a437-4e30-b121-df7c1b0a7ee9" TYPE="btrfs" 

Hoppy, please.  ;)

I'll send the patch upstream.

Comment 12 James (purpleidea) 2014-05-14 01:13:48 UTC
(In reply to Eric Sandeen from comment #11)
> # ./mkfs.btrfs -U 12345678-abdc-1234-1234-123456789abc fsfile 
> 
> ...
> 
> # blkid fsfile 
> fsfile: UUID="12345678-abdc-1234-1234-123456789abc"
> UUID_SUB="2895068e-a437-4e30-b121-df7c1b0a7ee9" TYPE="btrfs" 
> 
> Hoppy, please.  ;)
> 
> I'll send the patch upstream.

Done already? Sweet.
Can you point me to the sha1?

Comment 14 Eric Sandeen 2014-05-14 01:16:24 UTC
Not committed yet, I'll cc: you on the patch.

Comment 16 Eric Sandeen 2014-05-22 21:31:07 UTC
It's in kdave's integration tree now, so Chris should pull it into the main repo at some point.

It took more discussion than I expected.  :)

http://repo.or.cz/w/btrfs-progs-unstable/devel.git/commitdiff/a03901849f868c65f845325fcaeb3d25c6896759

-Eric

Comment 17 Fedora Update System 2014-06-17 00:32:59 UTC
btrfs-progs-3.14.2-3.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/btrfs-progs-3.14.2-3.fc20

Comment 18 Fedora Update System 2014-06-17 23:27:37 UTC
Package btrfs-progs-3.14.2-3.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing btrfs-progs-3.14.2-3.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-7440/btrfs-progs-3.14.2-3.fc20
then log in and leave karma (feedback).

Comment 19 Fedora Update System 2014-06-21 23:50:06 UTC
btrfs-progs-3.14.2-3.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.