Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I ran into a problem with my application running on OpenWRT, where I write files to /tmp which is in RAM. Even though df reports that about 0% is used:

root@OpenWrt:/tmp# df
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                     576       212       364  37% /
/dev/root                 2560      2560         0 100% /rom
tmpfs                    14680        48     14632   0% /tmp
tmpfs                      512         0       512   0% /dev
/dev/mtdblock3             576       212       364  37% /overlay
overlayfs:/overlay         576       212       364  37% /

after I have written 3,640 0-byte files, I get the error "No space left on device".

Can anyone explain why this is happening? In the real world case, I wouldn't normally have a condition like this, as I would be deleting these files, but I need to take care of this condition anyway.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

0-byte files still use space; each file uses at least one inode. From the tmpfs documentation, the default number of inodes for tmpfs (nr_inodes) is half the number of physical RAM pages (which are typically 4K). I suspect you have around 8MB of memory on your device?

It might be possible to increase the number of available inodes if that's what you want by issuing as root:

mount -o remount -o nr_inodes=7200 /tmp

Typically the number of used inodes in a filesystem is insignificant enough that it's not accounted by “df”.

share|improve this answer
    
My device has 32MB of RAM. I'll give your suggestion a try! Thank you. –  Dave May 19 '13 at 15:07
    
Thanks for your help. I'll read up on this more, but it's definitely tied to the number of available inodes. I bumped up the value and was able to write more files. I guess the key is to ensure that I implement a ring buffer of sorts, and make sure that I just clear out those files as often as I can! –  Dave May 19 '13 at 15:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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