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 have seen this before ... the /tmp directory mounted on swap space. I am aware something similar can be done using tmpfs, but I don't think that what was being used. I too would like to mount /tmp onto my swap partition without using tmpfs but do not know how. My (layman's) understanding of tmpfs is that, by default, it uses half the RAM on your system. I also understand that I can be tweaked to use a greater or lesser amount. But can it be configured to use 0 (that is, zero) bytes of RAM but use only available swap partitions? I tried and it did not work for me. But then again, I know very little about this. Maybe some parameters were entered incorrectly. I like the idea of using swap for an OS temp dir but I do not want to allocate any RAM for this. Is this possible?

share|improve this question
    
Uhm. You can use swapoff to stop swap. Then format the now unused partition with mke2fs and edit /etc/fstab to mount /tmp on it at the next reboot. -- This will accomplish what you ask, but somehow I doubt it answers what you actually want. –  Hennes Aug 25 '12 at 19:07
    
No, you're right, that's not it. What I want to know is, how can I concurrently use my active swap partition as a tmp directory under a running Linux system. –  user1549377 Aug 25 '12 at 19:28
    
OK, maybe this will start to clarify things a bit (I'm a bit new to this Unix thingy): Can tmpfs be used with swap only, that is, without using even a single byte of RAM? –  user1549377 Aug 25 '12 at 19:31
2  
No. It will always use some RAM. If you could use no RAM at all for it then what is the advantage above a regular directory? –  Hennes Aug 25 '12 at 19:50
    
Thanks Hennes. The advantage for me would be privacy. I was hoping to mount tmp on an encrypted swap. You could use a separate partition for tmp, but I already have four partitions. –  user1549377 Aug 25 '12 at 19:57

1 Answer 1

up vote 1 down vote accepted

tmpfs will initially be allocated half the size of RAM, but is is backed by swap space and will swap if memory is low, So it doesn't prevent the system from using all available RAM for othet purposes.

I'd recommend simply using tmpfs rather trying something obscure .

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.