Skip to content

Feature request: btrfs replace start --new-fsid #961

Closed
@Winterhuman

Description

@Winterhuman

Version: v6.13

I learnt of this interesting feature, where a backing device can be transparently replaced with another, using the following commands:

$ truncate -s 4G /tmp/somedevice
$ losetup -f /tmp/somedevice /dev/loop0
$ btrfs replace start /path/to/current/device /dev/loop0 /

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions