Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Curious about tmpfs filesystem

Posted on 2010-11-21
10
Medium Priority
?
1,459 Views
Last Modified: 2012-05-10
Hello,

Please look at the below details of a RHEL 5.3 server. I wish to know about this 'tmpfs' filesystem. Why do a Linux server have this filesystem and it mounted on /dev/shm?  When I checked in /dev/shm, nothing is there?  Please explain in detail. Thanks.

[root@pmclsb01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       51G  7.8G   40G  17% /
/dev/xvda1             99M   19M   75M  21% /boot
tmpfs                 3.1G     0  3.1G   0% /dev/shm                   <------ ?
[root@pmclsb01 ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          6144       4561       1582          0        179       4174
-/+ buffers/cache:        207       5936
Swap:         8159          0       8159
[root@pmclsb01 ~]# cd /dev/shm
[root@pmclsb01 shm]# ls
[root@pmclsb01 shm]# du -sh .
0       .
[root@pmclsb01 shm]#
[root@pmclsb01 shm]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.3 (Tikanga)
[root@pmclsb01 shm]#
0
Comment
Question by:ashsysad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 35

Accepted Solution

by:
torimar earned 2000 total points
ID: 34185520
Tmpfs is a filesystem for temporary storage which does not reside on the physical disk, but in the computer's memory (RAM).
In the Linux device system it is often bound to /dev/shm simply because its name once used to be SHMFS (=Shared Memory File System).

More here: http://en.wikipedia.org/wiki/Tmpfs
0
 

Author Comment

by:ashsysad
ID: 34185694
Thanks Torimar. I did a small testing on 'tmpfs' filesystem and looks like even a normal user can create files in /tmp or /dev/shm filesystem. If thats being the case, can't a hacker or a normal user (who has an account in the server) simply do continous write on thise filesystem and crash the server by filling the entire RAM space ?
0
 

Author Comment

by:ashsysad
ID: 34185760
I checked the size of tmpfs in few servers and noticed the value various in each servers.

[adevaraju@orallm06-tx ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      810G  545G  224G  71% /
/dev/sda1              99M   16M   79M  17% /boot
tmpfs                  17G     0   17G   0% /dev/shm

[adevaraju@sysllm01 shm]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      130G   51G   73G  42% /
/dev/sda1              99M   42M   53M  45% /boot
tmpfs                 4.0G  0     4.0G  0% /dev/shm


I created files more than 4 GB in the second server and made it full. But still the server runs fine.

[adevaraju@sysllm01 tmp]$ mv testfile /dev/shm/
mv: writing `/dev/shm/testfile': No space left on device
[adevaraju@sysllm01 tmp]$ free -m
             total       used       free     shared    buffers     cached
Mem:          8116       7832        284          0         93       6905
-/+ buffers/cache:        832       7283
Swap:         1983          0       1983
[adevaraju@sysllm01 tmp]$
[adevaraju@sysllm01 shm]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      130G   51G   73G  42% /
/dev/sda1              99M   42M   53M  45% /boot
tmpfs                 4.0G  4.0G     0 100% /dev/shm                   <-- Its full but server is running.


My simple question is, Is it advisable to save files in /tmp or /dev/shm filesystem?  In my organization, many users are habitual to store the file under /tmp.
0
How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

 
LVL 35

Expert Comment

by:torimar
ID: 34185782
No.
The size of tmpfs may dynamically grow or shrink according to requirements, but for normal users it cannot grow beyond the size specified in fstab (which in your case is 3.1 GB). Only root is able to increase that limit via a mount order.

0
 
LVL 35

Expert Comment

by:torimar
ID: 34185798
The above comment answers your first question.

As to the next question:
The size of tmpfs may vary depending on the amount of RAM on a server. Once full, swap space is used to accommodate for additional needs.

You should never save (or let users save) anything of importance in the /tmp folder. It is not meant for persistent storage in any way.
If your /tmp folder is set to use the tmpfs filesystem or the /dev/shm device, you not only should not, but simply cannot use it for "saving" anything. Reboot, and all will be lost.
0
 

Author Comment

by:ashsysad
ID: 34185809
Can I know how can I make the /tmp folder to use the tmpfs filesystem or /dev/shm device?
0
 

Author Comment

by:ashsysad
ID: 34185853
Please ignore my last question. I guess i got the answer. So in fstab if we mount tmpfs filesystem on /tmp, then /tmp will use RAM space for saving the files, which isn't acceptable.
0
 

Author Closing Comment

by:ashsysad
ID: 34185986
Thanks for clarifying me about tmpfs filesystem.
0
 
LVL 9

Expert Comment

by:expert_tanmay
ID: 34186010
You might have also come across a line as given below
none                 1004M     0 1004M   0% /dev/shm
this is the partition where Linux keeps the swap(virtual memory) file system. For every device on Linux a interface is created like /dev/... They allow software to interact with a device driver using standard input/output  system calls, which simplifies many tasks.

Similarly
tmpfs                 3.1G     0  3.1G   0% /dev/shm
/dev/shm is the device interface for reading or writing tmp files. Tmpfs does not use traditional non-volatile media to store file data; instead, tmpfs files exist solely in virtual memory maintained by the Linux kernel. Because tmpfs file systems do not use dedicated physical memory for file data but instead use VM system resources and facilities, they can take advantage of kernel resource management policies.

regards
0
 

Author Comment

by:ashsysad
ID: 34186022
Thanks Tanmay !
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question