Linux returns “No space left on device” while copying data to a non-full USB flash drive

disk-spacefat16linuxusb-flash-drive

I'm trying to copy a file to a USB flash drive. The drive does not have a write-protect switch.

df gives the following:

$ df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/sde1       1.9G  622M  1.3G  33% /media/lindenb/803C-078D

df -i produces strange output to me (0 everywhere)

$ df -i .
Filesystem     Inodes IUsed IFree IUse% Mounted on
/dev/sde1           0     0     0     - /media/lindenb/803C-078D

Number of files on the drive:

$ find . |wc -l
170

But when I try to copy a file, I get this:

$ mv ~/file.txt ./
mv: cannot create regular file ‘./file.txt’: No space left on device

How can I fix this ?

Best Answer

The root directory on a FAT16 filesystem can store only a limited number of file entries

  • Your flash drive is 2 GB in size. This is the maximum filesystem size supported by FAT16. As such, it is likely that it was formatted with the FAT16 filesystem from the factory.

  • Due to a technical limitation in the FAT16 filesystem, only a limited number of file entries may be stored into the root directory. This limit is set when the filesystem is formatted (source). Directory entries (which may include long filename information), but not the contents of directories, count towards this limit.

  • To solve this problem, convert the filesystem to FAT32. On Linux, it may simply be best to move all files to a temporary location, unmount the drive, reformat to FAT32 with mkfs.vfat -F 32 /dev/sde1, and mount the drive and move the files back.

Error message generated by Windows 8 for a full root directory on a FAT16 volume

Related Question