All of lore.kernel.org
 help / color / mirror / Atom feed
* btrfs: multi-device pool corrupted after repeated removal/recreation of missing device
       [not found] <JJ5S5tQDVkTmHxqx0ncj423p-TgogJGM8fSviYuGeF1i-xc7NtTdlmd1VO0aopC3SEVqYZF_Z6opVqrTz4eJ8sbDOiceQNzgwnjerSXJWhM=@proton.me>
@ 2026-05-30 20:25 ` xerobrinhek
  2026-05-30 22:55   ` Roman Mamedov
  0 siblings, 1 reply; 2+ messages in thread
From: xerobrinhek @ 2026-05-30 20:25 UTC (permalink / raw)
  To: linux-btrfs

Hello btrfs developers,

I have a btrfs multi-device setup that got corrupted after a failed device removal. I need help recovering the filesystem structure (not just raw file extraction).

Setup:

- Two devices: nvme0n1p9 (17.53GB) and nvme0n1p8 (31,30GB) originally

- The filesystem uses subvolumes: @, @home, @var, @snapshots

- Compression: enabled (zstd)

What happened:

1. I removed /dev/nvme0n1p8 (devid 2) from the pool without proper 'btrfs device remove'

2. I tried to recreate the missing device multiple times, creating and removing btrfs on it

3. Now the filesystem won't mount at all

Current symptoms:

Mount attempt:

# mount -t btrfs -o degraded,ro,rescue=all /dev/nvme0n1p9 /mnt

mount: /mnt: can't read superblock on /dev/nvme0n1p9.

dmesg shows:

[  688.380328] BTRFS warning: 'usebackuproot' is deprecated, use 'rescue=usebackuproot' instead

[  688.385530] BTRFS info (device nvme0n1p9): first mount of filesystem 0d554048-1a10-4fbe-9d7d-80de9d3f0700

[  688.385538] BTRFS info (device nvme0n1p9): using crc32c checksum algorithm

[  688.386981] BTRFS warning (device nvme0n1p9): devid 2 uuid a8559fa6-e465-459f-ac73-86c842aa6fe0 is missing

[  688.388044] BTRFS warning (device nvme0n1p9): failed to read root (objectid=4): -5

[  688.388060] BTRFS warning (device nvme0n1p9): try to load backup roots slot 1

[  688.388425] BTRFS warning (device nvme0n1p9): global root 2 0 already exists

[  688.388433] BTRFS error (device nvme0n1p9): failed to load root extent

[  688.388440] BTRFS warning (device nvme0n1p9): try to load backup roots slot 2

[  688.388498] BTRFS warning (device nvme0n1p9): couldn't read tree root

[  688.388505] BTRFS warning (device nvme0n1p9): try to load backup roots slot 3

[  688.388773] BTRFS warning (device nvme0n1p9): global root 2 0 already exists

[  688.388776] BTRFS error (device nvme0n1p9): failed to load root extent

[  688.389043] BTRFS error (device nvme0n1p9): open_ctree failed: -17

What I tried (all from Fedora Live USB):

1. Superblock recovery:

# btrfs rescue super-recover -v /dev/nvme0n1p9

All supers are valid, no need to recover

2. Zero log:

# btrfs rescue zero-log /dev/nvme0n1p9

Couldn't setup device tree

ERROR: could not open ctree

3. Chunk recover on both devices:

# btrfs rescue chunk-recover -y -v /dev/nvme0n1p8

Result: Chunk tree recovered successfully (generation 9, chunk root gen 😎

# btrfs rescue chunk-recover -y -v /dev/nvme0n1p9

Result: Chunk tree recovery failed (the device is the main one with data)

4. Mount with various options all fail with either "can't read superblock" or "FS exist" error:

- degraded,ro,subvol=@

- degraded,ro,rescue=all

- degraded,ro,usebackuproot

- degraded,ro,sb=1 (parameter unknown)

Key observation:

btrfs-find-root shows there are valid roots at various addresses, but mounting fails with EEXIST (-17) and "global root 2 0 already exists" errors.

Questions:

1. Is there any way to force the filesystem to forget about missing devid 2 and mount using only nvme0n1p9?

2. Can I manually copy the chunk tree from p8 to p9 using dd at specific offsets?

3. What would be the correct procedure to rebuild the extent tree and root tree without losing subvolume structure?

4. Is --init-extent-tree a viable option at this stage?

I understand the risk of data loss. My goal is to restore the filesystem structure (subvolumes, names, directory hierarchy), not just raw file extraction.

Thank you for your time.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: btrfs: multi-device pool corrupted after repeated removal/recreation of missing device
  2026-05-30 20:25 ` btrfs: multi-device pool corrupted after repeated removal/recreation of missing device xerobrinhek
@ 2026-05-30 22:55   ` Roman Mamedov
  0 siblings, 0 replies; 2+ messages in thread
From: Roman Mamedov @ 2026-05-30 22:55 UTC (permalink / raw)
  To: xerobrinhek; +Cc: linux-btrfs

On Sat, 30 May 2026 20:25:42 +0000
xerobrinhek <xerobrinhek@proton.me> wrote:

> Hello btrfs developers,
> 
> I have a btrfs multi-device setup that got corrupted after a failed device
> removal. I need help recovering the filesystem structure (not just raw file
> extraction).
> 
> Setup:
> 
> - Two devices: nvme0n1p9 (17.53GB) and nvme0n1p8 (31,30GB) originally
> 
> - The filesystem uses subvolumes: @, @home, @var, @snapshots
> 
> - Compression: enabled (zstd)

What were the profiles used for data and metadata? Since they were both on the
same physical device, did you use "single"? And what for metadata, e.g. I
believe DUP wouldn't guarantee copies across different devices in this case.

> 1. I removed /dev/nvme0n1p8 (devid 2) from the pool without proper 'btrfs device remove'

How do you "remove" partition 8 of an NVMe drive, at the same time retaining
partition 9 of the same NVMe drive? Just by deleting the partition? Recreating
it with the same offset would have been enough to make btrfs see it again
(after a device-scan).

> 2. I tried to recreate the missing device multiple times, creating and removing btrfs on it

This bit sounds weird, what exactly do you mean by that? If mkfs.btrfs, then
that makes an entirely separate FS, ruining all data that was on there before,
and with a guarantee to do so, because it full-device TRIMs the partition.

> I understand the risk of data loss. My goal is to restore the filesystem
> structure (subvolumes, names, directory hierarchy), not just raw file
> extraction.

I'd suggest to abandon that goal, all of that doesn't seem comparably as
important as the actual data (that you can try to btrfs-recover or just restore
from backups).

-- 
With respect,
Roman

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-30 23:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <JJ5S5tQDVkTmHxqx0ncj423p-TgogJGM8fSviYuGeF1i-xc7NtTdlmd1VO0aopC3SEVqYZF_Z6opVqrTz4eJ8sbDOiceQNzgwnjerSXJWhM=@proton.me>
2026-05-30 20:25 ` btrfs: multi-device pool corrupted after repeated removal/recreation of missing device xerobrinhek
2026-05-30 22:55   ` Roman Mamedov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.