tmpfs(5)

โœจ tmpfs(5) โ€” the virtual memory filesystem โœจ

okay bestie so this is the page for tmpfs, the virtual memory filesystem. Like, the filesystem that literally lives in your RAM and goes zoom ๐Ÿ’จ


๐Ÿ’– NAME ๐Ÿ’–

tmpfs โ€” a virtual memory filesystem


๐ŸŒธ DESCRIPTION ๐ŸŒธ

so tmpfs is this facility that lets you create filesystems whose contents justโ€ฆ reside in virtual memory. and because the files on those filesystems typically chill in RAM, file access is extremely fast. like, speeds that make your SSD look like it's walking ๐Ÿšถโ™€๏ธ๐Ÿ’€

the filesystem gets created automatically when you mount a filesystem with the type tmpfs, with a command like this:

$ sudo mount -t tmpfs -o size=10M tmpfs /mnt/mytmpfs

a tmpfs filesystem has these properties, and they're iconic fr:

  • the filesystem can employ swap space when physical memory pressure demands it.
  • the filesystem consumes only as much physical memory and swap space as is required to store the current contents of the filesystem. it's not greedy, it's mindful โœจ
  • during a remount operation (mount -o remount), the filesystem size can be changed without losing the existing contents of the filesystem. glow-up in place ๐Ÿ’…
๐Ÿšจ IMPORTANT: if a tmpfs filesystem is unmounted, its contents are discarded (lost). like, gone gone. no trash can. no undo. no "wait let me check my recents". it's giving vanishing act ๐Ÿซฅ

๐ŸŽ€ Mount options ๐ŸŽ€

the tmpfs filesystem supports the following mount options (yes, all of them, we're going through every single one, no skimming babes):

  • size=bytes โ€” specify an upper limit on the size of the filesystem. the size is given in bytes, and rounded up to entire pages. the limit is removed if the size is 0.

the size may have a k, m, or g suffix for Ki, Mi, Gi (binary kilo (kibi), binary mega (mebi), and binary giga (gibi)) ๐Ÿงฎ

the size may also have a % suffix to limit this instance to a percentage of physical RAM.

the default, when neither size nor nr_blocks is specified, is size=50%. half of your RAM, bestie, that's the vibe โœจ

  • nr_blocks=blocks โ€” the same as size, but in blocks of PAGE_CACHE_SIZE.

blocks may be specified with k, m, or g suffixes like size, but not a % suffix. read that again. no percent. ๐Ÿšซ

  • nr_inodes=inodes โ€” the maximum number of inodes for this instance. the default is half of the number of your physical RAM pages, or (on a machine with highmem) the number of lowmem RAM pages, whichever is smaller. the limit is removed if the number is 0.

inodes may be specified with k, m, or g suffixes like size, but not a % suffix. same rule, same energy ๐Ÿ’€

  • noswap (since Linux 6.4) โ€” disables swap. remounts must respect the original settings. by default swap is enabled.
  • mode=mode โ€” set initial permissions of the root directory. your house, your rules ๐Ÿ”‘
  • gid=gid (since Linux 2.5.7) โ€” set the initial group ID of the root directory.
  • uid=uid (since Linux 2.5.7) โ€” set the initial user ID of the root directory.
  • huge=huge_option (since Linux 4.7.0) โ€” set the huge table memory allocation policy for all files in this instance (if CONFIG_TRANSPARENT_HUGEPAGE is enabled).

the huge_option value is one of the following, and we love a menu:

  • never โ€” do not allocate huge pages. this is the default.
  • always โ€” attempt to allocate huge pages every time a new page is needed.
  • within_size โ€” only allocate huge page if it will be fully within i_size. also respect fadvise(2) and madvise(2) hints
  • advise โ€” only allocate huge pages if requested with fadvise(2) or madvise(2).
  • deny โ€” for use in emergencies, to force the huge option off from all mounts.
  • force โ€” force the huge option on for all mounts; useful for testing.
  • mpol=mpol_option (since Linux 2.6.15) โ€” set the NUMA memory allocation policy for all files in this instance (if CONFIG_NUMA is enabled).

the mpol_option value is one of the following:

  • default โ€” use the process allocation policy (see set_mempolicy(2)).
  • prefer:node โ€” preferably allocate memory from the given node.
  • bind:nodelist โ€” allocate memory only from nodes in nodelist.
  • interleave โ€” allocate from each node in turn.
  • interleave:nodelist โ€” allocate from each node of in turn.
  • local โ€” preferably allocate memory from the local node.

in the above, nodelist is a comma-separated list of decimal numbers and ranges that specify NUMA nodes. a range is a pair of hyphen-separated decimal numbers, the smallest and largest node numbers in the range. for example, mpol=bind:0-3,5,7,9-15. look at that syntax go ๐Ÿ˜Œ


๐Ÿฆ‹ VERSIONS ๐Ÿฆ‹

the tmpfs facility was added in Linux 2.4, as a successor to the older ramfs facility, which did not provide limit checking or allow for the use of swap space. so basically tmpfs came in and said "hold my ๐Ÿต, i'll add limits AND swap" and honestly? ate.


๐Ÿ‘‘ NOTES ๐Ÿ‘‘

in order for user-space tools and applications to create tmpfs filesystems, the kernel must be configured with the CONFIG_TMPFS option. no config, no filesystem, no cap ๐Ÿงข

the tmpfs filesystem supports extended attributes (see xattr(7)), but user extended attributes are not permitted. so close, yet so far ๐Ÿ™ˆ

an internal shared memory filesystem is used for System V shared memory (shmget(2)) and shared anonymous mappings (mmap(2) with the MAP_SHARED and MAP_ANONYMOUS flags). this filesystem is available regardless of whether the kernel was configured with the CONFIG_TMPFS option. it doesn't need permission, it's just there ๐ŸŒˆ

a tmpfs filesystem mounted at /dev/shm is used for the implementation of POSIX shared memory (shm_overview(7)) and POSIX semaphores (sem_overview(7)). โœจ

the amount of memory consumed by all tmpfs filesystems is shown in the Shmem field of /proc/meminfo and in the shared field displayed by free(1). that's your receipts, bestie ๐Ÿงพ

the tmpfs facility was formerly called shmfs. a little name change, a little rebrand, we love growth ๐Ÿ’…


โญ SEE ALSO โญ

and the kernel source files:

  • Documentation/filesystems/tmpfs.rst
  • Documentation/admin-guide/mm/transhuge.rst

and that's the whole page babe ๐Ÿซถ this one comes to you from Linux man-pages 6.20, dated 2026-02-08. go mount something fast, just don't forget about the unmount thing ๐Ÿ˜ญ๐Ÿ’–

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms