Last active
December 17, 2022 06:28
-
-
Save hdevalence/8088497 to your computer and use it in GitHub Desktop.
Btrfs corrupt file locator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
echo "Looking for failed csum inodes...." | |
inodes=`dmesg | grep csum | sed 's/^.*ino \([0-9]*\) .*$/\1/g' | uniq` | |
echo "Finding system files from inodes..." | |
sysfiles=`for i in $inodes; do find /etc /opt /root /srv /usr /var -inum $i 2>/dev/null; done` | |
echo "Finding user files from inodes..." | |
homefiles=`for i in $inodes; do find /home -inum $i 2>/dev/null; done` | |
echo "Attempting to reinstall corrupted packages..." | |
# Get list of packages with corrupt files | |
packages=$(for f in $sysfiles; do pacman -Qqo $f 2>/dev/null; done) | |
# Reinstall corrupted packages | |
pacman -S $(echo $packages | uniq) | |
# Find other system files | |
othersys=$(for f in $sysfiles; do pacman -Qqo $f 2>&1 | grep error | sed 's/error: No package owns \(.*\)$/\1/'; done) | |
echo "Unowned system files:" | |
for f in $othersys; do echo -e " $f"; done | |
echo "User files:" | |
for f in $homefiles; do echo -e " $f"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment