Skip to main content.
Navigation:
DENX
>
DULG
>
FilesystemTMPFS
Translations:
Edit
|
Attach
|
Raw
|
Ref-By
|
Printable
|
More
DULG
Sections of this site:
DENX Home
|
DULG
|
ELDK-5
|
Know
|
Training
|
U-Boot
|
U-Bootdoc
Topics
DULG Home
BoardSelect
Manual
FAQ
Application Notes
Changes
Index
List of pages in DULG
Search
%SECTION0{name=FilesystemTMPFS}% The TMPFS Virtual Memory Filesystem The =tmpfs= filesystem, formerly known as =shmfs=, is a filesystem keeping all files in virtual memory. Everything in tmpfs is temporary in the sense that no files will be created on any device. If you unmount a tmpfs instance, everything stored therein is lost. 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 ...'= 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<nop>*_), 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. %SECTION1{name=MountParameters}% Mount Parameters tmpfs has a couple of mount options: * =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 PAGECACHE_SIZE. * =nr_inodes=: The maximum number of inodes for this instance. The default is half of the number of your physical RAM pages. These parameters accept a suffix k, m or g for kilo, mega and giga and can be changed on remount. 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 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. So the following mount command will give you a tmpfs instance on _/mytmpfs_ which can allocate 12MB of RAM/SWAP and it is only accessible by root. <verbatim> mount -t tmpfs -o size=12M,mode=700 tmpfs /mytmpfs </verbatim> %SECTION1{name=KernelSupport}% Kernel Support for tmpfs In order to use a =tmpfs= filesystem, the =CONFIG_TMPFS= option has to be enabled for your kernel configuration. It can be found in the =Filesystems= configuration group. You can simply check if a running kernel supports =tmpfs= by searching the contents of _/proc/fileysystems_: <verbatim> bash# grep tmpfs /proc/filesystems nodev tmpfs bash# </verbatim> %SECTION1{name=EmbeddedUsage}% Usage of tmpfs in Embedded Systems In embedded systems =tmpfs= is very well suited to provide read and write space (e.g. _/tmp_ and _/var_) for a read-only root file system such as CramFs %IF{ "%HAVE_FLASH_FILESYSTEMS%" eq "true" }% described in section %REF{type=Section,topic=FlashFilesystemsCRAMFS,name=FlashFilesystemCRAMFS}%%ENDIF%. One way to achieve this is to use symbolic links. The following code could be part of the startup file _/etc/rc.sh_ of the read-only ramdisk: <verbatim> #!/bin/sh ... # Won't work on read-only root: mkdir /tmpfs mount -t tmpfs tmpfs /tmpfs mkdir /tmpfs/tmp /tmpfs/var # Won't work on read-only root: ln -sf /tmpfs/tmp /tmpfs/var / ... </verbatim> The commented out sections will of course fail on a read-only root filesystem, so you have to create the =/tmpfs= mount-point and the symbolic links in your root filesystem beforehand in order to successfully use this setup.
9.1.4. Compressed ROM Filesystem
1. Abstract
9.3. Adding Swap Space
Prev
Home
Next