[CentOS] Odd Question... MAX Ram Disk Size

Thu Mar 31 16:10:51 UTC 2005
Aleksandar Milivojevic <amilivojevic at pbl.ca>

Aleksandar Milivojevic wrote:

> # mount -t tmpfs -o size=8g none /ramdisk
> 
> That would create 8GB memory-based file system.  The memory file system 
> uses is swappable.  So just make sure free RAM + free swap is larger 
> than 8GB, and you should be fine.

One thing I forgot to mention.  tmpfs file system type does not allocate 
memory upfront.  That means it is possible to overcommit.  For example, 
even if you had like 256MB of memory, and 512MB of swap space, system 
will be happy to create 8GB tmpfs file system for you (try it out, 
nothing bad is going to happen).

It uses only amount of memory needed to store actual files on the file 
system.  So, if your /ramdisk (or whatever you call it) is empty, 
(almost) no memory is used.  If you put two 100kB files into it, 200kB 
of memory is dynamically allocated for them.  Not enough space in RAM, 
it goes to swap (or goes to swap if something else needs more memory, 
just like any other swappable memory region).  You delete one of those 
100kB files, 100kB is freed and goes back to the system to use for other 
purpuses.  If you run out of RAM and swap, writes to tmpfs will fail 
just as if it was disk that got full.

-- 
Aleksandar Milivojevic <amilivojevic at pbl.ca>    Pollard Banknote Limited
Systems Administrator                           1499 Buffalo Place
Tel: (204) 474-2323 ext 276                     Winnipeg, MB  R3T 1L7