Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How to be sure that a tmpfs filesystem can only deal with physical and it's not using a swap partition on disk ?

Since i have a slow HDD and a fast RAM i would like, at least, giving higher priority to the RAM usage for swap and tmpfs or disabling the disk usage for tmpfs related mount points.

Thanks.

share|improve this question
2  
Actualy, under the terms you've given the only one answer is not using swap at all. And JFYI Linux kernel programmers are really aware RAM is faster. So, you're doing something rather pointless. –  poige Oct 10 '12 at 22:10
    
Everybody has a slow hard disk and fast RAM. Use tmpfs. The kernel is smarter than you when it comes to deciding what should be kept in RAM and what has to be relegated back to disk when the RAM is full. –  Gilles Oct 10 '12 at 23:22

1 Answer 1

up vote 4 down vote accepted

use ramfs instead of tmpfs. ramfs is a ramdisk (no swap) tmpfs can be both in your /etc/fstab:

none     /path/to/location     ramfs  defaults,size=512M   0     0

edit the size parameter to whatever you like but be careful not to exceed your actual amount of ram.

NOTE: the use of a ramfs instead of tmpfs is not something i would recommend. you will find yourself experiencing stability issues if something happens and you write a ton of data to your ramdisk. you can NOT unallocate ram from a ramfs. once your ramdisk (all of your ram) is full your system will seize up. ram is volatile memory, meaning once it looses power all data is gone. so if your ramdisk fills up your ram and you crash you will never see what was on your ram disk again. unlike ramfs, tmpfs limits its size.

share|improve this answer
    
thanks, i have never heard of this ramfs, it's something that was introduced recently ? What are the requirements for this ? Kernel version ? EDIT how to swap on a ramfs ? –  user1717079 Oct 10 '12 at 15:54
    
tmpfs is supported on all kernels 2.4+. according to wikipedia ramfs precedes tmpfs (en.wikipedia.org/wiki/Tmpfs#Linux). –  h3rrmiller Oct 10 '12 at 15:55
    
/dev/shm is an example of a ramdisk. however it has been defaulted to tmpfs now that disks are faster. You commonly find /tmp as a ramfs on Solaris. The issue with that is you can continually allocate more ram for /tmp but cannot unallocate that ram once allocated without a reboot –  h3rrmiller Oct 10 '12 at 15:56
1  
the use of a ramfs instead of tmpfs is not something i would recommend. you will find yourself experiencing stability issues if something happens and you write a ton of data to your ramdisk. as i said you can NOT unallocate ram from a ramfs. once your ramdisk (all of your ram) is full your system will seize up. ram is volatile memory, meaning once it looses power all data is gone. so if your ramdisk fills up your ram and you crash you will never see what was on your ram disk again –  h3rrmiller Oct 10 '12 at 16:08
1  
+1 to h3rrmiller - I've seen a ramfs setup consume all available memory until a machine dies. tmpfs is more appropriate. Also there is little point swapping to ram - why swap at all? –  Danny Staple Oct 10 '12 at 16:43

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.