I use Ubuntu 10.04 on an embedded device. I have a CF card of 2GB formatted in FAT32. From time to time, the device is powered off while data is written to the FAT partition. As a result, the partition goes into read-only mode. I would like to know how the partition can be automatically repaired in such a situation, that is I would like to know how such an error can be detected e.g. with fsck and subsequently fixed.
I have tried using 'fsck.vfat -a -w /dev/sdax' always on boot but I have seen that taking too long and not really fixing the problem, since I had to do a 'fsck -y /dev/sdax' after that to fix the problem. So, I would like to check for errors and fix only if an error has already appeared or even always check for errors if that takes little time.