Plagued with storage corruption linked to USB cable that do not make a good contact, I wrote the following to automate the checking of the "disk" when it got corrupted.
May require modifications for more recent Kindles, I would not know as I like the K3, and will not change ;-3)
Code:
#!/bin/bash
# Depends on dosfsck
# This script runs dosfsck on the SD of a Kindle 3
# Keyboard after umounting it.
# May require adjusting for more recent Kindles.
# © Renaud Olgiati 2021 Feel free to copy or modify.
# Use: connect a Kindle, and launch.
#Check that the Kindle is connected
rm -rf tototototo >/dev/null 2>&1
# Find the device name of the Kindle, abort if none connected.
df | grep Kindle | gawk '{print $1}' > tototototo
if [ ! -s tototototo ] ; then
echo "No Kindle connected; connect, and re-launch."
exit 1
else
# Check that the script is run as root, if not relaunch with su
if [ $UID != 0 ]; then
echo " "
echo "fsckindle must be run as root."
su -c "/home/ron/bin/fsckindle"
echo " "
exit 1
else
echo "fsckindle now running as Root."
echo " "
SD=$(cat tototototo)
fi
# umount the Kindle prior to fsck
umount /dev/$SD >/dev/null 2>&1
# Run dosfsck
# -w will write changes to the disk immediately.
# -r will ask you about the repair method, if it has more than one way to fix an inconsistency.
# -l will list the names of files being checked; can be useful to determine if there are problems with any particular object.
# -a will automatically repair the filesystem.
# -v is the verbose mode, which should be helpful.
# -t will mark bad clusters, so they aren't used.
dosfsck -w -r -l -a -v -t /dev/$SD
echo " "
echo "Done !"
# Clean-up
rm -rf tototototo >/dev/null 2>&1
fi
exit 1