-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: btrfs replace start --new-fsid
#961
Comments
btrfs replace
, but without writingbtrfs replace
, but without writing
I believe it is a must-have safety check, not an optional For your idea of transacting from an in-memory fs to a full btrfs, I'm wondering why both the initramfs and the new root would even have the same fsid. |
Yeah, rejecting on matching FSID is definitely safer. I'm also not sure why the initramfs and the new root would have the same fsid either, is "tree hash" actually the same as fsid, or am I misunderstanding where I had implied that? |
Here's a better explanation of what I'm intending:
Does this make more sense? Sorry for the confusion initially |
The I begin to understand the case ii), it can indeed cause problems like this:
In this particular case, I guess btrfs seed device may be a better solution, as the sprout process (adding a writable device) will generate a new fsid, so that every new fs will not have the same UUID, thus no conflicts. For case 1) I still do not understand why we need to use the same backing file. Can't we create an empty file on the new rootfs, and do the replace? |
Oh, I'm still not sure what you mean by "create an empty file on the new rootfs"; the idea is that the rootfs on-disk is only written once, and Perhaps a new command like |
You can just remove the seed device from the sprout fs, then it will just be come a fully independent fs.
Sorry, I didn't understand the original case i), you mentioned "btrfs replace is called normally like in the example from the issue (but going in reverse, since we're coming from memory)". Do you mean just call And in that case it will work as expected, although with the mentioned conflicting fsid problem. |
Oh, it'd actually sync the on-disk FS when the original seed device is removed? That could work then!
Yep!
Perhaps the new option I'm looking for would be I think I actually can work with |
btrfs replace
, but without writingbtrfs replace start --new-fsid
Although we support change the fsid, all the supported solution is off-line based. Meaning the fsid can only be changed with the fs unmounted, thus not suitable for seamless migration. Thus the only online migration that can generate a new fsid is seed device, at least for now. |
Can't the fsid change happen after the target is generated, but before it's added to the src's device list? Or is generation something that happens while the target is in the device list, in which case, can the device be temporarily removed from the device list to make it offline, and then re-added afterwards before the transition? |
Fsid change is an offline operation. And we haven't yet take conflicting fsids into consideration. The devices can be taken out of the device list, but that's only for kernel btrfs module, not for offline tools like btrfstune. Overall seed device is still the best way, and IIRC Oracle and Meta is using this method to generate their container/VM images already. |
I managed to replace the
|
Version: v6.13
I learnt of this interesting feature, where a backing device can be transparently replaced with another, using the following commands:
However, if
/dev/loop0
is actually a real BTRFS partition with identical content, and--force
is passed so it doesn't reject the operation, that'd still mean it would overwrite the target despite it being identical.Proposal
See #961 (comment) for the new proposal and the reasoning.
Old proposal
I propose adding something like an
--if-match
option (probably a better name available for this), which checks if the src and target have identical tree hashes, and transparently replaces src with the target if the check succeeds. If src and target aren't identical, or aren't mounted read-only as an extra safety measure, the command cleanly fails and no writing ever occurs (#933 is relevant here).My idea for this feature would be for cleanly transitioning from an initramfs/recovery USI to a real root, where both are intended to have identical contents, but, where you don't want to keep the initramfs in memory (hence the backing device transfer).
The text was updated successfully, but these errors were encountered: