Files
blog-public/content/blog/btrfs-fix.md
2025-07-18 13:19:19 +08:00

46 lines
858 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: 'Btrfs Fix'
date: 2025-07-06T13:12:10+08:00
draft: true
summary: some summary
---
```
sudo btrfs scrub start /
sudo btrfs scrub status /
```
```
sudo dmesg | grep BTRFS | bat
```
确定块大小
```
sudo btrfs inspect-internal dump-super /dev/mapper/root1 | grep -i sector
```
定位到 2537392 扇区错误,在服务器上的是:
```
3420: 124352.. 124384: 2537365.. 2537397: 33: 43046457: shared
```
在备份中的是:
```
3321: 124352.. 124384: 5818956505..5818956537: 33: 5789786767:
```
在服务器上,我们取 logical 10393157632 和它前面一个扇区处的数据 10393153536
```
sudo btrfs-map-logical -l 10393157632 -b 40960 /dev/mapper/root1
```
得到物理偏移后,把数据 dd 出来:
```
sudo dd if=/dev/mapper/root1 bs=4096 skip=$((10393157632/4096)) count=1 of=/dev/shm/b1
```