Really strange FAT32 file listing problem

filesystemslsmount

I'm mounting a FAT32 drive on my NAS (which has a USB port), and hitting a strange issue when I use the ls command on the drive root:

ls: cannot access ???²é?u.g: Input/output error
ls: cannot access ?f$?â?.k: Input/output errorPuTTY
ls: cannot access ?21ï??é.ìk?: Input/output error
ls: cannot access ºq`{??ùê.?zï: Input/output error
ls: cannot access +?l`æ~2?.]9: Input/output error
ls: cannot access ??j.é: Input/output error
ls: cannot access ëégö²?è.?« Input/output error
?.¢??: Input/output error
ls: cannot access ??d?¬«ëc.?½f: Input/output error
ls: cannot access ?r??%f.o??: Input/output error
ls: cannot access b}?çb¼=u.?c·: Input/output error
}??..÷p½: Input/output error
ls: cannot access u?;e?j?.

I'm not sure why "PuTTy" is thrown in there on the second line. It is the client I'm using to access the NAS, and I'm running the latest version, but I don't understand what it has to do with the ls command. It goes on like this for a while and then starts listing files that aren't really there along with the files that are:

�?=?^Oaa�.h?=
?*ab^G^S??.?^[?
a?cw??^?*.=?$
�??a�h��.?�?
??a�?^_j!.?i?
�?a?m??^U.a^G^?
apps
??^Q??a?y.�?z

I'm running Debian/Lenny (now), but I had the same problem before I switched to Debian on my NAS. I'm not sure which distro I was running before, I think it was a custom build.

When I plug the drive in, sdc and sdc1 appear in the /dev directory. I'm unable to mount sdc, but can successfully mount sdc1. These are the command I've tried using to mount:

mount /dev/sdc1 /USB
mount -t vfat /dev/sdc1 /USB
mount -o umask=0 -t vfat /dev/sdc1 /USB

# Additional
mount -t vfat -o codepage=850 /dev/sdc1 /USB
mount -t msdos -o codepage=850 /dev/sdc1 /USB
mount -t vfat -o codepage=869 /dev/sdc1 /USB
mount -t vfat -o codepage=850,iocharset=iso8859-7 /dev/sdc1 /USB
# ... and combinations of codepage 850, 869, 437 (the common ones)
# ... and combinations of utf8, iso8859-7, iso8859-1
# ... and additional flags such as umask=0, rw

If I check the logs after the ls command, this is the result:

$ dmesg | tail
FAT: Filesystem panic (dev sdc1)
    invalid access to FAT (entry 0x8c31db6e)
FAT: Filesystem panic (dev sdc1)
    invalid access to FAT (entry 0xee786bb9)
FAT: Filesystem panic (dev sdc1)
    invalid access to FAT (entry 0x2f16a272)
FAT: Filesystem panic (dev sdc1)
    invalid access to FAT (entry 0xa8ee938e)
FAT: Filesystem panic (dev sdc1)
    invalid access to FAT (entry 0x6df5a84f)

I'll be honest, my Linux knowledge isn't that great — it's limited mostly to basic administrative tasks. Of course, if I plug the drive into Windows (7) it works fine.

One final note perhaps worth mentioning is that I remember having to use a special tool to format the drive because it was too large for Windows to format it.

EDIT

On closer inspection of the drive, all files appear to be present – so where is linux getting all this garbage from? There are only several files and folders in the root directory on Windows. Could it be data that has not been properly disposed of?

EDIT 2

The same problem in Ubuntu on my Laptop PC. Both ls and the file explorer show these strange file listings.

Best Answer

That looks like a codepage issue. Look in the man page for mount - in the fat sections, there is a codepage= setting you can use.

Also look at the iocharset= setting. (And search the web for both.)

Related Question