On 2021/10/11 22:13, Kyle James Chapman wrote:
Hello,
I lost access to my home BTRFS filesystem on a 4TB SATA drive without partitioning today.
I am a graduate student of translation studies at a foreign university. Programming is not my specialty but have ran Linux for over a decade because I support open source endeavors. I say this for background on my technical capabilities, I am also a radio amateur extra-class in the United States. I have some technical competence and run Arch Linux for general duty.
The system boots and reads the kernel into memory from an optical ROM drive, reads keyfiles from a USB stick, decrypts the home and swap partitions on different devices, asks for a password for the root partition, and finishes booting. I was rebooting my system from userspace and observed a kernel panic after finishing some work repartitioning a small USB stick using gparted.
Any idea on what part is causing the panic, or any log/screenshot of the
panic message?
After rebooting, my home BTRFS system was not mountable. Some information seems present in some of the superblocks, but I do not understand everything. I was careful in my use of the disk tool, and it was clear that only the USB stick was being accessed, because of the simple work I was doing, resizing a partition on the obvious drive. I would like to recover the data. I finished writing my master's thesis and have already submitted it, so no real work was lost, but I would like to understand why this is happening and how the data can be recovered. A memory fault seems plausible, but the fact that I was accessing the partitions (through gparted) seems to indicate other possibilities. Please do not get sidetracked into thinking I wrote data on the drive through carelessness. I have made many many uses of disk tools throughout my life and the simple nature of the operations which did not involve the filesystem in question are completely understandable and I remember them clearly.
Please advise.
Relevant /dev/fstab entry which has worked for several months until I commented it out today:
#/dev/mapper/home /home btrfs rw,compress,autodefrag,inode_cache 0 1
Inode cache is already deprecated, but it won't do anything to the
kernel, thus it shouldn't cause any problem.
cat /proc/version:
Linux version 5.15.0-rc3-1-git-00319-g7b66f4393ad4 (linux-git@archlinux) (gcc (GCC) 11.1.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Sun, 03 Oct 2021 17:24:26 +0000
sudo smartctl -a /dev/sdd excerpt:
=== START OF INFORMATION SECTION ===
Model Family: Seagate Barracuda 2.5 5400
Device Model: ST4000LM024-2AN17V
Serial Number: WCK03H8Y
LU WWN Device Id: 5 000c50 09e55827b
Firmware Version: 0001
User Capacity: 4,000,787,030,016 bytes [4.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 5526 rpm
Form Factor: 2.5 inches
Device is: In smartctl database [for details use: -P show]
ATA Version is: ACS-3 T13/2161-D revision 5
SATA Version is: SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Mon Oct 11 16:07:49 2021 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
btrfs --version:
btrfs-progs v5.14.1
sudo btrfs inspect-internal dump-super -s 0 /dev/mapper/home :
superblock: bytenr=65536, device=/dev/mapper/home
The first copy in fact looks pretty good.
If there is something wrong, then it would be in the backup roots or sys
chunk map.
Mind to dump the full super block with "btrfs ins dump-super -Ffa"?
---------------------------------------------------------
csum_type 0 (crc32c)
csum_size 4
csum 0xc59083ff [DON'T MATCH]
bytenr 65536
flags 0x1
( WRITTEN )
magic _BHRfS_M [match]
fsid bd5872ad-8fee-4d90-b048-b81120ce3254
metadata_uuid bd5872ad-8fee-4d90-b048-b81120ce3254
label
generation 161054
root 4028020703232
sys_array_size 129
chunk_root_generation 154912
root_level 1
chunk_root 22020096
chunk_root_level 1
log_root 0
log_root_transid 0
log_root_level 0
total_bytes 4000787030016
bytes_used 3969357348864
sectorsize 4096
nodesize 16384
leafsize (deprecated) 16384
stripesize 4096
root_dir 6
num_devices 1
compat_flags 0x0
compat_ro_flags 0x0
incompat_flags 0x161
( MIXED_BACKREF |
BIG_METADATA |
EXTENDED_IREF |
SKINNY_METADATA )
cache_generation 161054
uuid_tree_generation 161054
dev_item.uuid 47593c4d-689d-4e1e-a310-dc7b8ab26c51
dev_item.fsid bd5872ad-8fee-4d90-b048-b81120ce3254 [match]
23 more quoted lines
The 2nd one begins to have some garbage, but not yet full of garbage.
This means there are some writes into the 2nd super block, and mostly
the writes are just into part of the super block.
magic _BHRfS_M [match]
fsid 4468b2e4-d249-639c-dc54-792caf170cc9
metadata_uuid 4468b2e4-d249-639c-dc54-792caf170cc9
The UUID is damaged.
label
generation 161054
root 4028020703232 > sys_array_size 129
chunk_root_generation 154912
root_level 1
chunk_root 22020096
chunk_root_level 1
But then some good data.
log_root 11922660382425005768
log_root_transid 14582268926853107316
log_root_level 0
total_bytes 10532150587539085458
bytes_used 8124524553913841719
Some garbage again.
I don't think it can be even caused by simple memory corruption, too
many random part gets corrupted.
It's really hard to say if btrfs itself is involved, until we see the
calltrace.
For the recovery, the superblock needs to be manually fixed to allow any
further data salvage attempts.
And that can only be done with the extra "btrfs ins dump-super -Ffa" output.
Thanks,
Qu
sectorsize 4096
nodesize 16384
leafsize (deprecated) 16384
stripesize 4096
root_dir 6
num_devices 1
compat_flags 0x0
compat_ro_flags 0x0
incompat_flags 0x161
( MIXED_BACKREF |
BIG_METADATA |
EXTENDED_IREF |
SKINNY_METADATA )
cache_generation 161054
uuid_tree_generation 161054
dev_item.uuid 47593c4d-689d-4e1e-a310-dc7b8ab26c51
dev_item.fsid bd5872ad-8fee-4d90-b048-b81120ce3254 [DON'T MATCH]
dev_item.type 0
dev_item.total_bytes 4000787030016
dev_item.bytes_used 3997564731392
dev_item.io_align 4096
dev_item.io_width 4096
dev_item.sector_size 4096
dev_item.devid 1
dev_item.dev_group 0
dev_item.seek_speed 0
dev_item.bandwidth 0
dev_item.generation 0
sudo btrfs inspect-internal dump-super -s 2 /dev/mapper/home:
superblock: bytenr=274877906944, device=/dev/mapper/home
---------------------------------------------------------
csum_type 62267 (INVALID)
csum_size 32
csum 0x9876fd0000000000000000000000000000000000000000000000000000000000 [UNKNOWN CSUM TYPE OR SIZE]
bytenr 274877906944
flags 0x1
( WRITTEN )
magic _BHRfS_M [match]
53 more quoted lines