There is a lot of discussion in this thread about SD corrpution on umount detailing the different ways the default xandros installation does a shutdown and suspend and how the unmounting of external devices is handled (SD cards, USB and truecrypt volumes). Here is some insight into possible solutions.
It is important to understand which scripts are called by xandros on shutdown and suspend.
(The Zz button)
unmounting on suspend will close any applications you have open using those files, which slightly defeats the use of suspending in the first place. The system will have to remount the disk when you come out of suspend. You can get over this by putting in a line to remount the SD card into suspend2ram.sh after it comes back for suspend.
Important to note that apart from the jumount.sh script the others are scripts which are already on your system and which programs like Tweakee other tweak programs copy from their own archive. Meaning, when you edit the system scripts and then make a change in a tweak program you might find your changes lost.
Change the paths for your paticular SD or USB drive mount point.
### jumount.sh ### #!/bin/bash sync echo $(date) >> /var/log/jumount.log # write list of open files on SD card to temp file lsof | grep "/home/user/sdhc" > /tmp/jumount.log # copy temporary list to log file cat /tmp/jumount.log >> /var/log/jumount.log # kill any processes with open files grep "/home/user/sdhc" /tmp/jumount.log | awk '{system ("kill -TERM "$2)}' # wait for the processes to unwind sleep 2 sync # use eject to dismount the SD card (essential!) /usr/bin/eject /home/user/sdhc 2>> /var/log/jumount.log # check if eject has fully dismounted SD card. If not, dismount it explicitly df | grep /home/user/sdhc | awk '{system("umount "$1)}'
This script unmounts a truecrypt partition whose raw file is on a SD card. It unmounts the encrypted partition first and then unmounts the SD drive that contained the raw file. If you run this by hand you will need to do so outside of the path for the SD or truecrypt drives.
#!/bin/sh # IMPORTANT: we use this value to avoid killing ourselves. should match # the script file name: SCRIPTNAME=unmountenc # Set this to the mountpoint of your SD card SD=/media/D: # Shouldnt need to change this unless you have other encrypted drives. This is the loop device for the encrypted drive. DEV=/dev/loop0 MNT=`df | grep $DEV | awk '{print $6}'` echo "Closing applications using $MNT ($DEV):" # if we are running under the SD or MNT we want to unmount # we have to avoid killing ourselves by filtering out: # grep, lsof, awk, sort, uniq, our PID for bash, script name sudo lsof +c 0 | grep $MNT | awk '{print $1 " " $2}' | sort | uniq | egrep -v "grep|lsof|awk|sort|uniq|$PPID|$SCRIPTNAME" || echo "no applications using $MNT" # 15 = SIGTERM echo "First sync disks before closing the applications" sudo sync echo "Now closing applications" sudo lsof +c 0 | grep $MNT | awk '{print $1 " " $2}' | sort | uniq | egrep -v "grep|lsof|awk|sort|uniq|$PPID|$SCRIPTNAME" | awk '{system("kill -15 "$2)}' # wait for processes to stop sleep 3 echo "Unmounting $MNT and $SD" sudo sync && truecrypt -d && sudo sync && sudo eject $SD echo "check df:" df | egrep "$MNT|$DEV|$SD" || echo everything unmounted
You can add this script to the end of the jumount.sh and add an icon to your desktop sudo /home/user/jumount.sh to unmount while your computer is still on and have confirmation that it was successful!!
varCheck=`mount | grep " /home/user/SDHC "` if [[ ${#varCheck} > 0 ]] then zenity --error \ --text="Close all programs and try again" else zenity --info \ --text="Drive is unmounted" fi