Solution and prevention of "General error mounting filesystem failed " in ubuntu

There could be many cases where "error mounting filesystem failed" problem can occur.
While starting up ubuntu returned this message with information "please run fcsk manually".After running following command in the debugging terminal solved the problem for me:
fsck.ext2 /dev/sda1 (ext2 or sda1 depend upon ubuntu installation on your system).

When i looked into the root cause of above error, it was due to improper shutdown.When the battery of the system reach to critically low level(almost 0%), then system goes off.This was the reason shutdown was improper.There could be many solution for this, i have one automated solution for this.

In linux, "acpi" command returns the status of battery like % level of battery, charging/discharging etc.Now, we run a script that continuously monitors the status of battery and we can interrupt a graceful shutdown if battery label is below some threshold value and battery is discharging.How to do that?Just copy paste the following script in a file,configure it as per the need and add this script in startup application.


************************************************************************************************
i=0
while [ $i -le 1 ] ;do
TH=13 //set the threshold value here..

label=`acpi |awk '{print $4}'|sed 's/%,//'`
charge=`acpi |awk '{print $3}' |sed 's/,//'`

TH0=`expr $TH + 3`
if [ $label -le $TH0 ] && [ $label -gt $TH ] && [ $charge = "Discharging" ] ;then
echo "Your Battery is getting lower...please connect charger.."

//Instead of this beep sound can be generated..
fi

if [ $label -le $TH ] && [ $charge = "Discharging" ];then
echo "Your Battery is getting lower than threshold.connect cable.."
shutdown -h now

fi

sleep 10
done

************************************************************************************************

Comments

Unknown said…
Thanks for such a valuable information Indu ji.. hope you will continue providing such solutions in near future. All the best.