linuxspiflash-memoryjffs2

JFFS2 filesystem, storage usage inconsistent with real file size


I used a spi-nor chip and made one 16M partition as JFFS2 fs. I found a weird thing that I should have used 14M storage, but when I use df to check, it shows only 7M have been used:

/ # df
Filesystem            1K-blocks       Used  Available Use% Mounted on
...
/dev/mtd7                 16384       7488       8896  46% /data
...

After I copied another 2M file to this partition:

/tmp # ls -l 
-rwxr-xr-x    1 0        0       Fri Jul 24 18:32:46 2015          2478144 asd

It turns out that only 1M more storage have been used:

# df
Filesystem            1K-blocks       Used  Available Use% Mounted on
....
/dev/mtd1                 16384       8744       7640  53% /tmp
....

Is there any one also found this issue?

Thanks,


Solution

  • JFFS2 uses filesystem compression by default, so space used on the partition will not reflect the sum of the file sizes, because the files are compressed on-the-fly. This means that their individual file sizes will reflect their uncompressed sizes, but the overall volume usage will reflect their compressed sizes.

    From JFFS2 on Wikipedia:

    There is no practical way to tell how much usable free space is left on a device since this depends both on how well additional data can be compressed, and the writing sequence.