Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Available inodes in a tmpfs

422 views
Skip to first unread message

Mehran Emadi

unread,
Jan 20, 2000, 3:00:00 AM1/20/00
to

Hi,

How can I get the number of available (or total) inodes (tmpnodes) in a
tmpfs filesystem? The command "df -o i" doesn't work on a tmpfs. Is
it possible to increase the number of inodes in a tmpfs filesystem?
how?

Thanking you in advance,

mehran


Chris Thompson

unread,
Jan 20, 2000, 3:00:00 AM1/20/00
to
In article <388746EE...@ctsecurities.com>,

Mehran Emadi <mem...@ctsecurities.com> wrote:
>
>How can I get the number of available (or total) inodes (tmpnodes) in a
>tmpfs filesystem? The command "df -o i" doesn't work on a tmpfs.

Use "df -t" (or "df -g", etc., etc.). It's onlu slightly tedious that none
of these will show you the number of inodes in use: you need to do the
subtraction in your head.

>Is it possible to increase the number of inodes in a tmpfs filesystem?
>how?

Only by magic in /etc/system. I think the right location to modify is
"tmpfs_maxkmem" and that it is about 240 * the inode limit. The default
value increases with the physical memory size.

Note that if you have more than one tmpfs mount point, their "inodes"
come out of the same kernel memory pool, and "df -t" on any of them
will show the inode usage of them all together, although the block
usage is maintained seperately for each.

Chris Thompson
Email: cet1 [at] cam.ac.uk

Chris Thompson

unread,
Jan 29, 2000, 3:00:00 AM1/29/00
to
In article <867nn0$mqr$1...@pegasus.csx.cam.ac.uk>, I wrote:
>In article <388746EE...@ctsecurities.com>,
>Mehran Emadi <mem...@ctsecurities.com> wrote:
[...]

>>Is it possible to increase the number of inodes in a tmpfs filesystem?
>>how?
>
>Only by magic in /etc/system. I think the right location to modify is
>"tmpfs_maxkmem" and that it is about 240 * the inode limit. The default
>value increases with the physical memory size.

I just got round to testing this (Solaris 2.6, SPARCstation 5). Adding

set tmpfs:tmpfs_maxkmem = 3600000

to /etc/system does indeed cause "df -t /tmp" to show a limit of precisely
15000 inodes.

Chris Thompson

unread,
Feb 2, 2000, 3:00:00 AM2/2/00
to
I have noticed an oddity about the inodes in use reported by "df -t"
(i.e., statvfs(2)) for a tmpfs filing system. Directories seem to count
as about 1.3 inodes (i.e. creating N new directories decreases the free
inode count by about 1.3*N). Regular files seem to be counted 1:1.

I take it that what's actually being reported is the amount of kernel
memory in use, divided by a "normal" inode size. Can anyone familiar
with the actual code comment? [Tests were done using Solaris 2.6.]

Chris Thompson

unread,
Feb 3, 2000, 3:00:00 AM2/3/00
to

Thanks to Tony Walton who pointed me at /usr/include/sys/fs/{tmp,tmpnode}.h.
I'll do a quick brain dump in case anyone is interested.

The kernel data structures that are accounted against tmpfs_maxkmem are
mostly of three types:

struct tmpnode (a tmpfs "inode") size 208 bytes [*]
struct tdirent (a tmpfs directory entry) size 32 bytes [*]
\0-terminated names in directories size N+1 bytes

[*] in Solaris 2.6. YMMV, especially in 64-bit mode.

The running total is kept in tmpfs_kmemspace, and tracking this enables
one to see what is really going on. statvfs(2) converts this into "inodes"
by dividing by sizeof(tmpnode)+sizeof(tdirent) = 240 on the basis that
the normal file is referenced by exactly one directory entry (and has
a short name).

Creating hard links (just 1 tdirent + 1 name), or unlinking an open
file (removes the tdirent and name, but leaves the tmpnode) serve to
demonstrate the individual contributions. A new directory costs
1 tmpnode + 3 tdirents + ".\0" + "..\0" + "name-in-its-parent\0"
= 310+n bytes; hence the factor of approximately 1.3 that I observed.

0 new messages