`disk-deactivate` fails to wipe BTRFS on mdadm RAID (leaves stale data, skips mkfs)
When tearing down and reprovisioning a machine state, the `disk-deactivate` wiping logic stops `mdadm` arrays *before* wiping the filesystems residing on them.
[BTRFS stores backup superblocks](https://man7.org/linux/man-pages/man8/btrfs-select-super.8.html) at specific offsets (64 MiB, 256 GiB). If the RAID array is torn down first, the subsequent calls to `wipefs` on the underlying raw disks miss these backup superblocks. (The offsets are relative to the RAID, not to the individual disks.)
When `disko` reprovisions the machine and re-assembles the exact same `mdadm` array, the BTRFS superblocks realign. `blkid` then falsely detects an existing `btrfs` filesystem, causing `disko` to silently skip the `mkfs.btrfs` step and remount the old filesystem with all previous data intact.
Run [a gist](https://gist.github.com/kmein/9644e65ab8218a4b57c35cb9290b86ad) to reproduce the bug:
```
nix build git+https://gist.github.com/kmein/9644e65ab8218a4b57c35cb9290b86ad --no-write-lock-file --print-build-logs
```
From the logs during teardown (notice the order):
```
+ mdadm --stop md127
+ wipefs --all -f /dev/vdc1
+ wipefs --all -f /dev/vdc
+ dd if=/dev/zero of=/dev/vdc bs=440 count=1
```
From the logs during reprovisioning (format is skipped):
```
+ blkid /dev/md/raid0 -o export
+ grep -q '^TYPE='
# mkfs.btrfs is silently skipped here because grep found a match
```
关闭于 2026-04-19 0 条评论