My kids are gamers, and they love Minecraft. Minecraft sells its client software, but the server software is freely available. Since it is written in Java, it can run easily on Linux. Meanwhile, you can order neat little Raspberry Pi Linux computers for less than $50. So, putting two and two together, you can build cheaply a little box (not much bigger than my hand) that can be used as a permanent, low-power, perfectly silent game server. And you can expose your kids to servers, Linux and so forth.
There are many guides to setting up a Minecraft server on a Raspberry Pi, but the information is all over the place, and often obsolete. So I thought I would contribute my own technical guide. It took me a couple of long evenings to set things up, but if you follow my instructions, you can probably get it done in a couple of hours, once you have assembled all the material.
You need to buy a Raspberry Pi. I recommend getting either a Raspberry Pi 2 or a Raspberry Pi 3. I tried long and hard to get a stable and fast server running on a first-generation Raspberry Pi, but it was not good.
You need a power cord to go with it.
Moreover, you need a micro SD card. I recommend getting, at least, an 8GB card. Given how cheap cards are, you might as well get a larger card.
I recommend getting a nice plastic box to enclose your Raspberry Pi, just so that it is prettier.
You might also need an ethernet cable if you do not have one already. If you are going to use the Raspberry Pi, it is best to connect it directly to your router: wifi is slower, more troublesome and less scalable.
An HDMI cable, an HDMI-compatible monitor or TV, a USB keyboard and a USB mouse are also be required at first.
Then you need to put the latest version of the Linux distribution for Raspberry Pi, Raspbian on the SD card. If you have an old version of the operating system, do not try to upgrade it unnecessarily. Starting from a fresh version is best. Simply follow the instructions from the Raspberry Pi website. Downloading the image files takes forever.
At first, you will need a monitor or a TV (with an HDMI connection), a keyboard and a mouse. Connect your Raspberry Pi to your router through the ethernet cable. Put the SD card in the Raspberry Pi. Plug the monitor, the keyboard, and the mouse. Plug the power in and it should start. It will launch in a graphical mode with mouse support and everything you expect from a modern operating system: we will soon get rid of this unnecessary luxury. If, like it happened to me, the card won’t stay plugged in, just use a rubber band. Hopefully, you have Internet access right away.
Go to the terminal. I recommend installing a couple of extra packages: sudo apt-get install netatalk screen. Then type sudo raspi-config. This command starts a little configuration tool. First, tell it to expand the file system so that it uses all the SD card. For safety, I recommend changing the default password (the basic account is called pi with password raspberry). You want to tell the Raspberry Pi to boot in the shell: Console Autologin Text console, automatically logged in as 'pi' user. In Internationalisation Options, you want to configure the time and locale. You may want to set the overclocking to the maximum setting. You want to assign the minimum amount of memory to the GPU (16 is enough) from Advanced Options. Make sure that the ssh server is on. Reboot the Raspberry Pi.
From your PC or Mac on the same network, you need to connect by ssh to pi@raspberrypi.local.
On a Mac, just go to Terminal and type ssh pi@raspberrypi.local.
If you are using Windows, you can access your Raspberry Pi via ssh by using Putty. You should now be in the bash shell. Once this work, you can unplug the Raspberry Pi from the monitor, the keyboard and the mouse. Your server is now “headless”.
Create a directory where you will install the Minecraft files: mkdir minecraft && cd minecraft.
Download the build file for Spigot (your chosen Minecraft software):
Build the server: java -jar BuildTools.jar. This will take forever. Go drink coffee.
Once this is done, start the server for the first time: java -jar -Xms512M -Xmx1008M spigot-1.9.jar nogui. This will create a file called eula.txt. You need to edit it with the command nano eula.txt. Make sure it reads eula=true.
Start the server a second time: java -jar -Xms512M -Xmx1008M spigot-1.9.jar nogui. It will take forever again. Go drink more coffee. Once the server return the command prompt, it should be operational. Have a Minecraft player connect to raspberrypi.local. Once you have verified that everything works, type stop.
We are going to create a convenient script to start the server. Type nano minecraft.sh and write the following:
Make the script executable: chmod +x minecraft.sh.
To make the server more stable, type nano spigot.yml. Set view-distance: 5 and restart-script: /home/pi/minecraft/minecraft.sh.
Optionally, you may want to type nano server.properties and modify the greeting message given by the motd variable.
We want the server to start automatically when the Raspberry Pi reboots, so type nano /etc/rc.local and enter su -l pi -c /home/pi/minecraft/minecraft.sh right before the exit command.
Start the server again using the script: ./minecraft.sh. It will return you to the shell. To access the console of the server type screen -r minecraft, to return to the shell type ctrl-a d. At any point, you can now disconnect from the server.
And voilà! The result is a “robust” and low-cost Minecraft server. In my experience, the server will still crash on occasion, but it will be stable enough to be fun to use. Moreover, when it does crash, it will automatically reboot.
In the hope of improving performance, I use a plugin called LaggRemover. However, I do not know whether it actually helps stability and performance. Adding plugins is easy, just drop the corresponding jar file in the plugins directory under the Minecraft and rebooting the server (just type stop and relaunch minecraft.sh). (You can recover jar files from the Internet using the wget or curl commands in a shell.)
Next, you can make the server available on the Internet using a service like dyn.com, and some work on your router to redirect the Minecraft port (25565) from your router to the Raspberry Pi. It is not very difficult to do but it requires you to know a few things about how to configure your router. You should also be aware of the security implications.
Is there any point to all of this? Probably not. Minecraft servers like Spigot are memory hungry and the Raspberry Pi has little memory. However, the project has stretched my imagination and make me think of new possibilities. I used to recycle old PCs as home servers to provide backups and caching for various projects. I got tired of having old, noisy and bulky PC in my home… but I could literally stack a cluster of Raspberry Pi computers in a shoe box. The fact that there is no fan is really a blessing.