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
lsblk
to find my/home
partition (/dev/sdb2
in 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 check
gave 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
umount /mnt
btrfs check --repair /dev/mapper/lvmvg-home
cryptSetup luksClose /dev/sdb2
shutdown -r now