JF Linux Kernel 2.6 Documentation: /usr/src/linux/Documentation/filesystems/tmpfs.txt

filesystems/tmpfs.txt

tmpfs ファイルシステムの説明 [プレインテキスト版]


==================================
これは、
linux-2.6.13-rc3/Documentation/filesystems/tmpfs.txt の和訳
です。
翻訳団体: JF プロジェクト < http://www.linux.or.jp/JF/ >
翻訳日 : 2005/7/25
翻訳者 : Hiroshi.Suzuki < setter at reset dot jp >
校正者 : Chie Nakatani さん <jeanne at mbox dot kyoto-inet dot or dot jp>
==================================

Tmpfs is a file system which keeps all files in virtual memory.

Tmpfs は、仮想メモリに全ファイルを保持するファイルシステムです。

Everything in tmpfs is temporary in the sense that no files will be
created on your hard drive. If you unmount a tmpfs instance,
everything stored therein is lost.

tmpfs 内の 全ては一時的なもので、ハードディスク上にはファイル類は作成されません。
tmpfs をマウント解除すれば、そこに保存されたすべてのものは失なわれます。

tmpfs puts everything into the kernel internal caches and grows and
shrinks to accommodate the files it contains and is able to swap
unneeded pages out to swap space. It has maximum size limits which can
be adjusted on the fly via 'mount -o remount ...'

tmpfs は、全てをカーネルの内部キャッシュに置き、含まれるファイルにあわせて
大きくも小さくもなり、不要なページはスワップアウトされます。
それには、最大サイズの制限がありますが、'mount -o remount ...' で、すぐに調整可能です。

If you compare it to ramfs (which was the template to create tmpfs)
you gain swapping and limit checking. Another similar thing is the RAM
disk (/dev/ram*), which simulates a fixed size hard disk in physical
RAM, where you have to create an ordinary filesystem on top. Ramdisks
cannot swap and you do not have the possibility to resize them. 

(tmpfs を作成するテンプレートであった) ramfs と比較すると、スワップと、制限チェックに利点があります。
もうひとつ別の良く似たものは、RAM ディスク( /dev/ram ) で、物理RAM 内にサイズを
固定したハードディスクを、シミュレートしますが、最上位に、通常のファイルシステムを
作成しなければなりません。RAM ディスクはスワップできませんし、サイズの変更もできません。

Since tmpfs lives completely in the page cache and on swap, all tmpfs
pages currently in memory will show up as cached. It will not show up
as shared or something like that. Further on you can check the actual
RAM+swap use of a tmpfs instance with df(1) and du(1).

tmpfs は、完璧な形でページキャッシュとスワップに上にあるので、
現メモリ内の全ての tmpfs ページは、キャッシュされたものとして見えるでしょう。
それは、共有されたもの(または類似のもの)としては見えません。
さらに、tmpfs により使用されている RAM+swap は、df(1)、du(1) で、調べることができます。

tmpfs has the following uses:

tmpfs は、以下の用途を持っています:

1) There is always a kernel internal mount which you will not see at
   all. This is used for shared anonymous mappings and SYSV shared
   memory. 

1) 全く見ることのできないカーネル内部マウントが常に存在します。
   これは、匿名の共有マッピングや、SYSV 共有メモリに使用します。

   This mount does not depend on CONFIG_TMPFS. If CONFIG_TMPFS is not
   set, the user visible part of tmpfs is not build. But the internal
   mechanisms are always present.

   このマウントはCONFIG_TMPFSに依存しません。
   CONFIG_TMPFS がセットされない場合、tmpfs  のユーザ可視部が組み込まれません。
   しかし、内部メカニズムは、常に存在します。

2) glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for
   POSIX shared memory (shm_open, shm_unlink). Adding the following
   line to /etc/fstab should take care of this:

2) glibc 2.2 以降の場合、tmpfs は、POSIX 共有メモリ(shm_open,shm_unlink) のために、
    /dev/shm にマウントされなければいけません。
    /etc/fstab に、以下の行を追加するときは注意してください:

	tmpfs	/dev/shm	tmpfs	defaults	0 0

   Remember to create the directory that you intend to mount tmpfs on
   if necessary (/dev/shm is automagically created if you use devfs).

   tmpfs をマウントする予定がある場合、そのためのディレクトリを作成することを忘れないでください
   ( /dev/shm は、devfs を使うなら自動的に作成されます)。

   This mount is _not_ needed for SYSV shared memory. The internal
   mount is used for that. (In the 2.3 kernel versions it was
   necessary to mount the predecessor of tmpfs (shm fs) to use SYSV
   shared memory)

   このマウントは、SYSV 共有メモリには *必要ありません*。
   内部マウントが使用されます( バージョン2.3系カーネルでは、SYSV 共有メモリ を使うために、
   tmpfs (shm fs) の前身として、マウントをする必要がありました )。

