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 ?
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.
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).