1tmpfs(7FS) File Systems tmpfs(7FS)
2
3
4
6 tmpfs - memory based file system
7
9 #include <sys/mount.h>
10
11 mount (special, directory, MS_DATA, "tmpfs", NULL, 0);
12
13
15 tmpfs is a memory based file system which uses kernel resources relat‐
16 ing to the VM system and page cache as a file system. Once mounted, a
17 tmpfs file system provides standard file operations and semantics.
18 tmpfs is so named because files and directories are not preserved
19 across reboot or unmounts, all files residing on a tmpfs file system
20 that is unmounted will be lost.
21
22
23 tmpfs file systems can be mounted with the command:
24
25 mount -F tmpfs swap directory
26
27
28
29 Alternatively, to mount a tmpfs file system on /tmp at multi-user
30 startup time (maximizing possible performance improvements), add the
31 following line to /etc/vfstab:
32
33 swap −/tmp tmpfs − yes −
34
35
36
37 tmpfs is designed as a performance enhancement which is achieved by
38 caching the writes to files residing on a tmpfs file system. Perfor‐
39 mance improvements are most noticeable when a large number of short
40 lived files are written and accessed on a tmpfs file system. Large com‐
41 pilations with tmpfs mounted on /tmp are a good example of this.
42
43
44 Users of tmpfs should be aware of some constraints involved in mounting
45 a tmpfs file system. The resources used by tmpfs are the same as those
46 used when commands are executed (for example, swap space allocation).
47 This means that large sized tmpfs files can affect the amount of
48 space left over for programs to execute. Likewise, programs requiring
49 large amounts of memory use up the space available to tmpfs. Users run‐
50 ning into this constraint (for example, running out of space on tmpfs)
51 can allocate more swap space by using the swap(1M) command.
52
53
54 Another constraint is that the number of files available in a tmpfs
55 file system is calculated based on the physical memory of the machine
56 and not the size of the swap device/partition. If you have too many
57 files, tmpfs will print a warning message and you will be unable to
58 create new files. You cannot increase this limit by adding swap space.
59
60
61 Normal file system writes are scheduled to be written to a permanent
62 storage medium along with all control information associated with the
63 file (for example, modification time, file permissions). tmpfs control
64 information resides only in memory and never needs to be written to
65 permanent storage. File data remains in core until memory demands are
66 sufficient to cause pages associated with tmpfs to be reused at which
67 time they are copied out to swap.
68
69
70 An additional mount option can be specified to control the size of an
71 individual tmpfs file system.
72
74 df(1M), mount(1M), mount_tmpfs(1M), swap(1M), mmap(2), mount(2),
75 umount(2), vfstab(4)
76
77
78 System Administration Guide: Basic Administration
79
81 If tmpfs runs out of space, one of the following messages will display
82 in the console.
83
84 directory: File system full, swap space limit exceeded
85
86 This message appears because a page could not be allocated while
87 writing to a file. This can occur if tmpfs is attempting to write
88 more than it is allowed, or if currently executing programs are
89 using a lot of memory. To make more space available, remove unnec‐
90 essary files, exit from some programs, or allocate more swap space
91 using swap(1M).
92
93
94 directory: File system full, memory allocation failed
95
96 tmpfs ran out of physical memory while attempting to create a new
97 file or directory. Remove unnecessary files or directories or
98 install more physical memory.
99
100
102 Files and directories on a tmpfs file system are not preserved across
103 reboots or unmounts. Command scripts or programs which count on this
104 will not work as expected.
105
107 Compilers do not necessarily use /tmp to write intermediate files
108 therefore missing some significant performance benefits. This can be
109 remedied by setting the environment variable TMPDIR to /tmp. Compilers
110 use the value in this environment variable as the name of the directory
111 to store intermediate files.
112
113
114 swap to a tmpfs file is not supported.
115
116
117 df(1M) output is of limited accuracy since a tmpfs file system size is
118 not static and the space available to tmpfs is dependent on the swap
119 space demands of the entire system.
120
121
122
123SunOS 5.11 9 Oct 1990 tmpfs(7FS)