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

bcachefs format can overwrite existing bcachefs filesystem with no warning #346

Open
iskarian opened this issue Oct 26, 2024 · 1 comment

Comments

@iskarian
Copy link

Not sure if this is a documentation or implementation error.

I initially formatted one device with bcachefs

bcachefs format \
--label=bulk.hdd1 /dev/sdb1 \
--compression=lz4

transferred some data do it, then (naively) attempted to add a cache layer in front of it

bcachefs format \
--label=cache.nvme1 /dev/nvme/cache \
--label=bulk.hdd1 /dev/sdb1 \
--compression=lz4 \
--foreground_target=cache \
--promote_target=cache \
--metadata_target=cache \
--background_target=bulk \
--metadata_replicas=2

which succeeded without errors, silently overwriting the data on /dev/sdb1. I would argue that this is a common enough use case that warning would be a good idea. In fact, in the manpage, there is an option

            -f, --force
                     Force the filesystem to be created, even if the device already contains a filesystem.

so I would assume that the default is to warn before overwriting.

# bcachefs version
1.12.0

Also, if anyone has suggestions for how I might recover said overwritten data...

@g2p
Copy link

g2p commented Oct 28, 2024

The issue was that bcachefs superblock detection can silently fail due to an outdated blkid dependency. That's now detected at format time (#347) but it needs to be in a release. Am also proposing #348 and #336 to make packaging less error prone.

For recovery, I have no idea if it's possible, but I would hold on to that superblock dump you mentioned, as that has various filesystem UUIDs and parameters that might turn out useful to detect where the previous data is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants