Find and delete corrupted files on btrfs
Some days ago my laptop overheated and then turned off. I booted it up again, opened Chromium and got the “cannot load profile” error. I tried the usual “delete & resync” approach, but it didn’t work. One file got corrupted due to the sudden shutdown and I wasn’t able to delete it.
In order to fix this issue, I applied the following steps:
- booted-up a linux live distro
lsblkto find my
/dev/sdb2in this case)
cryptsetup luksOpen /dev/sdb2
btrfs check /dev/mapper/lvmvg-root
btrfs check /dev/mapper/lvmvg-home
btrfs check --repair /dev/mapper/lvmvg-root
btrfs check --repair /dev/mapper/lvmvg-home. That one didn’t succeed because of a corrupted file.
btrfs checkgave me the inode of the corrupted file, so the only thing left was to find it and delete it.
mount /dev/mapper/lvmvg-home /mnt
find /mnt -inum XXXXX
rm -f /mnt/DAMAGED_FILE
btrfs check --repair /dev/mapper/lvmvg-home
cryptSetup luksClose /dev/sdb2
shutdown -r now