Based on the comments and feedback from my older guides I have added many requested features and fixes. It has changed so much since 1.12’s World of Color that my old guide is now obsolete and it’s time for the 1.13 Aquatic era update!
This script and guide are written to help you get a great performing Raspberry Pi Minecraft server up and running in only a few minutes.
I play on my server with 3-4 players on Survival mode without any difficulty on default settings (vanilla view distance of 10 and normal entity spawns/ranges). Above that number of players you will want to look into hardware with more memory but if you just want to play with a few friends it will be an excellent experience!
- Sets up fully operational Minecraft server in a couple of minutes
- Installs OpenJDK 9 for ARM (supports G1, a much better garbage collector than Java 8 for ARM has)
- Sets up Minecraft as a system service with option to autostart at boot
- Automatic backups to minecraft/backups when server restarts
- Updates automatically to the latest Minecraft server version when server is started
- Optional daily restart of Pi using cron
- Easy control of server with start.sh, stop.sh and restart.sh scripts
- Optional configuration of video memory to 16MB (default 64MB) and overclocking MicroSD reader to 100Hz (default 50Hz) for maximum performance
- Raspberry Pi model with 1024MB of RAM. Basically a Raspberry Pi 2B or higher. (No Zero unfortunately, 512MB is not enough RAM to do this, I’ve tried!)
- Raspbian Stretch Lite (No GUI, it eats up too much precious RAM!)
- Solid state drive highly recommended but not required.
You can get a SSD setup on a Pi for < $30. See my article here for details
- If using MicroSD you want to be using a mid to high range card otherwise you will really be hurting on IO when the server is reading/writing chunks of terrain. Your card’s name should have lots of Pros/Ultras/Extremes in the title! Click here for MicroSD card benchmarks/recommendations.
Or for a compact setup: SanDisk Extreme Pro USB Solid State Flash Drive
Install Raspbian Lite on your Pi first and then SSH into your Raspberry Pi and type/paste the following commands:
wget -O SetupMinecraft.sh https://raw.githubusercontent.com/TheRemote/RaspberryPiMinecraft/master/SetupMinecraft.sh
chmod +x SetupMinecraft.sh
The script will setup the Minecraft sever and ask you some questions on how to configure it. I’ll explain here what they mean.
“Set clock speed to 100 MHz? Requires reboot. (y/n)?” – This will overclock your MicroSD card reader for you to 100 MHz giving you much faster read/writes on your server. Poor I/O is the #1 performance bottleneck so if you are going MicroSD we need to do all we can to mitigate that!
There are some cards (usually cheap ones) that can’t handle this overclock and will fail to boot afterward. If this happens don’t panic. You can simply reimage the MicroSD card or put it in your computer and go to /boot/config.txt and remove the line dtparam=sd_overclock=100 and save and it will boot right back up unharmed.
Most cards can handle the overclock fairly easily. If your card couldn’t do the overclock just run the script and say no when it asks to overclock. If you are using a SSD instead of MicroSD this setting will do nothing no matter what you pick.
“Change GPU shared memory to 16MB? Requires reboot. (y/n)?” – This is recommended for everyone. Since we are running a headless lite distribution we don’t need any more than the bare minimum of 16MB. That extra memory makes a gigantic difference when we are only working with 1GB total.
“Start Minecraft server at startup automatically (y/n)?” – This will set the Minecraft service to start automatically when your Pi boots. This is great because whenever you want to play you can just plug it in and go without having to SSH in.
“Automatically reboot Pi and update server at 4am daily (y/n)?” – This will add a cron job to the server that reboots the Pi every day at 4am. This is great because every time the server restarts it updates to the latest Minecraft server version as well. The Minecraft Paper server binary is updated every couple of days with bug and performance fixes.
That is it for the setup script. The server will finish configuring and start!
The first time you run the server it will take a little longer to start since it is generating all the server data. If you try to log in before it fully starts you will get a connection timeout error. Watch for the line: “Timings Reset”. This is the last line that prints when the server is ready to rock and roll. At this point you will be able to connect successfully.
The very first time you log into the server it will be slow for about 1-2 minutes. This is because since nobody has logged in before the server has to scramble to generate all the chunks within your view distance (10 by default) and send them to you/store them. During this time you may not be able to see very far and if you try to destroy blocks there will be noticeable lag from when they break to when they actually disappear.
Don’t panic! This will go away within a couple of minutes as the Pi catches up with all the first time login stuff it needs to do. Performance stabilizes and it will feel very much like the offline experience after that.
If you are hosting for a few friends I’d recommend logging in for the first time right after you set up the server instead of having several people nail a blank server at first startup. This gets it out of the way and when everyone is ready to log in the starting area chunks will be fully fleshed out and the Pi just has to read them. It’s an order of magnitude faster for the Pi to read chunks than to generate and store chunks.
In my experience after the initial login exploring new parts of the server doesn’t cause any lag even though new chunks are being generated. The reason for this is that when you’re walking it’s really only having to generate a new chunk as you get close to the border instead of a huge square area of chunks in all directions and all at the same time like during the first login.
Start, Stop and Restart Server
The server can be started, stopped and restarted two different ways. You can use the provided scripts in the Minecraft folder or you can use systemctl. Here are the commands:
sudo systemctl start minecraft
sudo systemctl stop minecraft
sudo systemctl restart minecraft
The server backs up each time it starts. This helps you recover easily if something goes wrong. This system works best if you configured the server to restart daily since it means you will have a backup every day.
To access these backups type:
When a backup is made the filename will be the date and time the backup was taken. If you need to restore a backup it’s very easy. Substitute the timestamp in my example to the backup you want to roll back to. Type:
rm -rf world world_nether world_the_end
tar -xf backups/2019.02.15.22.06.30.tar.gz
Your world has now been restored! It’s a good idea to download these backups off the Pi periodically just in case the Pi’s storage fails.
Updating the Scripts
The scripts can always be updated by downloading the latest SetupMinecraft.sh and running the installer again. It will update all of the scripts in the Minecraft directory and reinstall the startup service for you. This will not overwrite your world or any other data so it is safe to run!
If everyone on your server is on the same LAN or WiFi network as you then you don’t need to do this. If you want people to connect from outside your local network then you need to set up port forwarding on your router.
The process for this is different for every router so the best thing to do is just look at your router and find the model # and put that in google with port forwarding for easy instructions on how to do it for your specific router.
You want to forward port 25565. The type of connection is TCP if your router asks. Once you do this people will be able to connect to your Minecraft server through your public IP address. This is different than your local IP which is usually a 192.x.x.x or 10.x.x.x. If you don’t know what that is just go to google and type “what’s my ip” and Google will kindly tell you!
Wired vs. Wireless
Going with an ethernet (wired) connection is going to be faster and more reliable. There’s so much wireless traffic and other interference in the air that running your server on WiFi is not recommended.
Even if it is working great 99% of the time it can ruin your experience very quickly if the WiFi drops for a couple of seconds and you get blown up by a creeper!
All that being said, the server works fine on wireless. The script will work fine as is with a wireless connection.
OpenJDK 9’s new garbage collector has made running a server on the Raspberry Pi feel great! We can run at the default view distance of 10 with default entity settings.
If you have any feedback or suggestions let me know in the comment section. A lot of the new developments in this script were directly from comments to the older articles.