Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I was compiling 2 kernels at once but the compiling process stopped. Reason: /tmp directory full. I checked with df and... /tmp has a fixed size of 2GB! (My PC has 4GB of RAM) Why? I don't even have a /tmp partition... how can I change that?

    File system    1K-blocks    Usati Disponib. Uso% Montato su
/dev/sda5       35431432 13651652  19973276  41% /
dev              1989592        0   1989592   0% /dev
run              1992432      976   1991456   1% /run
tmpfs            1992432      280   1992152   1% /dev/shm
tmpfs            1992432        0   1992432   0% /sys/fs/cgroup
tmpfs            1992432  1436412    556020  73% /tmp
share|improve this question
2  
What Linux are you using? Is this 32 or 64bit? Could you update your question with the output of free -h? –  terdon Jul 13 '13 at 13:13

3 Answers 3

up vote 1 down vote accepted

Putting a limit on /tmp size if it is mounted as tmpfs is to prevent the DOS attack. If one service was compromised or one user malicious they could simply write to /tmp until all of the swap and memory would be occupied.

Since the OOM condition does not apply to files the processes would be killed until the malicious user shell would be killed (and he would not be able to log in due to lack of memory) or the compromised service would be killed. At this stage the system would be too slow for administrator to actually do anything other then restart, which would wipe the evidence thus making it effective DOS technique.

Not having /tmp as separate mount then a slightly different problems would happened. Making the / partition full may render system unbootable and in very bad situation (say a glibc update) it may require much more repairing.

While those problems can be significant for multi-system there is also a reason to prevent it for desktop users. For example I had once used a program which tried to write several GB of files in times when 512 MiB was large amount of RAM, which would render system unusably had the tmpfs been unlimited. In such way it only cause problems for the program itself and others trying to write to /tmp.

50% of RAM for tmpsfs allows to use 50% of RAM for other things like running programs thus preventing the large swapping. Since it is generally assumed that minimal amount of information is kept there (41M on my system), but it needs to be quickly accessible is the reason of using tmpfs in the first place (no need to preserve it accross reboots is enabling it). Thus 50% is 'reasonable' to both having large slack in case a peak /tmp usage happens while at the same time preventing the system slowdown.

As mentioned by abdelsaid you can change the settings in /etc/fstab:

none /tmp tmpfs size=2G 0 0 # Change the size= parameter to whatever you want

PS. Where are you trying to compile the kernels (in /tmp)? Usually you compile them with user rights AND save the results in case you need 3rd party modules etc. gcc should keep minimal amount of files on /tmp thus avoiding the whole problem.

Once you use 4 GB of /tmp on 4GB system it is possible (especially when you are using heavyweight desktop environment) that your system will slow down significantly.

share|improve this answer

By default installation, RHEL and most Linux distributions mount tmpfs (a RAM-based temporarily filesystem) to /dev/shm directory and this temporarily filesystem size is always set to be half of the installed memory.

source: http://www.walkernews.net/2010/05/04/how-to-resize-devshm-filesystem-in-linux/

You can change that by specifying size=... in /etc/fstab:

e.g. 2GB:

tmpfs      /dev/shm      tmpfs   defaults,size=2g   0   0

e.g. 4GB:

tmpfs      /dev/shm      tmpfs   defaults,size=4g   0   0
share|improve this answer
    
The problem is with /tmp not /dev/shm (the latter is almost not used). –  Maciej Piechotka Jul 13 '13 at 17:42
1  
/tmp is using tmpfs which is exactly /dev/shm –  abdelsaid Jul 13 '13 at 21:31

If you prefer to not have /tmp mounted in tmpfs, look in /etc/fstab for a line similar to this:

tmpfs /tmp tmpfs defaults,noexec,nosuid 0 0

Remove it if present.

Depending on the distribution, it may also be configured in /etc/default/tmpfs. Edit that file and if the following line is present, comment it (prepend a #):

RAMTMP=yes
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.