Linux tmpfs
Mark Veltzer
mark@veltzer.net
tmpfs intro
● tmpfs is a linux filesystem that stores all of your
files in RAM.
● Available in all recent linux versions.
...
tmpfs read(2) performance
● tmpfs offers some performance benefits for
read and write operations.
● Actually the read diff...
tmpfs read performance (cont)
● In a regular disk based file system the first read
will be slow while subsequent reads wil...
tmpfs write performance
● Write performance in tmpfs is always just a
memcpy to the kernel (if you have enough
space that ...
tmpfs disadvantages
● When your system crashes (power failure, OS
bug, hardware failure, whatever) you lose your
tmpfs dat...
When should you use tmpfs?
● You should use tmpfs for faster access to data
which is not critical.
● Much like a memory ca...
Using tmpfs
● First make a folder:
mkdir -p /mnt/tmp
● Then mount it:
mount -t tmpfs -o size=20m tmpfs /mnt/tmp
References
● http://www.thegeekstuff.com/2008/11/overview-of-ra
● http://www.linux-mag.com/id/7689/
● http://en.wikipedia....
References
● http://www.thegeekstuff.com/2008/11/overview-of-ra
● http://www.linux-mag.com/id/7689/
● http://en.wikipedia....
Upcoming SlideShare
Loading in …5
×

Linux tmpfs

1,900 views

Published on

Published in: Technology, News & Politics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,900
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Linux tmpfs

  1. 1. Linux tmpfs Mark Veltzer mark@veltzer.net
  2. 2. tmpfs intro ● tmpfs is a linux filesystem that stores all of your files in RAM. ● Available in all recent linux versions. ● Is used by some distributions by default for some folders (/tmp, /dev, /var/run, /run). ● You can mount your own folders as tmpfs, but need root or CAP_SYS_ADMIN to do so. ● Or you can just have a per-prepared tmpfs already defined in /etc/fstab.
  3. 3. tmpfs read(2) performance ● tmpfs offers some performance benefits for read and write operations. ● Actually the read difference between tmpfs and regular file system is not that great and is centered around the first time you read a certain area of a file. ● In tmpfs this, and all subsequent reads, will be a memcpy.
  4. 4. tmpfs read performance (cont) ● In a regular disk based file system the first read will be slow while subsequent reads will probably be from the OS page cache and so will resolve to memcpy. ● But in tmpfs you are guaranteed to get memcpy performance on both first and all subsequent reads. ● And you can control the maximum size of your tmpfs filesystem.
  5. 5. tmpfs write performance ● Write performance in tmpfs is always just a memcpy to the kernel (if you have enough space that is...) ● And you don't apply any pressure on any real disk file system that you have running in parallel and used by other programs. ● But the downside is that you data never reaches any persistent storage...
  6. 6. tmpfs disadvantages ● When your system crashes (power failure, OS bug, hardware failure, whatever) you lose your tmpfs data. ● This is unlike disk based file systems where you can guarantee your data will be there by calling fsync, fdatasync, sync, sync_file_range. ● tmpfs also lacks some advanced file system features (compression and others).
  7. 7. When should you use tmpfs? ● You should use tmpfs for faster access to data which is not critical. ● Much like a memory cache. ● Actually it's better to use some in process memory cache which will be more effective because accessing it does not require system calls. ● On the other hand you could mmap tmpfs files.
  8. 8. Using tmpfs ● First make a folder: mkdir -p /mnt/tmp ● Then mount it: mount -t tmpfs -o size=20m tmpfs /mnt/tmp
  9. 9. References ● http://www.thegeekstuff.com/2008/11/overview-of-ra ● http://www.linux-mag.com/id/7689/ ● http://en.wikipedia.org/wiki/Tmpfs ● http://www.ibm.com/developerworks/library/l-fs3/ind ● http://fixunix.com/linux/1717-tmpfs-swap.html
  10. 10. References ● http://www.thegeekstuff.com/2008/11/overview-of-ra ● http://www.linux-mag.com/id/7689/ ● http://en.wikipedia.org/wiki/Tmpfs ● http://www.ibm.com/developerworks/library/l-fs3/ind ● http://fixunix.com/linux/1717-tmpfs-swap.html

×