背景

tmpfs是一种基于内存的文件系统,具有速度快,使用简单,大小可调整等优点,在linux,android中获得了广泛的应用。

Linux使用方法

linux根分区的/dev,/run目录都是基于tmpfs的,如果要新建一个20M大小的tmpfs分区/test,可以用mount命令来快速实现。

1
mount -t tmpfs -o size=20m tmpfs /test

Android使用方法

android和Linux类似,mount命令虽然也可以创建,但更常用的做法是写在init.rc中.

1
2
on onit
	mount tmpfs none /test mode=0750 rw noexec nosuid nodev size=16M