john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

Linux ramdisk

linux-ramdisk

A ramdisk is a virtual disk that stores data in RAM. While this reduces the amount of RAM available to your system it may be useful for sensitive material that shouldn't ever be written to disk, making certain files as accessible as fast as possible, mounting a loopback system (e.g. livecd where you don't need a hard drive).

although the most speed gains will be noticed on larger files or a large number of small files that all need to be sent across a network...

Additionally if you are running an OS from flash memory and if you want to reduce your writes you can mount any logging (e.g. /var ) onto a ram/temp fs... of course you'll have to manually save them in a chunk if you really want to keep them...

NOTE that a ramdisk, even when unmounted, will still be marked as "used" so you can remount it and access the same files... BUT you still won't have it available to RAM... until the next reboot...


random tip to clear your linux buffer cache (e.g. what appears with "free") Kernels 2.6.16

ls /proc/sys/vm/ //see all of the fun stats

To free pagecache:

echo 1 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes: echo 3 > /proc/sys/vm/drop_caches


More modern alternatives are RAMFS and TEMPFS

ramfs will grow dynamically so when you fill up /tmp/ram to the size of your RAM your system will hang...

tmpfs has a set size AND it will use swap (if you have any)...

mount -t tmpfs -osize=1M tmpfs /var/run


hopefully your os has created some ramdisk devices for you...

ls /dev/ram*

mke2fs -m 0 /dev/ram0

mount /dev/ram0 /mnt/myfastfilesystem

mount -t ramfs none /mnt/myramfs mount -t tmpfs none /mnt/mytmpfs


umount -v /mnt/myfastfilesystem

trying to reclaim that ram disk space:

from util-linux package...

blockdev --flushbufs /dev/ram0


  • « Linux ndiswrapper linksys wifi
  • Linux printing Unsupported format application octet stream »

Published

Feb 6, 2010

Category

linux

~301 words

Tags

  • linux 249
  • ramdisk 1