# tmpfsとは？インメモリファイルシステム

> tmpfsは、ディスクではなくメモリに存在するファイルシステムです。tmpfsの仕組み、トレードオフ、そしてそれがCIのbuildをどう高速化できるかを学びましょう。

Source: https://latchkey.dev/ja/learn/ci-explained/what-is-a-tmpfs  
Updated: 2026-06-26

tmpfsは、ファイルをディスクではなくメモリ (RAM) に格納するファイルシステムで、非常に高速ですが揮発性です。

tmpfsは、ファイルを永続ストレージではなくRAMに置きます。読み書きは極めて高速ですが、システムが再起動したりmountが解除されたりするとすべて消えます。Unixでは、/tmp や /dev/shm のような場所がtmpfsで裏付けられていることがよくあります。CIでは、tmpfsがファイルシステムを酷使するbuildステップを劇的に高速化できます。

## tmpfsとは何か

tmpfsはインメモリファイルシステムです。そこに書き込まれたファイルはRAMに存在し (必要ならswapにあふれます)、アクセスは高速ですが、内容はrebootやunmountを生き延びません。

## 速度対永続性

ディスクが関与しないため、tmpfsはディスクレイテンシを完全に回避し、一時的で使い捨てのデータに最適です。トレードオフは揮発性で、保持する必要があるものはmountが消える前に別の場所にコピーしなければなりません。

## どこで見かけるか

- /tmp はLinuxでしばしばtmpfsで裏付けられています。
- /dev/shm は共有メモリ用のtmpfsです。
- コンテナはスクラッチ領域のためにtmpfsをマウントできます。

## メモリが上限

tmpfsはRAMを消費するため、大量のデータをそこに書き込むとメモリを使い果たし、out-of-memory killを引き起こすことがあります。そのサイズは、広々としたディスクとは違い、利用可能なメモリに制限されます。

## CIにおけるtmpfs

コンパイラやテストスイートのように重い一時I/Oを行うbuildやテストは、スクラッチディレクトリがtmpfs上にあると著しく高速に実行できます。難点はメモリで、tmpfsにギガバイト単位の一時データを書き込むbuildはrunnerのRAMを使い果たすことがあります。

## マネージドrunnerでの高速スクラッチ

Latchkeyのrunnerでは、buildの一時ディレクトリをtmpfsに向けると、runnerに十分なメモリがあればI/Oバウンドのステップを高速化できます。runnerを適切にサイジングすれば、out-of-memory killなしに速度を享受する余裕が得られます。

## Applying this to your pipeline

- Measure before changing. Most CI optimisation targets the wrong step because the slow one is assumed rather than timed.
- Cache what is expensive to produce and cheap to validate, and key the cache to the exact tool version.
- Fail fast: run the cheapest checks that can reject a change first, so an expensive job never starts on code that cannot pass.
- Prefer determinism over speed when they conflict. A fast pipeline nobody trusts gets re-run, which is slower than a slow one that is believed.

## FAQ

### What is What is a tmpfs? an In-Memory filesystem?

A tmpfs puts files in RAM rather than on persistent storage. Reads and writes are extremely fast, but everything vanishes when the system reboots or the mount is removed. On Unix, locations like /tmp or /dev/shm are often backed by tmpfs. In CI, a tmpfs can dramatically speed up build steps that thrash the filesystem.

### What a tmpfs is?

A tmpfs is an in-memory filesystem. Files written to it live in RAM (spilling to swap if needed), so access is fast, but the contents do not survive a reboot or unmount.

### Speed versus persistence?

Because there is no disk involved, a tmpfs avoids disk latency entirely, which is great for temporary, throwaway data. The trade-off is volatility: anything you need to keep must be copied elsewhere before the mount goes away.

### Memory is the limit?

A tmpfs consumes RAM, so writing a large amount of data to it can exhaust memory and trigger an out-of-memory kill. Its size is bounded by available memory, unlike a roomy disk.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
