tempfs vs RAM Disk

2004 Oct 21 at 07:46 » Tagged as :

I am beginning to wonder why I ever bothered with RAM disks. Apprently tempfs can offer all the benefit of RAM disk and more.

For years I used to think /dev/shm that used to show up with a call to df was just for shared memory. How stupid can you get?! according to the kernel documentation, it probably isn't even used for shared memory nowadays!

It turns out that you can mount /dev/shm and use it just like any other partition. The main advantage it has over RAM disks is that you can change it's size dynamically and if by some chance you need it to be larger than the available RAM you can move it out into swap.

The first thing I did since making this discovery is to move my /tmp into shared memory. All it takes is the following entry in /etc/fstab

none /tmp/ tmpfs size=32M,nr_inodes=10k,user,noatime 0 0

That gives me a 32mb /tmp folder.