Using Ubuntu 14.04.1 LTS, I have mounted a 1 TB usb drive formatted with FAT32.

The drive was mounted with this command (no error) :

sudo mount -t vfat /dev/sdc1 /media/jpgs/
  • I create a single folder named "test"
  • I copy images into this folder (~ 5MB per image)
  • After ~ 20000 files copied, the system throws this error : ... No space left on device

That's obviously not the case, as I can still create a new directory and copy files into it...

According to this question : https://stackoverflow.com/questions/466521/how-many-files-can-i-put-in-a-directory, I should be able to put 65,535 files per directory.

I have read many questions regarding this issue and cannot find a clear explanation nor a solution.

I have tested it with different versions of ubuntu and different drives and I always see the same error.

No problem when I plug the drive on a mac osX system.

Results of fdisk, df, fsck :

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdc1             932G   63G  869G   7% /media/jpgs

$ fdisk -l
Disk /dev/sdc: 1000.2 GB, 1000202043392 bytes
255 heads, 63 sectors/track, 121600 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1      121601   976759749    b  W95 FAT32

fsck from util-linux-ng 2.17.2
dosfsck 3.0.9, 31 Jan 2010, FAT32, LFN
/dev/sdc1: 24068 files, 2059652/30516291 clusters

$ mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro,acl)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/dev/sdc1 on /media/jpgs type vfat (rw)

Edit: output of sudo dosfsck -v /dev/sdc1

fsck.fat 3.0.26 (2014-03-07)
fsck.fat 3.0.26 (2014-03-07)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "BSD 4.4"
Media byte 0xf0 (5.25" or 3.5" HD floppy)
512 bytes per logical sector
32768 bytes per cluster
32 reserved sectors
First FAT starts at byte 16384 (sector 32)
2 FATs, 32 bit entries
122065408 bytes per FAT (= 238409 sectors)
Root directory start at cluster 2 (arbitrary size)
Data area starts at byte 244147200 (sector 476850)
30516291 data clusters (999957823488 bytes)
32 sectors/track, 255 heads
0 hidden sectors
1953519498 sectors total
Checking for unused clusters.
Checking free cluster summary.
/dev/sdb1: 24068 files, 2059652/30516291 clusters
  • 1
    500GB for a FAT 32 partition? What's the cluster size? See:techcosupport.com/press/maximum-size-of-a-fat-32-partition
    – Elder Geek
    Feb 17, 2015 at 15:47
  • Is the drive mounted when you have this problem? Please add the output of 'mount' to your question as well as 'cat/etc/fstab`
    – Elder Geek
    Feb 17, 2015 at 15:59
  • If you 'umount /dev/sdc1' and then 'ls /media/jpgs` is the directory full of files?
    – Elder Geek
    Feb 17, 2015 at 16:21
  • 1
    I thought that FAT32 only supports volume/partition sizes of about 127GB!? And file sizes about 4GB. And I think I remember that some FAT derivative uses multiple file table entries for one actual file if the file name does not fit in one single 8.3 compatible entry. Might this cause it to give up at 20000 instead of 65000?
    – Byte Commander
    Feb 18, 2015 at 3:26
  • 1
    The limit was 137Gb and an issue with IDE. You need 48LBA to fix that (Windows XP SP1 is the first one supporting that) but also compatible hardware/
    – Rinzwind
    Feb 18, 2015 at 14:43

2 Answers 2


NOTE: Keep in mind that although the maximum number of files in a single folder under FAT32 is 65,534, this can be significantly reduced by the use of long filenames.

FAT32 was originally a DOS file system and as such the limits were derived from the use of 8.3 filenames (eight characters with a 3 character extension.

Also the media byte is incorrect. You should never see this. It suggests insane file operations, which in turn implies deranged software or flaky hardware. You have:

System ID "BSD 4.4"
Media byte 0xf0 (5.25" or 3.5" HD floppy)

I would expect to see:

System ID "mkfs.fat" if created under Ubuntu
Media byte 0xf8 (hard disk)

If you know how to correct this with a HEX editor you could do that although it could be dangerous to the underlying data if more is wrong, It's likely better to image the drive (if you have critical data on it) so that data recovery is possible from the image and then reformat it under Ubuntu rather than OSX.

  • Bravo you found it ! Please put your note in bold at the begining of your answer : if you use Long filenames instead of 8.3 filenames, each file will take several entries in the directory table. Should I strip my question to remove unecessary command line outputs ?
    – slaur4
    Feb 18, 2015 at 10:28
  • Excellent! Will do. I'm not sure stripping that information is a good idea. It's a good example of providing enough information to arrive at an answer. Others may benefit by the example. We should clean up our unrelated comments though.
    – Elder Geek
    Feb 18, 2015 at 14:15
  • I'm updating one of my answers to include 8TB maximum FAT size! (And upvoted!)
    – Fabby
    Feb 19, 2015 at 6:42

You try formatting your USB drive first using this command

mkfs -t ext4 /dev/sdc

That may help.

Make sure that you type the right USB drive name, it must be /dev/sdc.

  • Is this a typo? Are we ignoring the need for a partition table? Furthermore, while an ext4 filesystem will work great under Ubuntu it won't be compatible with other OS's such as OSX or Windows. You may want to revise your answer to address these points. Thank you!
    – Elder Geek
    Feb 17, 2015 at 22:30
  • @ElderGeek I accept that ext4 works fine in Ubuntu and user may prefer some other file format. But didn't understand your question "Are we ignoring the need for a partition table? ". Can you make it clear.
    – Red Aura
    Feb 19, 2015 at 3:39
  • You are suggesting creating a filesystem on the entire device. I thought perhaps it was a typo and you just missed the 1 '/dev/sdc1' which would indicate the first partition in the table on the device. Correct me if I'm wrong but a partition table is still required.
    – Elder Geek
    Feb 19, 2015 at 13:53
  • Yes, if user wants to just format single partition then he can go ahead with /dev/sdc1 But if its entire device than its /dev/sdc
    – Red Aura
    Feb 19, 2015 at 16:28
  • Just because you can doesn't make it a good idea. See unix.stackexchange.com/questions/14010/…
    – Elder Geek
    Feb 19, 2015 at 16:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .