btrfs root filesystem corruption
2024
- Boots into initfs
- run $ btrfs device scan
- run $ btrfs filesystem show /dev/sdXX
run $ mount -t btrfs -o recovery,ro /dev/<device_name> /<mount_point>
run $ btrfs check --repair /dev/<device_name>
Was now able to mount on /mnt
mount -t btrfs -o rescue,ro /Dec/sda2 /mnt # ): err again errno=-5 IO failure
run $ btrfs rescue zero-log /dev/<device_name>
- run $ btrfs rescue chunk-recover /dev/sdb
2017
- Linux hangs, i rebooted with with power button.
- Only boots into rescue shell can't mount btrfs root raid0 over two ssd's.
- Boot with live Ubuntu 16.04 usb thumbdrive.
$ sudo btrfs rescue chunk-recover -y -v /dev/sda2 > btrfs_rescue_chunk-recover-y-v.txt
- capture btrfs rescue, with stdio+stderr to one file and stderr to 2nd file
$ sudo btrfs rescue chunk-recover -y -v /dev/sda2 2>btrfs4.9.1_error.out.txt 1>btrfs4.9.1_stdio.out.txt
- $ sudo dpkg -i btrfs-progs_4.9.1-1ubuntu1_amd64.deb btrfs-tools_4.9.1-1ubuntu1_amd64.deb
- $ btrfs --version
- btrfs-progs v4.9.1
$ sudo btrfsck --repair -y -v /dev/sda2 2>btrfs4.9.1_repair.error.out.txt 1>btrfs4.9.1_repair.stdio.out.txt
- Aborted (core dumped)
$ sudo btrfs check /dev/sda2 incorrect offsets 14881 539169 Checking filesystem on /dev/sda2 UUID: be6d3734-fb49-42d0-973c-547949d1b013 checking extents incorrect offsets 14881 539169 bad block 558842675200 Errors found in extent allocation tree or chunk allocation checking free space cache checking fs roots incorrect offsets 7795 532083 ... ... incorrect offsets 7795 532083 incorrect offsets 7795 532083 incorrect offsets 7795 532083 incorrect offsets 7795 532083 incorrect offsets 7795 532083 incorrect offsets 7795 532083 unresolved ref dir 15472 index 0 namelen 104 name ECRYPTFS_FNEK_ENCRYPTED&FXZvkd1KmbFm2-TLjTCVJL3ZxYtD-zomwbXYUucAHBkMRRCJlE9vuOS36gm9wpi7LxUvI9UT8B7H6Js- filetype 1 errors 6, no dir index, no inode ref unresolved ref dir 15472 index 152801 namelen 104 name ECRYPTFS_FNEK_ENCRYPTED.FXZvkd1KmbFm2-TLjTCVJL3ZxYtD-zomwbXYUucAHBkMRRCJlE9vuOS36gm9wpi7LxUvI9UT8B7H6Js- filetype 1 errors 1, no dir item root 258 inode 772374 errors 100, file extent discount Found file extent holes: start: 0, len: 24576 found 105208057971 bytes used err is 1 total csum bytes: 0 total tree bytes: 46825472 total fs tree bytes: 0 total extent tree bytes: 46710784 btree space waste bytes: 16700977 file data blocks allocated: 59506688 referenced 59506688 ubuntu@ubuntu:~$
$ sudo btrfs rescue chunk-recover -v /dev/sda2 All Devices: Device: id = 2, name = /dev/sdb2 Device: id = 1, name = /dev/sda2 ... ... ... Unrecoverable Chunks: Chunk: start = 0, len = 4194304, type = 2, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 0 No block group. No device extent. Chunk: start = 4194304, len = 8388608, type = 4, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 4194304 No block group. No device extent. Chunk: start = 104173928448, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 104173928448 No block group. No device extent. Chunk: start = 105247670272, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 103100186624 No block group. No device extent. Chunk: start = 106321412096, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 100952702976 No block group. No device extent. Chunk: start = 107395153920, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 99878961152 No block group. No device extent. Chunk: start = 108468895744, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 97731477504 No block group. No device extent. Chunk: start = 109542637568, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 95583993856 No block group. No device extent. Chunk: start = 110616379392, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 93436510208 No block group. No device extent. Chunk: start = 111690121216, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 91289026560 No block group. No device extent. Chunk: start = 112763863040, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 89141542912 No block group. No device extent. Chunk: start = 113837604864, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 88067801088 No block group. No device extent. Chunk: start = 114911346688, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 86994059264 No block group. No device extent. Chunk: start = 115985088512, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 83772833792 No block group. No device extent. Chunk: start = 117058830336, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 82699091968 No block group. No device extent. Chunk: start = 118132572160, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 81625350144 No block group. No device extent. Chunk: start = 119206313984, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 80551608320 No block group. No device extent. Chunk: start = 120280055808, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 79477866496 No block group. No device extent. Chunk: start = 121353797632, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 78404124672 No block group. No device extent. Chunk: start = 122427539456, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 77330382848 No block group. No device extent. Chunk: start = 123501281280, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 75182899200 No block group. No device extent. Chunk: start = 124575023104, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 74109157376 No block group. No device extent. Chunk: start = 125648764928, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 73035415552 No block group. No device extent. Chunk: start = 126722506752, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 70887931904 No block group. No device extent. Chunk: start = 127796248576, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 69814190080 No block group. No device extent. Chunk: start = 128869990400, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 68740448256 No block group. No device extent. Chunk: start = 129943732224, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 67666706432 No block group. No device extent. Chunk: start = 131017474048, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 65519222784 No block group. No device extent. Chunk: start = 132091215872, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 64445480960 No block group. No device extent. Chunk: start = 133164957696, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 62297997312 No block group. No device extent. Chunk: start = 134238699520, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 61224255488 No block group. No device extent. Chunk: start = 135312441344, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 59076771840 No block group. No device extent. Chunk: start = 136386183168, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 58003030016 No block group. No device extent. Chunk: start = 137459924992, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 56929288192 No block group. No device extent. Chunk: start = 138533666816, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 54781804544 No block group. No device extent. Chunk: start = 139607408640, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 53708062720 No block group. No device extent. Chunk: start = 140681150464, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 52634320896 No block group. No device extent. Chunk: start = 141754892288, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 51560579072 No block group. No device extent. Chunk: start = 142828634112, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 49413095424 No block group. No device extent. Chunk: start = 143902375936, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 48339353600 No block group. No device extent. Chunk: start = 144976117760, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 47265611776 No block group. No device extent. Chunk: start = 146049859584, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 46191869952 No block group. No device extent. Chunk: start = 147123601408, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 45118128128 No block group. No device extent. Chunk: start = 148197343232, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 44044386304 No block group. No device extent. Chunk: start = 149271085056, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 42970644480 No block group. No device extent. Chunk: start = 150344826880, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 41896902656 No block group. No device extent. Chunk: start = 151418568704, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 40823160832 No block group. No device extent. Chunk: start = 152492310528, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 39749419008 No block group. No device extent. Chunk: start = 153566052352, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 38675677184 No block group. No device extent. Chunk: start = 154639794176, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 37601935360 No block group. No device extent. Chunk: start = 155713536000, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 36528193536 No block group. No device extent. Chunk: start = 156787277824, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 35454451712 No block group. No device extent. Chunk: start = 157861019648, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 34380709888 No block group. No device extent. Chunk: start = 158934761472, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 33306968064 No block group. No device extent. Chunk: start = 160008503296, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 32233226240 No block group. No device extent. Chunk: start = 161082245120, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 31159484416 No block group. No device extent. Chunk: start = 162155986944, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 30085742592 No block group. No device extent. Chunk: start = 163229728768, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 29012000768 No block group. No device extent. Chunk: start = 164303470592, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 27938258944 No block group. No device extent. Chunk: start = 165377212416, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 26864517120 No block group. No device extent. Chunk: start = 166450954240, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 25790775296 No block group. No device extent. Chunk: start = 167524696064, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 24717033472 No block group. No device extent. Chunk: start = 168598437888, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 23643291648 No block group. No device extent. Chunk: start = 169672179712, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 22569549824 No block group. No device extent. Chunk: start = 170745921536, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 21495808000 No block group. No device extent. Chunk: start = 171819663360, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 20422066176 No block group. No device extent. Chunk: start = 172893405184, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 19348324352 No block group. No device extent. Chunk: start = 173967147008, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 18274582528 No block group. No device extent. Chunk: start = 175040888832, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 17200840704 No block group. No device extent. Chunk: start = 176114630656, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 15053357056 No block group. No device extent. Chunk: start = 177188372480, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 13979615232 No block group. No device extent. Chunk: start = 178262114304, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 12905873408 No block group. No device extent. Chunk: start = 179335856128, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 10758389760 No block group. No device extent. Chunk: start = 180409597952, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 8610906112 No block group. No device extent. Chunk: start = 181483339776, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 7537164288 No block group. No device extent. Chunk: start = 182557081600, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 5389680640 No block group. No device extent. Chunk: start = 183630823424, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 4315938816 No block group. No device extent. Chunk: start = 184704565248, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 3242196992 No block group. No device extent. Chunk: start = 185778307072, len = 1073741824, type = 1, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 2168455168 No block group. No device extent. Chunk: start = 186852048896, len = 1073741824, type = 4, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 6463422464 No block group. No device extent. Chunk: start = 187925790720, len = 33554432, type = 2, num_stripes = 1 Stripes list: [ 0] Stripe: devid = 1, offset = 12582912 No block group. No device extent. Total Chunks: 197 Recoverable: 116 Unrecoverable: 81 Orphan Block Groups: Orphan Device Extents: incorrect offsets 14881 539169 incorrect offsets 14881 539169 Search block group failed(-1) ...
$ sudo btrfsck --repair /dev/sda2 enabling repair mode incorrect offsets 14881 539169 repair mode will force to clear out log tree, Are you sure? [y/N]: y Unable to find block group for 0 extent-tree.c:289: find_search_start: Assertion `1` failed. btrfs check[0x438110] btrfs check(btrfs_reserve_extent+0x70b)[0x43c31e] btrfs check(btrfs_alloc_free_block+0x63)[0x43c5ae] btrfs check(__btrfs_cow_block+0x100)[0x430792] btrfs check(btrfs_cow_block+0x93)[0x430d3b] btrfs check[0x434cc4] btrfs check(btrfs_commit_transaction+0xb5)[0x436519] btrfs check(cmd_check+0x424)[0x424963] btrfs check(main+0x139)[0x40ec30] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f828446b830] btrfs check(_start+0x29)[0x40ec69] ubuntu@ubuntu:~$
...