knowledge/technology/linux/filesystems/tmpFS.md
2024-12-17 14:24:37 +01:00

3.6 KiB

obj wiki arch-wiki
filesystem https://en.wikipedia.org/wiki/Tmpfs https://wiki.archlinux.org/title/Tmpfs

tmpFS

tmpfs is a temporary filesystem that resides in memory and/or swap partition(s). Mounting directories as tmpfs can be an effective way of speeding up accesses to their files, or to ensure that their contents are automatically cleared upon reboot.

Usage

Create a tmpfs:
mount -t tmpfs -o [OPTIONS] tmpfs [MOUNT_POINT]

Resize a tmpfs:
mount -t tmpfs -o remount,size=<NEW_SIZE> tmpfs [MOUNT_POINT]

Options

Option Description
size=bytes Specify an upper limit on the size of the filesystem. Size is given in bytes, rounded up to entire pages. A k, m, or g suffix can be used for Ki, Mi, or Gi. Use % to specify a percentage of physical RAM. Default: 50%. Set to 0 to remove the limit.
nr_blocks=blocks Similar to size, but in blocks of PAGE_CACHE_SIZE. Accepts k, m, or g suffixes, but not %.
nr_inodes=inodes Sets the maximum number of inodes. Default is half the number of physical RAM pages or the number of lowmem RAM pages (whichever is smaller). Use k, m, or g suffixes, but % is not supported. Set to 0 to remove the limit.
noswap Disables swap. Remounts must respect the original settings. By default, swap is enabled.
mode=mode Sets the initial permissions of the root directory.
gid=gid Sets the initial group ID of the root directory.
uid=uid Sets the initial user ID of the root directory.
huge=huge_option Sets the huge table memory allocation policy for all files (if CONFIG_TRANSPARENT_HUGEPAGE is enabled). Options: never (default), always, within_size, advise, deny, or force.
mpol=mpol_option Sets NUMA memory allocation policy (if CONFIG_NUMA is enabled). Options: default, prefer:node, bind:nodelist, interleave, interleave:nodelist, or local. Example: mpol=bind:0-3,5,7,9-15.