HowTo: Utilise the RAM disk

Those of you who are Amiga veterans from the 80’s and early 90’s will be familiar with the oh-so-useful RAM: disk. A virtual device that treated your unused system RAM as a disk device that you could extract temporary files to and make a general mess of without worrying about cleaning it up later, because when you rebooted, the content of the RAM disk would be cleared. The amount of data you could put in it was simply limited to how much physical RAM you had. The RAM disk was always 100% full because it was dynamic in nature. If you had 10MB of data in there, then the RAM disk consumed 10MB of system RAM. If you only had 2MB of data in there, then it only consumed 2MB of system RAM – the RAM disk never impacted on the rest of system memory in a prejudiced fashion.

Microsoft DOS and Windows have tried to replicate this feature with limited success, and the RAM disk was always a fixed size and pre-allocated from the rest of the system as well, which made it somewhat useless. If you had a 512MB RAM system and allocated 50MB for the RAM disk, then you only had 462MB left for the rest of the system, and this also meant that you could not put more than 50MB of data into the RAM disk.

Ubuntu Linux (and pretty much every other distro) has its own RAM disk feature as well and is just as flexible as the Amiga’s RAM disk in its use. Here’s a guide on how to use it.

Using a RAM disk in Ubuntu is simplicity itself – it’s already setup for you!

The RAM disk is located at /dev/shm on your system. Anything placed in this directory is in the RAM disk and will be lost when you reboot the system. The RAM disk is already utilised for temporary files from PulseAudio, so if you list the content of the RAM disk in a terminal with:

$ ls /dev/shm

You might get one or more temporary files that look similar to “pulse-shm-2343031262″.

Let’s make the RAM disk more accessible – how about an icon for it on the Gnome desktop?

  1. Start by doing a single right-mouse-click  anywhere on the Gnome desktop. A menu appears.
  1. Choose “Create Launcher” from this menu. A “Create Launcher” window will appear.
  1. Change the “Type” option from Application to Location.
  2. In the “Name” field, type in My RAM disk (or whatever you prefer).
  3. In the “Location” field, type in file:///dev/shm/
  4. And finally in the “Comment” field, type in a suitable description such as “Accesses the RAM disk for temporary data”.
  1. Click OK and a new icon will appear on the desktop entitled “My RAM disk”.
  1. When you double-click on it, a Nautilus window will open showing the content of the RAM disk.

Try copying some data to the RAM disk now and then reboot your PC. When you re-open the RAM disk, you will find the data you copied is now gone because it was never physically saved to your hard-drive.

Great stuff, but that Launcher icon looks a bit boring. Let’s give it some meaning. On my system, I use an icon of a male sheep, or (you guessed it) a Ram! Male sheep = Ram = RAM disk, geddit? Oh never mind… You can use this visual gag yourself by replacing the icon of the launcher with an image file.

  1. First up, download the sheep icon from here and place it somewhere appropriate on your system where it can be re-retrieved from, eg: /home/jbloggs/Pictures/RamSheep.png because it needs to be reloaded as your Launcher icon whenever you reboot. Leave this Nautilus window showing pictures folder open as we’ll need it to drag and drop from later.
  2. Now do a single-right-click of your RAM disk icon on your desktop and choose “Properties” from the menu. A new window appears.
  1. The properties window shows the current icon for your Launcher.
  1. Now drag the sheep icon from where you downloaded it to on top of the default icon of the launcher and release the mouse button to drop it. This will replace it with the picture of the sheep.
  1. Click close to close the Properties window.
  1. If the icon is too small for you, you can make it bigger by resizing it. Do a single-right-click on the  icon and choose “Stretch icon” from the menu. Four anchors will appear on the icon for you to pull on.
  1. Grab one of the anchors with your mouse and drag it until the icon is at the desired size.
It’s a RAM Disk, geddit?
  1. Click anywhere outside of the icon to set the icon size and remove the anchors.
  2. You’re done!