29

I've been trying to move 32.6 GB of files to a folder on an external flashdrive to free up space on my laptop's SSD. After opening up the source folder in Terminal (and running ulimit -S -s unlimited to keep mv from throwing up), mv *from* /media/[username]/8849-14DB/Screenshots/ transferred the first 5.9 GB just fine.

But then, with 26.7 GB still to go:

mv: cannot create regular file '/media/[username]/8849-14DB/Screenshots/Screenshot from 2022-01-06 06-34-27.png': No space left on device
mv: cannot create regular file '/media/[username]/8849-14DB/Screenshots/Screenshot from 2022-01-06 06-34-30.png': No space left on device
mv: cannot create regular file '/media/[username]/8849-14DB/Screenshots/Screenshot from 2022-01-06 06-34-34.png': No space left on device
mv: cannot create regular file '/media/[username]/8849-14DB/Screenshots/Screenshot from 2022-01-06 06-34-39.png': No space left on device
mv: cannot create regular file '/media/[username]/8849-14DB/Screenshots/Screenshot from 2022-01-06 06-35-23.png': No space left on device

[repeated ad infinitum]

This despite the fact that the flashdrive in question is not, in fact, out of space, as shown by:

  • me being able to successfully save a test file to said flashdrive, and
  • both the drive's Properties window and its Disks entry showing that it still has 31.1 GB of free space remaining.

However, when I tried to use the GUI to move the aforementioned test file into the specific directory where I'd been trying to use mv to move the multiple gigabytes of files, I did get a "No space left on device" error, indicating that

  • whatever the issue is, it's specific to that folder, and
  • this isn't a command-line-specific issue.

I looked at this earlier question: Filesystem - No space left error, but there is space. However, the answers to that question were unhelpful to me, as they related to the limited number of inodes available on an ext-family filesystem, whereas, in my case, the destination filesystem is a FAT32-formatted flashdrive.

What issue am I running into that keeps the files from transferring, and how do I overcome it?

EDIT: The target directory has 16,383 files in it.

Vikki
  • 569

2 Answers2

75

Ext4 filesystems are not the only ones with limitations on the number of files. FAT32 filesystems have a limit on the number of files that can be stored in a single directory. If you are using short names (8 characters + . + 3 character file extension) then the limit is 65,534 files. However, if you use longer names, then every 13 bytes of the name is stored as a separate directory entry, which can greatly limit the number of files you can fit in a directory.

In your case, it looks like each file is actually taking up 4 directory entries, since you have 16,383 files, and 16,383 * 4 is 65,532, which brings you right up to the limit. At a closer look, each filename has 39 characters, which is 39 bytes: exactly 13 * 3. So you have 3 directory entries for each filename, and a fourth for the actual file contents.

You can get around this by either:

  1. formatting the drive as NTFS, which limits the number of files to about 4 billion (should be enough)
  2. putting the files in different sub-directories, since the limitation is on the number of directory entries, and you aren't running into the limit on the total number of files quite yet
Esther
  • 3,932
2

Ext4 file systems have a limited number of inodes. If your filesystem contains a large number of (small) files, it can be "full" despite having lots of disk space (in the sense of "free bytes") left, because it does not have free inodes left.

You can view the available inodes on your file system using

df -i <device/mountpoint>
Heinrich
  • 248