Skip to content
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

Add a retain old fs option to replace? #534

Open
CorrosiveTruths opened this issue Oct 26, 2022 · 2 comments
Open

Add a retain old fs option to replace? #534

CorrosiveTruths opened this issue Oct 26, 2022 · 2 comments
Labels
question Not a bug, clarifications, undocumented behaviour

Comments

@CorrosiveTruths
Copy link

CorrosiveTruths commented Oct 26, 2022

Hi, would it feasible to have an option when using btrfs replace with a single fs device to leave the old filesystem intact on the replaced device?

That is, instead of removing the filesystem on the device being removed, generate a new UUID for it.

This would be useful as a backup / recovery in case something goes wrong on the new device (I had the idea when someone on reddit reported this very thing happened).

It would also be useful as a way to clone filesystems - so people don't use dd and end up with two devices with the same UUID.

@kdave kdave added the question Not a bug, clarifications, undocumented behaviour label Oct 26, 2022
@kdave
Copy link
Owner

kdave commented Oct 27, 2022

So there are probably more things how to do tat:

  • tweak replace - it could be possible with a minor change to the finalization, not deleting the superblock but updating it with a new metadata_uuid (that's only change in the superblock, otherwise the metadata blocks keep he old uuid, but it's effectively hidden)
  • ioctl to clone a device on a mounted filesystem, probably with constraints like only for a single device, and I'm not sure how exactly the new device should be logically connected, as it would be a new device but unusable for writes
  • add a safe way to "dd" the device with metadata_uuid change at the end, on an image it would be easy, on a mounted filesystem it would require quiescent state (like read-only mount or maybe turning the device itself to read-only)

@Forza-tng
Copy link
Contributor

A btrfs clone could be a useful command. It save having to do the mkfs.btrfs, subvol create, and send|receive (hard to do with many or nested subvols and snaps) operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Not a bug, clarifications, undocumented behaviour
Projects
None yet
Development

No branches or pull requests

3 participants