mirror of
https://github.com/kmein/niveum
synced 2026-03-21 04:11:07 +01:00
add sd card fixer
This commit is contained in:
19
.bin/fix-sd.sh
Executable file
19
.bin/fix-sd.sh
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
drive="$1"
|
||||||
|
mountpoint="/media/sd-card-$(date +%s)"
|
||||||
|
|
||||||
|
trap clean EXIT
|
||||||
|
clean() {
|
||||||
|
umount "$mountpoint"
|
||||||
|
rm "$mountpoint"
|
||||||
|
}
|
||||||
|
|
||||||
|
filenames="$(fsck.exfat "$drive" 2>&1 | sed -nE "s/.* file '(.*?)' is not allocated.*/\1/p")"
|
||||||
|
mkdir "$mountpoint"
|
||||||
|
mount "$drive" "$mountpoint"
|
||||||
|
|
||||||
|
echo "$filenames" | while read -r filename; do
|
||||||
|
find "$mountpoint" -type f -name "$filename" -exec rm {} \;
|
||||||
|
done
|
||||||
|
|
||||||
Reference in New Issue
Block a user