ramfs 和 tmpfs 以及 ramdisk相关调研

最近需要使用到 ramfs 和 tmpfs 做内存文件系统,下面对这两个文件系统相关的信息,做一下总结:

参考链接:

https://www.thegeekstuff.com/2008/11/overview-of-ramfs-and-tmpfs-on-linux/ 

https://www.cnblogs.com/dosrun/p/4057112.html 

https://www.cnblogs.com/zlhff/p/5436092.html 

http://blog.chinaunix.net/uid-375398-id-4096820.html (ramdisk 于 ramfs ) 

ramfs, tmpfs, rootfs, initramfs的区别 

ramfs 和 tmpfs 对比:

ExperimentationTmpfsRamfs
Fill maximum space and continue writing Will display error Will continue writing
Fixed Size Yes No
Uses Swap Yes No
Volatile Storage Yes Yes

结论:

  • ramfs 因为追求高效和简单,去掉了容量计数;所以当使用的值超过分配的值的时候,将会继续使用;
  • tmpfs 使用了虚拟内存,其会使用swap和内存, 其会将一些不必要的文件内容写入到swap当中;并且会使用计数,来统计当前使用的容量,并进行容量限制;使用df -h 操作可以显示其具体使用的容量和可用容量信息;现在系统中,大多使用 tmpfs 作为内存文件系统;
  • ramdisk 是快设备,ramfs 是文件系统;ramdisk的内存空间大小是固定的,一经设定就不能改变大小了;
  • tmpfs 带来了一定的管理机制,但是也是意味着 相对于 ramfs,tmpfs 性能较差一点;不过使用方式上基本相同;

Linux 社区文档:

https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt 

https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt 

https://en.wikipedia.org/wiki/Tmpfs (/dev/shm)

ramfs 与 tmpfs 的使用和测试(没想到之前也写过类似的博客,竟然忘记了):

https://www.cnblogs.com/xuyaowen/p/ramfs-tmpfs-test.html 

posted @ 2019-11-18 10:06  Michael-Xu  阅读(618)  评论(0编辑  收藏  举报