09-18-2021, 04:45 PM | #1 |
Groupie
Posts: 164
Karma: 31650
Join Date: May 2011
Location: Asuncion (Paraguay)
Device: Several Kindle 3 KB's
|
Linux bash script for checking the storage on my Kindle 3 Keyboard.
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 |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Can calibre run a bash script when it's started? | Suffolk Punch | Calibre | 4 | 04-03-2015 02:55 PM |
Linux script for images to Kindle Screensaver | soymicmic | Kindle Developer's Corner | 4 | 01-28-2011 11:20 AM |
Bash Script/SQL Query for ISBN in filename? | zenrhino | Calibre | 1 | 09-26-2010 08:55 AM |
Is it possible to execute a bash script from the SD card? | godel10 | iRex | 25 | 06-25-2009 03:55 PM |
BASH script for *2lrf utilities (thanks Kovid!)... | KaiGoth | Sony Reader | 0 | 08-05-2007 01:30 AM |