Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm using the FAT32 file system for my pen drive. It's frequently facing file/data corruptions.

In Windows, I used the scan disk utility to fix the FAT32/NTFS file systems. How can I do this in Ubuntu?

share|improve this question
1  
Do you safely eject? –  hexafraction Jun 6 '12 at 12:20

3 Answers 3

up vote 24 down vote accepted

Try typing the following command in the Linux terminal:

sudo dosfsck -w -r -l -a -v -t /dev/sdc1

sdc1 is usually your pen drive. You can find your pen drive by typing mount in terminal. It's somewhere inside. If that commad takes too much time for you, avoid -t switch.

  • -a means automatically fix errors. Do not use it, if You want to have more control over fixing possible errors.
  • -w means write to disk immediately.
  • If You want to be sure not to lose Your data - create backup of the source device
share|improve this answer
    
What other file system this command capable to fix other than FAT32? –  Shaharil Ahmad Nov 28 '13 at 8:53
    
@ShaharilAhmad FAT16, which maybe still be used. For example I got an mini 2GB sd card with FAT16. –  keiki Jul 5 at 9:36
    
But if I don't do -t, then next time it tries again to use the bad clusters next time? –  keiki Jul 5 at 9:37

You can try Dosfsck, which is a component of dosfstools.

For this, type in terminal:

sudo apt-get install dosfstools

To use Dosfsck, you have to indicate the device address you want (Ex. /dev/sdb1, /dev/sdb2, or other device.).

To know your device address, open the terminal (CTRL+ALT+T), then run this command:

mount

If your partition is /dev/sdb1, for example, then unmount it first by running this command:

sudo umount /dev/sdb1

Now you can verify and repair your partition by running this command:

sudo dosfsck -t -a -w /dev/sdb1

Hope this helps.

Note:

if you receive the following error, when your USB flash drive is not recognized:

Error: Buffer I/O error on device sdb1

Run this command:

dmesg|tail

If the output is:

end_request: I/O error, dev sdb1, sector 0
Buffer I/O error on device sdb1, logical block 0

Run this command:

sudo dosfsck -t -a /dev/sdb1

Of course, you must change the device address to your needs, like i wrote above.

share|improve this answer
    
in 13.04 the umount seems to work also without sudo –  giuspen Jun 7 '13 at 8:13

Also try:

fsck.vfat -r /dev/sdXn
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.