3) Some people (including me) find it very convenient to mount it
   e.g. on /tmp and /var/tmp and have a big swap partition. And now
   loop mounts of tmpfs files do work, so mkinitrd shipped by most
   distributions should succeed with a tmpfs /tmp.

3) /tmp や /var/tmp、そして大きなスワップパーティションを持っている場合、
   それをマウントするのはとても便利だと考える人たちもいます(私もそうですが)。
   また、現在、tmpfs ファイルの 再帰的マウントが使えます。ですから、多くのディストリビューション
   に含まれる mkinitrd は、tmpfs /tmp でも動作するはずです。

4) And probably a lot more I do not know about :-)

4) たぶん、私のわからないことがもっとたくさんあるはずです :-)

tmpfs has three mount options for sizing:

tmpfs にはサイズを決定するために3つのマウントオプションがあります。

size:      The limit of allocated bytes for this tmpfs instance. The 
           default is half of your physical RAM without swap. If you
           oversize your tmpfs instances the machine will deadlock
           since the OOM handler will not be able to free that memory.
nr_blocks: The same as size, but in blocks of PAGE_CACHE_SIZE.
nr_inodes: The maximum number of inodes for this instance. The default
           is half of the number of your physical RAM pages, or (on a
           a machine with highmem) the number of lowmem RAM pages,
           whichever is the lower.

size:	     この tmpfs に対して割当てるバイト数の上限。
          デフォルトは、スワップを除く物理メモリの半分。tmpfs インスタンスを限界を超えた
          大きさにすると、OOM ハンドラがメモリを開放できずマシンがデッドロックするかもしれません。
nr_brocks: size と同じですが、PAGE_CACHE_SIZE のブロック数を指定します。
nr_inodes: このインスタンスの inode 最大数。デフォルトは、物理 RAM ページ数の半分、または、
          (highmem があるマシンで) lowmem RAM ページ数 のどちらか小さい方。

These parameters accept a suffix k, m or g for kilo, mega and giga and
can be changed on remount.  The size parameter also accepts a suffix %
to limit this tmpfs instance to that percentage of your physical RAM:
the default, when neither size nor nr_blocks is specified, is size=50%

これらパラメータは、k、m、g(それぞれ、キロ、メガ、ギガ) をサフィックスでき、
再マウント時に変更もできます。size パラメータは、物理RAMのに対する割合を 
tmpfs インスタンスの上限サイズにするために、% も使えます:size、nr_brocks の
どちらも指定しない場合のデフォルトは、size=50% です。 

If nr_blocks=0 (or size=0), blocks will not be limited in that instance;
if nr_inodes=0, inodes will not be limited.  It is generally unwise to
mount with such options, since it allows any user with write access to
use up all the memory on the machine; but enhances the scalability of
that instance in a system with many cpus making intensive use of it.

nr_blocks=0 ( または、size=0 ) の場合、そのインスタンスでは、block 数は無制限になります;
nr_inode=0 の場合、inode 数が無制限です。一般的にこれらオプションを使ってマウントすることは、
愚かなことです。書込み権を持つユーザが、マシン上のメモリを使い果たしてしまうからです。
しかし、それを集中的に使用する、たくさんの CPU を持つシステムで、そのインスタンスの
スケーラビリティを増します。

To specify the initial root directory you can use the following mount
options:

初期ルートディレクトリを指定するため、次のマウントオプションが使えます:

mode:	The permissions as an octal number
uid:	The user id 
gid:	The group id

mode:      8進数による許可属性のモード
uid: ユーザ ID
gid: グループ ID

These options do not have any effect on remount. You can change these
parameters with chmod(1), chown(1) and chgrp(1) on a mounted filesystem.

これらオプションは、再マウント時、何も効力を持ちません。
これらパラメータは、マウントされたファイルシステム上で、chmod(1), chown(1), chgrp(1) 
によって変更できます。


So 'mount -t tmpfs -o size=10G,nr_inodes=10k,mode=700 tmpfs /mytmpfs'
will give you tmpfs instance on /mytmpfs which can allocate 10GB
RAM/SWAP in 10240 inodes and it is only accessible by root.

よって、 'mount -t tmpfs -o size=10G,nr_inodes=10k,mode=700 tmpfs /mytmpfs'
では、 /mytmpfs 上の tmpfs インスタンスで、10240以下の inode で RAM/SWAP に 
10GB 割当てでき、また、root だけがアクセスできます。

Author:
   Christoph Rohland <cr at sap dot com>, 1.12.01
Updated:
   Hugh Dickins <hugh at veritas dot com>, 13 March 2005

Linux カーネル 2.6 付属文書一覧へ戻る