Running Minecraft from a RAM disk

Posted by Kromey at 6:17pm Aug 17 '11
You must sign in to send Kromey a message
RAM disks are fast. Very fast. If the speed of your hard drive were to be considered like that of a Ferrari, then the speed of a RAM disk would be akin to a tachyon -- a theoretical sub-atomic particle that travels faster than the speed of light!!

So why not harness that awesome speed to make Minecraft speedier?

Well, RAM disks come with a significant drawback: Anything sitting on one when the computer loses power is gone, for all intents and purposes completely irrecoverable.

So how can this be used to make Minecraft faster? Won't it mean that all your hard work will be lost the next time there's a power outage, or you restart the server to apply an update?

Not even if we periodically commit changes to the disk.

Here's how I've done it:

Prerequisites:
Minecraft (duh)
Linux server with rsync installed (it can be done on Windows or Mac, but the process is very different)
Enough spare RAM to contain your Minecraft world

In my case, my server is Ubuntu, and I have 4GB of RAM, and I'm using less than half of it.

Step 1: Make the RAM disk
The RAM disk needs to be big enough to contain your entire world, plus the Minecraft server files. It also cannot exceed your free RAM.

In my case, my world+server files total 91MB; to allow room for growth, I created a 128MB RAM disk by adding the following line to my /etc/fstab file:
tmpfs /srv/mc tmpfs size=128M 1 1

Then you can either reboot, or else simply run the command "mount -a" to mount your new RAM disk (make sure you create the folder /srv/mc first!).

Step 2: Copy Minecraft and your world
In my case, I'd been running the game from /home/minecraft/, so this was simple:
rsync -a --delete-after /home/minecraft/ /srv/mc/

Step 3: Start Minecraft
I have a handy script that does this bit for me, so after changing the paths all I have to do is
/etc/init.d/minecraft start

Step 4: Periodically save the world to a physical disk
I created a cron job that runs every 15 minutes and writes everything to disk, using rsync:
rsync -a --delete-after /srv/mc/ /home/minecraft/

Step 5: Automate everything!
I modified my init script to run the first rsync command (Step 2) prior to starting the server, run the second one (Step 4) after stopping it and also when "backing up" the world. The cron job was then tweaked to run the "backup" action from my script (which also forces the Minecraft server to write the whole world to "disk") every 15 minutes, ensuring that I always have a consistent and up-to-date copy stored safely on disk.

I'll post a more thorough walk-through on my blog later, including my init script that I use; I'll add a link here when I do.

You currently have read-only access to this board. You must request an account to join the conversation.

Why Join 4thKingdom?

Note that there are no ads here. Just intelligent and friendly conversation. We keep the spam out, the trolls out, the advertisers out… 4K is just a low-key, old-fashioned site with members from around the world.
This community began in 1998, and we continue to accept new members today.

Hot Discussion Topics: