I have a new USB Flash drive, 16GB. I am trying to copy a folder from my local drive to this flash drive. The folder I am trying to copy contains about 225000 4KB files. I have tried to copy using the folder GUI and with terminal. Both times it copies exactly 21844 files and then I get the error:

"cannot create regular file `filename': No space left on device"

I also have a compressed copy of the files and I have tried extracting this directly into the USB drive, again stopping after 21844 files.

I have looked for possible solutions and tried emptying the trash but that does not solve the issue. I have also formatted the drive to FAT32 and tried again, but that doesn't work. Does anyone have any suggestions?

I am running Ubuntu 12.04 and the USB drive is an ADATA S107.

  • I also have this problem, will try formatting as ext4. – SomeNickName Sep 10 '16 at 11:28

There are two ways to run out of space on a filesystem: 1)Actually running out of space for the data 2)Running out of some filesytem resource like inodes or fat table entries. Lots of little files may cause running out of inodes -- the filesystems are built with a default number of inodes and that may not meet your needs. The FAT32 filesystem is limited to 64k files per directory (max, long names will reduce that), so that will not work for you unless you combine the small files with an archiver like tar before you copy them. The archiver approach should work for any case, and will certainly reduce the stress on the flash memory -- think of the number of writes the directory block may get while being built, and hope the drivers are smart about buffering. Maybe you should put the same type of filesystem on the 16G stick as you have on your hard drive? (I'm guessing ntfs, since its directory limit is over 4 million). You can run mke2fs with switches to change the default inode size/number. Run the manual pages

man mke2fs

for a full description. The other possibility is you are really running out of space for the data -- you know your files are only 4K, but ask yourself, how much space does the filesystem allocate for them? Check the free space left when the stick says no more space -- free space indicates lack of inodes. No free space, well, there's always the archiver to fix that too.

  • I have a .tar.gz file of the whole folder and copied that to the flash drive easily, but when extracting I get: tar: info/B28965-gb7-R.info: Cannot open: No space left on device info/L5689-lmc13-R.info – Herb Jul 18 '13 at 2:34
  • OK, now what does the df command report as free space? Lots of free space indicates you ran out of inodes. – ubfan1 Jul 18 '13 at 16:23

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.