# problems mounting fat partitions

## frnc

Hi everybody,

I have just installed a new Gentoo 2006.1. I wanted to transfer some files via pen drive, but I noted that after i copied them on the pen drive, the files have a zero byte dimension at a ls -l check. Other times, I am not allowed to copy at all, with a message like "cannot create regular file xxxx: read only filesystem". In this case dmesg says "FAT: filesystem panic (dev sdc1) clusters badly computed, filesystem has been set read only".

After playing a bit around, I came to the conclusion that the problem must be not connected with usb detecting. 

In fact, I get a similar behaviour if I mount a hard disk partition previously formatted with mkfs.vfat. Once again, the copied files have zero dimension. In both cases, if I launch a fsck.vfat /dev/xxx, I am told "file size is zero bytes, cluster chain length is > 0 bytes". Of course, letting fsck fix the typo does not prevent this from showing up next time I try to copy a file.

I read somewhere it could be a matter of language support. I have reconfigured the kernel like this:

```
CONFIG_FAT_FS=y

CONFIG_MSDOS_FS=y

CONFIG_VFAT_FS=y

CONFIG_FAT_DEFAULT_CODEPAGE=850

CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
```

and then

```
CONFIG_NLS_DEFAULT="iso8859-1"
```

but that is not showing any effect.

Any hint?

Thank you in advance

----------

## NeddySeagoon

frnc,

A few things, as well as the 

```
CONFIG_FAT_DEFAULT_CODEPAGE=850

CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"

CONFIG_NLS_DEFAULT="iso8859-1"
```

You need CODEPAGE=850 in the NLS section of the kernel. However I don't think that is your problem.

To get zero size files, it shouns as if the data copy was started, so the file enrty was made in the directory but the device was removed before the in RAM cache and the device were synced.

On windows, thats Safely Remove Device, on Linux its either sync or umount and wait for the prompt to return.

This can take several minutes for big files. Until thats done, the data is not actually on the pendrive.

I suspect your data is not there to read.

----------

## frnc

NeddySeagoon, thank you for your answer.

I don't think a premature unmount can be the reason of my problem. The files I wanted to copy are very small (1 kb or so), and the message "cannot create regular file" most of the times appears _before_ the copy is even tried. Other than this, the same behaviour shows up on the vfat hard disk partition, with no unmount at all being performed.

----------

## NeddySeagoon

frnc,

How do you mount the vfat partition ?

What in in your /etc/fstab for it ?

----------

## frnc

as I am still configuring the system, I have not a fixed entry in etc/fstab.

I do it on the fly with:

```
mount -t vfat /dev/sdc1 /mnt/usb
```

for the pen drive and with

```
mount -t vfat /dev/sdb4 /mnt/a_partition
```

for the hard disc

Also with -o rw, but no effect.

In this last try: zero-byte writing for the pen drive, "cannot create regular file" for the hard disc.

Dmesg says: Filesystem panic (dev sdb4).

Regards

----------

## NeddySeagoon

frnc,

Those mount commands will allow thr root user access only.

Try adding in 

```
-o umask=0
```

```
mount -t vfat -o umask=0 /dev/sdc1 /mnt/usb
```

That allows all users full access but makes no difference for root.

vfat does not understand *NIX permossions, so umask=0 is like 

```
chmod -R 777 * 
```

on the vfat filesystem.

Do *not* *ever* use that chmod command.

----------

## frnc

Thank you.

I was trying to copy the files as root. Anyway, I mounted the hard disc with the - o umask=0 option and tried to copy again: again, same effect, zero-bytes files.

Let me restate the point: I can see perfectly the content of usb pen and of hard disc. Only, I can't write on them - even as root. I realize that the title I chose for this thread is a little misleading: not problems with mounting, rather problems with writing on vfat. Sorry for this.

Regards

----------

## NeddySeagoon

frnc,

There are two USB block device drivers in the kernel, one is called usb-storage and is found in the main USB section of of the kernel config. The other is Low perfomance USB block device in the Block Devices section (from memory)

You should be using usb-storage with the SCSI disk option, not the Low perfomance USB block device driver.

How is your kernel set up?

----------

## frnc

Thanks NeddySeagoon.

the Low performance USB Block driver is disabled. 

SCSI generic support, SCSI cdrom and disk support, USB mass storage support are all enabled. 

Anyway I wonder why it should be a usb problem, since similar oddities happen in a usb pen drive but also in a sata2 internal hard disc partition. 

regards

----------

## NeddySeagoon

frnc,

After the write fails, are there any error messages at the end of dmesg ?

Using the sync command to attempt to flush the disk buffer may help provoke something.

----------

## frnc

well, after the failed copy operation, dmesg reports at the end "Filesystem panic (dev sdb4) clusters badly computed (1 != 0) File system has been set read-only". 

the sync command does not show any particular effect.. really no idea...

----------

## theDOC_23

I have a similar problem with my usb-stick. I needed to dump a dos boot image directly to it (not the partition). After things were done, I cleaned the stick with dd and created a new partition.

But when I create a fat filesystem and write files to it, the space is gone (as shown by df) but the filesizes are zero. No error messages in the logfiles. fsck shows a bunch of "File size is 0 bytes, cluster chain length is > 0 bytes." messages.

However, using jfs works fine.

----------

