4

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 ?

3
  • do you have windows to test this before you format the USB drive? I'd want to know if this is OS dependent or not
    – Prasanna
    Dec 20, 2014 at 14:59
  • @Prasanna no windows
    – Pierre
    Dec 20, 2014 at 15:01
  • Every time I've seen it it was OS dependent, varying even with different flavors of Linux -- usually, I'll find antiX 13.2 can't write to the device, but Kubuntu 14.04 can. I'm pretty sure antiX uses different filesystem drivers from Kubuntu (antiX is heavily tailored for low-resource system), which may be part of the issue; as well, my two anitX computers are 32-bit only, while my Kubuntu is 64-bit.
    – Zeiss Ikon
    Dec 20, 2014 at 15:05

2 Answers 2

5

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

4
  • I don't have the rep to downvote, or I would. The device has inodes, so it's clearly an ext2/ext3/ext4 format.
    – Zeiss Ikon
    Dec 20, 2014 at 15:07
  • 1
    @ZeissIkon: The inode count is zero. There are no inodes on the device. superuser.com/questions/647343/…
    – bwDraco
    Dec 20, 2014 at 15:08
  • moved the files, reformated using askubuntu.com/questions/22381 . It works now.
    – Pierre
    Dec 20, 2014 at 15:19
  • And FAT32 has its limits, too. :) For me, it was fixed by formatting the drive from FAT32 to NTFS.
    – Smile4ever
    Dec 30, 2015 at 10:11
0

When I've gotten this, it turned out that, for reasons I've never fully understood, the USB device had put itself in read-only mode or been marked by the OS as read-only. The only way I've found to fix it has been to back up the information on the flash device and recreate its partition table, partitions, and filesystem. In Linux, you'd do that with fdisk or a partition editor like gparted or KDE Partition Manager (the last time I had to do it, fdisk and gparted wouldn't touch it due to a recursive partition table entry, and I had to run the process twice in KDE Partition Manager before it took).

You must log in to answer this question.

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