I’ve been using a ramdisk under Haiku on and off for a while now. The command has been in Haiku’s sources for a long time, and I just compiled it myself. Now it’s officially added to Haiku images and I updated the user guide accordingly. Until that update finds its way to the images and website, I reproduce the entry here.
A ramdisk is like a harddisk running only in the computer's memory. That makes it very fast but also volatile, because its contents vanishes when you shut down the computer, or it crashes or you experience a blackout.
To create a ramdisk of 1 GiB, format to the name "RAMses" and mount it, you enter this in Terminal or create a script of it:
ramdisk create -s 1gb mkfs -q -t bfs /dev/disk/virtual/ram/0/raw RAMses mountvolume RAMses
Note: When creating a ramdisk, the ramdisk command prints out the path to it. If you create several disks, that path /dev/disk/virtual/ram/0/raw will change!
To preserve the contents, at least if no calamity like a blackout etc. strikes, a ramdisk can be set up to read/write an image on the harddisk. For that, you need to supply a file of the desired size that will be read from every time you start your ramdisk, and written to when you unmount it.
To create an image file “RAMimage” of 500MiB and format it, do this:
dd if=/dev/zero of=RAMimage bs=500M count=1 mkfs -q -t bfs /dev/disk/virtual/ram/0/raw RAMimage
From now on, you start the ramdisk like this:
ramdisk create RAMimage mountvolume RAMimage
It’s very important to always cleanly unmount you ramdisk, either from Tracker or with unmount /RAMimage, or the changes won’t be written back to the image file!