Raspberry Pi Minecraft V1.12 Server – Excellent Performance Guide

The Minecraft world of color update 1.12 has finally arrived! This walk through will show you how to set up a playable Minecraft server running on the Raspberry Pi.

ATTENTION:  Newer guide is available! View the updated version here

I highly recommend using Docker over the standalone version for most people. Installing Docker is as simple as sudo apt install docker.io. There are 3 Docker options available:

I have read many tutorials on Google about how to set up a “great performing” Minecraft server on your Raspberry Pi and have been sorely disappointed by the results. Most tutorials are very outdated and tell you to turn your view distance all the way down to 4 (meaning you can’t see very far), or turn your entities (monsters/animals) down to settings so low that they hardly spawn or you can walk right up next to them before you see you.  

After much research, trial and error, and spending time in the #Paper IRC channel talking to the smartest people in the Minecraft server configuration world I have been able to get the Minecraft Server (popular Paper fork based on Spigot) to run at vanilla settings (view distance 10, no reduction in entity settings). This means the server is suitable for full survival mode just like a regular vanilla Minecraft server.

Should you try this?

Let me answer a big question right off the bat. Should you buy a Raspberry Pi just to run it as a Minecraft server? Absolutely not. If you just want to run a Minecraft server, especially one with more than a few people, you are much better off buying a realms subscription or one of the many dedicated Minecraft server options.

The price of the Pi would get you approximately 6 months of a Realms server and probably much more from private hosts. You may also be better off just running the server off your own computer because your CPU and RAM in a desktop class machine is almost certainly going to be better than a Pi.  However, if you already have a Pi just laying around or want to use it to learn a bunch of cool new stuff like setting up a headless Linux server on an embedded device then by all means proceed. It’s a great setup to play Minecraft with a few friends.

Second question: Do you have fast Raspberry Pi storage? Because this tutorial will overclock your SD port from 50hz to 100hz. (Update: Since I wrote this article solid state storage has gone down so much in price that it makes much more sense!) If you have a good SanDisk A1 Class 10 card you should have no problems. However, although the risk is minimal, there is some risk of SD card corruption if you don’t have a high quality card. I am not responsible if your card dies,
your Pi explodes, your house gets hit by a meteorite, or anything else that happens! This is solely at your own risk! These are very common overclocks though and the risk is minimal, but you have been warned!

If you are prepared to continue, then read on!

Requirements:

  • Raspberry Pi with 1GB of memory or higher required. The 1GB of memory in these boards is still barely enough to run the server and can only support a few people. The 4B 2GB and 4GB models have much more breathing room. If you are using a 512MB version of the Pi (like a Raspberry Pi Original Model B/B+ you are not going to get the performance necessary to deliver a stable Minecraft experience without major sacrifices that will be outside the scope of this guide.
  • SSD or *Highly* ranked Micro SD card (SanDisk Extreme or other highly ranked card. Here are some benchmarks of SD cards on Raspberry Pi for comparison. It is extremely important you do not skimp on this as IO performance is the biggest bottleneck in the Raspberry Pi when running a Minecraft server)
  • Latest Raspbian Lite image (currently Buster) https://www.raspberrypi.org/downloads/raspbian/ We need the Lite version because ALL of the Pi’s resources will need to be devoted to running the server. This is command line only and we cannot use an X environment because we need all available memory for the Minecraft server
  • A highly rated power supply capable of providing more than enough of the power we need. Do not plug this into a USB hub unless you know it is powered and has more than enough power for the Raspberry Pi. You also need a good power cable. The official Raspberry Pi power supply or the Canakit power supply (linked below in my configuration) will suffice.
  • Minecraft “Paper” Server
  • Ethernet connection to your router.  Wireless is *not recommended* for a dedicated server or any kind!  Wireless adds so much overhead not to mention signal strength issues, interference with all nearby access points, etc.  Unless you have absolutely no choice you should directly wire the PI to your router with an ethernet cable.  If you have a Pi3 the wireless chip only supports wireless N and not wireless AC on the broader bandwidths.  Even if you have a dongle that does support a wireless AC connection it will slow down your Pi by adding overhead to the USB bus which is an extremely limited resource on the Pi because the Pi basically shares that bus with everything else and we need those lanes as clear as possible.

My Configuration

Recommended Gear

Raspberry Pi 4
Raspberry Pi 4

The Raspberry Pi 4 is available in different memory configurations all the way up to 8 GB. It’s about the size of a credit card and uses an extremely low amount of power making it ideal for all sorts of projects and ideas!

Links: Amazon.com*, AliExpress*, Amazon.ca*, Amazon.com.au*, Amazon*.co.jp*, Amazon.co.uk*, Amazon.de*, Amazon.es*, Amazon.fr*, Amazon.it*, Amazon.nl*, Amazon.pl*, Amazon.se*, Amazon.sg*

Kingston A400 SSD
Kingston A400 2.5″ SATA SSD

The Kingston A400 has been a great drive to use with the Pi for years. It’s reliable, widely available around the world, has low power requirements and performs very well. It’s also very affordable. This drive has been benchmarked over 1000 times at pibenchmarks.com and is the #1 most popular SSD among the Pi community!

Links: Amazon.com*, AliExpress*, Amazon.ca*, Amazon.com.au*, Amazon.co.jp*, Amazon.co.uk*, Amazon.de*, Amazon.es*, Amazon.fr*, Amazon.it*, Amazon.nl*, Amazon.pl*, Amazon.se*, Amazon.sg*

StarTech 2.5" SATA to USB 3.0/3.1 Adapter
StarTech 2.5″ SATA to USB 3.1 Adapter

The USB 3.1 variant of the StarTech 2.5″ SATA adapter works well with the Pi 4. The USB 3.0 variant doesn’t have firmware updates available and is not recommended.

Links: Amazon.com*, Amazon.ca*, Amazon.com.au*, Amazon.co.jp*, Amazon.co.uk*, Amazon.de*, Amazon.es*, Amazon.fr*, Amazon.it*, Amazon.nl*, Amazon.pl*, Amazon.se*, Amazon.sg*

Or for a compact setup:

SanDisk Extreme Pro USB SSD
SanDisk Extreme Pro SSD

The SanDisk Extreme Pro USB SSD is a true solid state drive. This is different than a typical “flash drive” which uses extremely cheap memory and has very low random I/O performance/throughput compared to a real solid state drive. I’ve used both the USB 3.1 and USB 3.2 variants with the Pi successfully and they benchmark very well!

Links: Amazon.com*, AliExpress*, Amazon.ca*, Amazon.com.au*, Amazon.co.jp*, Amazon.co.uk*, Amazon.de*, Amazon.es*, Amazon.fr*, Amazon.it*, Amazon.nl*, Amazon.pl*, Amazon.se*, Amazon.sg*

SD Card Setup:

SanDisk Extreme A1
SanDisk Extreme A1

The SanDisk Extreme A1-A2 SD card has the best scoring SD card on pibenchmarks.com for years and is second in popularity only to the SanDisk Ultra (often included in combo kits). The application class (A1) means random I/O speeds (very important when running an OS) have to meet a higher standard. There’s no benefit on the Pi for A2 right now so get whichever is cheaper/available.

Links: Amazon.com*, AliExpress*, Amazon.ca*, Amazon.com.au*, Amazon.co.jp*, Amazon.co.uk*, Amazon.de*, Amazon.es*, Amazon.fr*, Amazon.it*, Amazon.nl*, Amazon.pl*, Amazon.se*, Amazon.sg*

Windows Initial Setup Requirements:

  • If you aren’t using Windows then you probably don’t need help with this part and can skip to the Raspbian Lite configuration section
  • SSH client – This allows us to connect to our server via SSH. SSH is command line only. I recommend Putty which can be downloaded for free here: Official Putty Download Page
  • Win32DiskImager (writes our Raspbian Lite image to the SD card)

Getting Started – Imaging your SD card for use with the Raspberry Pi

Unzip the Raspbian Lite image you downloaded and use Win32DiskImager to write it to your SD card.  Insert your Micro SD card into your computer’s Micro SD adapter slot.  If your computer can already take MicroUSB cards without the adapter then just stick it right in there.

Now open Win32DiskImager and click the little blue folder icon on the Image line and browse to where you unzipped the Raspian image and select it.  The image line should now be populated with your Raspbian.img file.  You must now select the drive to write the image to.  This will be D: or some other letter depending on how many drives you already have on your computer.  

Win32DiskImager should hide most of the drives you shouldn’t pick like your C: drive but other drives might show up.  Warning:  Don’t screw this one up!  Double, triple, and quadruple check that you select the CORRECT drive to write your SD image to.  If you pick the wrong one it will overwrite that drive and you will be screwed!

The write process will take a few minutes but it won’t take too long because the Raspbian Lite distribution is much smaller than the full distribution.  Once the write completes Win32DiskImager will tell you it is done.  Okay, excellent, we have now formatted your MicroSD card with Raspbian Lite.  

Enabling SSH

There is still one step we need to do.  Raspbian Lite has no X based window manager and is console only.  We need to configure the Pi for SSH access so we can get in with SSH. You can alternatively hook it up to a TV and plug a keyboard in, but since this article is about setting up a headless server I encourage you to do it using SSH.

You should now be able to browse to your SD card in Windows.  Go to your SD cards base folder which will just be called “boot” and create an file called ssh with no file extension.  Make sure that you do not make something like ssh.txt or anything.  It will be just “ssh” with no file extension.  

If you create the ssh file and it looks like a text/Notepad document for the icon then you have your file extensions turned off.  Click “View” at the top of the window and you will see a checkbox under “Show/Hide” that says File Extensions.  Check this box and you will see the ending extensions for every file.  If there is no extension and you have a file that just says “ssh” then you are good to go.  Have Windows safely eject the drive and let’s proceed.  Put the newly formatted card into your Raspberry Pi and fire it up.

Initial Raspbian Lite Configuration

We need to get the newly assigned IP address to your Raspberry Pi.  The easiest way to do this is to log into your routers configuration page and view your connected devices.  If you do not know how to do this then you need to look up how to sign into your router’s configuration page because you will need to set up port forwarding later if you want anybody outside of your own network to be able to connect to the Minecraft server.  

The default hostname is going to be something like rpi3 or raspberrypi.  While you are configuring this I strongly suggest you assign a static IP address for your Raspberry Pi.  This is so that when you set up port forwarding so other users can connect from outside your network that you won’t receive a new IP address the next time you restart your router which would make them unable to connect again.  Now that you know your IP address it’s time to fire up Putty and make a SSH connection to your server.  Put the IP address into Putty and leave the port to the default 22 and click open.

Now it’s time to log into the pi using the default username of pi and the password raspberry. Now that you have signed in and changed your password it’s time to configure Raspbian.

  • Step 1: Type sudo raspi-config and it will take you into the Raspberry Pi configuration options. Choose menu option #1 and Change your password immediately. The stock password of raspberry is the same for everyone and is a huge security risk. This is the very first option on the raspi-config page. Select it and choose a secure password.
  • Step 2 (Optional): You may change your hostname with menu option 2 to whatever you want, such as minecraftserver. If you want to leave it as raspberrypi (the default) that is fine too.
  • Step 3: Choose menu option 4 (Localization Options). By default all Raspbian images will be in the en_GB language. Choose option 1 to change locale and go down and uncheck en_GB and check your own locale’s UTF-8 option. This is important for performance later as the Minecraft server is formatted it UTF-8. For example, on my system I unchecked en_GB and checked en_US.UTF8. Press tab until you get to the Ok button and save these settings. It will now update your locale and ensure you are using UTF-8.
  • Step 4: Choose your timezone. This is the second option in the localization options right under ‘Change Locale’. Select your time zone and hit Ok.
  • Step 5: Interfacing options: Here we need to enable SSH. Even if you did option 2 earlier you still need to do this again or the next time you reboot you won’t be able to SSH in without pulling out the card and recreating that ssh file in the boot folder. Enable SSH and hit ok.
  • Step 6: Choose “Advanced Options” from the main menu. Now choose “Expand Filesystem” which will expand your partition to the maximum size of your SD card so you can actually use all your space.
  • Step 7: Under “Advanced Options” choose option 3 which is “Memory Split”. We are going to set your GPU memory to 16mb. GPU memory on the PI is actually taken out of your RAM so it goes to waste on a headless system. It does not go lower than 16mb so do not try. Choose 16mb and hit ok.
  • Step 8: We are done in this configuration utility. Hit the tab key until “Finish” is highlighted and hit enter. Make sure that you don’t accidentally highlight the cancel option or you may have to do all these steps again. It will now ask if you want to reboot the system. Say yes as this is when many of the changes will take place such as expanding the filesystem which cannot be done without a reboot

After your Raspberry Pi reboots log back in with SSH. We now need to update the system. Type the following command to update the system:

sudo apt-get update && sudo apt-get upgrade

This may take some time based on the speed of your internet connection. After all of the updates have completed reboot your system by typing sudo reboot

Java Configuration

NOTE: For a better way to do this: Update Java to the latest on Raspberry Pi OS

Since we chose the lite image Java is not yet installed on the system, but we are *not* going to use the Java in the Raspbian Jessie repositories because it is outdated and many performance fixes and optimizations have been added. We are going to download the latest Oracle JDK ourselves. At the time of writing the latest Java JDK for hard float ARM (Raspbian 32bit) is jdk-8u131-linux-arm32-vfp-hflt.tar.gz.

Use the following commands:

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/errors/download-fail-1505220.html

If the download was successful you may proceed to the next following commands which will extract the JDK. If it was not successful you need to go to the Oracle Java website and download the latest JDK manually. Once you have downloaded the JDK type the following commands to install it:

sudo mkdir /usr/java
cd /usr/java
sudo tar xf ~/jdk-8u131-linux-arm32-vfp-hflt.tar.gz

Okay, we have extracted Java, now we need to tell the system that it is installed and where to find it using update-alternatives. Use the following commands:

sudo update-alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_131/bin/java 1000
sudo update-alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_131/bin/javac 1000

Alright, that is it. Now lets test and make sure that Java is working properly.

cd ~
java -version

If everything went correctly, you should see something like:
java version “1.8.0_131”
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) Client VM (build 25.131-b11, mixed mode)

If you see this, then congratulations, you’ve installed the latest JDK and are now done with Java configuration for the system.

Minecraft Server Initial Setup

I have all the latest configuration files I am using to run the server uploaded to my GitHub. Lets replace the default versions with these ones to use as a starting point.

My GitHub repository is located at TheRemote – RaspberryPiMinecraft GitHub Repository

Lets download this repository and make our folder to extract the files to. Type/paste the following:

curl https://raw.githubusercontent.com/TheRemote/RaspberryPiMinecraft/master/SetupMinecraft.sh | bash

Advanced Raspberry Pi Configuration – Overclock SD card reader

To get a well performing server we need to make some changes to the Raspberry Pi configuration. The first and most important change that we need to make is that we need to overclock the SD port from 50hz to 100hz. This is safe for all modern cards. Unless you have a 2 dollar bargain bin card you shouldn’t have any trouble.

To understand why the Raspberry Pi is so underclocked keep in mind that the Raspberry Pi is designed to work with any piece of junk SD card since it is an educational computer shipped all over the world. They want it to work with as wide of a range of hardware as possible.

Good class 10 SD cards are rated to work at 100hz. If you have a Samsung Evo or a good SanDisk class 10 you will see tremendous performance gains by changing this. This is the most important optimization/overclock you can make to your Pi because I/O performance WILL be a major bottleneck for the Minecraft Pi server!

This overclock option is enabled in your /boot/config.txt. So before we change anything we are going to back it up. Type this command:
sudo cp /boot/config.txt /boot/config.txt.backup

Great. Now we have a backup of our original config.txt located in the boot folder. Next let’s overclock the SD card slot.

sudo nano /boot/config.txt

Now we want to type/paste this line into the file (I put it at the bottom usually, but you can put it anywhere). The # sign in this configuration file indicates a comment, but I have left a comment on it to make it clear what each line does.

# Overclock the SD card port to 100hz
dtparam=sd_overclock=100

Ctrl+X and yes to save. That’s it. Now let’s reboot the Pi by typing sudo reboot and if you have a quality card your Raspberry Pi will boot up. This nearly doubles the performance of your SD card provided you are using a high quality microUSB card from the links posted above.

If anything goes wrong and your Pi won’t boot, you can simply put the SD card into another machine and open the /boot/config.txt and change it back to the original. Then restart your Pi and it will load up with the original configuration settings. If this happens it means you probably don’t have a card that can handle a 100hz microSD overclock.

Pregenerate your world

The biggest bottleneck on the Raspberry Pi is that generating “chunks” or basically sections of the Minecraft map is done by the server as you explore. This is a very expensive operation both in CPU usage and disk I/O. If you have several people exploring a server that is brand new and the chunks haven’t been generated things get really slow really quick.

Fortunately, there is a plugin that offers a solution to this problem. It is a plugin called “WorldBorder”. The plugin allows you to set a border on your world that stops people from going further, but this isn’t the feature we are necessarily interested in. WorldBorder has an option to “fill” all of the chunks in your server inside your defined border. This means we can generate all of the chunks before the players reach them so that all the Raspberry Pi has to do is read the chunks from the disk which is MUCH faster than having to generate the chunk from scratch and then save it to the disk.

To download this plugin, make sure that the server is not running, and type the following commands:

cd ~/Paper/plugins
wget --content-disposition -E https://dev.bukkit.org/projects/worldborder/files/latest

That’s it. The plugin is now installed.

Before we run the server we need to install one more package. It is an application called “screen” that will allow you to run the Minecraft server on the Pi without having to keep your SSH connection open. Type the following command:

sudo apt-get install screen

In our configuration files we extracted earlier you may have noticed we extracted a script called start.sh. This is a special startup script that uses JVM arguments to help the Minecraft server run appropriately on the Raspberry Pi. I have had Aikar (the master of timings and author of many of the optimizations present in the Paper/Spigot fork of Minecraft) check these JVM arguments and they are the best we can do for the Raspberry Pi and they do make a significant difference.

This is the minimum required to get things running but there are several optional optimizations you should making that I will explain in the next sections. You can start the server by going into the paper directory and running start.sh. This is how it will look when you type the commands:

cd ~/Paper/
./start.sh

At first you won’t really see anything happen. To actually see the Minecraft server screen you will type the following command:

screen -r minecraft

You should now see the Minecraft server output and can interact with the console and type commands per usual. The great thing about screen is that even when you close the SSH window your Minecraft server will stay running. If you close your SSH window and want to log back into SSH you simply reattach to the screen by typing screen -r minecraft once again. This will bring the screen back up again.

Go ahead and bring up the Minecraft server back up now by typing:

screen -r minecraft

If the server has completely loaded you should see something at the bottom like “Timings Reset”. This is one of the last lines that prints as the server starts. You can type console commands to the server from here. We are going to use WorldBorder to create a border and then use the fill function to pregenerate the world.  This is so that the Pi doesn’t have to create the world dynamically as you are trying to play. These commands will set a worldborder radius of 1000 blocks. The first time I did this I set a radius of 2500 blocks and the server ended up being about 350mb and it took hours and we will probably never go to most of those places. You can adjust this number based on how big you want the world to be. I recommend starting with something like 1000. Remember, this can be adjusted later. Use the following commands:

wb world set 1000 spawn
wb world fill 1000
wb fill confirm

This process will take quite a while. On my overclocked Pi I was getting only 50-60 chunks generated per output message. This shows how important it is to pregenerate your world. If you weren’t doing this, this process would be happening while you were trying to play the server and exploring chunks you had not been to before.

This is one of the biggest secrets to having a playable Pi Minecraft server that nobody ever told you! This process took about 30-45 minutes on my overclocked Pi3 with a great SD card for 1000 blocks. It may take shorter/longer depending on how fast your SD card is and what revision of the Pi you are using.

Okay, now that you have waited and the process is 100% complete, you are done! Type stop to gracefully close the server and make sure all those generated chunks are saved. Now I recommend completely rebooting your Pi to clear out the cache with sudo reboot and get a fresh boot and then heading to your Paper folder and typing ./start.sh.

Connecting to the server

Open your Minecraft client and launch vanilla 1.12. The beauty of the Paper fork is that we will be using the vanilla client to play without any mods. Neither you or your friends will change anything from your vanilla Minecraft client. Launch 1.12 and then head to the multiplayer section. Choose “Add Server” and type in your Pi’s IP address. You should see the Pi server and now be able to connect.

To allow outside players to connect to your network you will need to first find out your public IP address (the internet facing IP address). The easiest way to do this is just to go to http://www.whatismypublicip.com/.

Now that you know your public IP address you need to set up a port forwarding rule in your router. This process is different for every router. If you don’t know how to log into your router and add a port forwarding rule go look at your router and find the model # and then go to google and type your router’s model along with “port forwarding” and you should easily find instructions for any router.

If you already know how to log into your router and add port forwarding, you will simply add a port forward for TCP/UDP port 25565 to your Raspberry Pi’s IP and players outside the network will be able to connect by adding your internet facing IP we got from whatismypublicip.com.

Congratulations, you are done and will now have a well performing Raspberry Pi server!

Benchmarking / Testing Storage

If you want to verify your drive’s performance you may want to run my storage benchmark with:

sudo curl https://raw.githubusercontent.com/TheRemote/PiBenchmarks/master/Storage.sh | sudo bash

If you search for the model of your drive on Pi Benchmarks you can compare your score with others and make sure the drive is performing correctly!

Conclusion

The reason we are able to run a Minecraft server at full vanilla settings with this configuration is because of the Raspberry Pi’s bottlenecks and how we have minimized them. Let’s recap them real quick.

  • Disk I/O: By overclocking the SD port and having a high quality SD card we are able to nearly double our disk performance. Reading is much faster than writing, so by pregenerating our world we are able to use a full view distance of 10 instead of 4 like the other tutorials recommend
  • RAM: By running a completely headless server and changing our dedicated video memory to 16mb we squeeze out enough RAM for the Minecraft server to comfortably support a few players at vanilla settings
  • CPU: The CPU on the Raspberry Pi is actually fairly decent, but most of Minecraft’s code is single threaded meaning most of the operations are running on one core. The Paper Spigot fork of Minecraft adds threading for some extremely important areas. The most important one is chunk loading and unloading. The vanilla Minecraft server does not do this and that is why it is practically impossible to run a pure vanilla Minecraft server on a quad core ARM computer when everything is in a single thread.

As you saw when we ran WorldBorder’s fill function, the Minecraft server on a Pi can only generate around 50-60 chunks per second. When somebody logs into a server with view distance 10, they can see MANY more chunks than that. That means that if you try to explore with your friends you are generating a huge amount of chunks which brings the Raspberry Pi to its knees.

By pregenerating the world all the Pi has to do is load it and send it. The Pi’s fastest disk performance is reading, so since we are just reading the chunks and sending them instead of generating them (CPU and RAM expensive) and then saving those chunks to the disk (Disk IO intensive), we avoid all this by just reading them and forwarding them to the players. This creates a smooth playable experience.

Therefore, the conclusion of this project is that the key to running a Minecraft server on the Pi is to invest in a excellent solid state drive or SD card and overclock it, then pregenerate your world!

45 thoughts on “Raspberry Pi Minecraft V1.12 Server – Excellent Performance Guide”

  1. Avatar for flo

    Hey there,

    very nice articel. Since i was trying to run minecraft since the first generation of PIs, im pleased to see there are more people doing this even its not the best hardware.
    My latest attempt is using the new folia server provided by paper. Building it was easy from the github-Repo. So far its running very smooth and even the PI clocks down when no player is online. Wasnt the case with paper afaik.
    Only downside: There a no official supported plugins atm, but you can try to append “folia-supported: true” in any plugins.yml. Maybe it works. For example dynmap doesnt. 🙁

    Running on PI4 8GB with ubuntu installed on a m.2 expansionboard via USB (no sd-card in PI). Arguments:
    -Xms4G -Xmx4G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:-OmitStackTraceInFastThrow -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=8 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=true -Daikars.new.flags=true

    In case anyone wants to try: bunnykitty.servebeer.com
    “/tps” works for non-OPs. So you can see the performance.

    Happy easter
    flo

    1. Avatar for James A. Chambers

      Hey flo,

      That’s actually very interesting. I’d never heard of it. It’s legit though and featured on the Paper Minecraft web site.

      I’d say it’s very, very early to be running this. There are no official builds available so it would be impossible for me to make a script like this one (or my Docker containers) for it yet with automatic updates.

      Nevertheless this is an extremely exciting project and that’s very cool you have a test build up that you built from source. I’m very excited to see how they expand the API. I hope they can make it compatible with all plugins somehow but that might be impossible. It sounds like they’re planning to make Folia plugins compatible with Paper but not the other way around if I’m reading their README correctly:

      Currently, there is a lot of API that relies on the main thread. I expect basically zero plugins that are compatible with Paper to be compatible with Folia. However, there are plans to add API that would allow Folia plugins to be compatible with Paper.

      Have you found any plugins that do actually still work yet? Hopefully they’re able to do some kind of compatibility layer later.

      This would solve a major problem that massively impacts the Pi but also impacts many other devices. The Minecraft server (even the Paper version) sucks at multithreading. It always has. Paper even has threading improvements over vanilla but nothing like Folia is trying to do. In the past it has been better to have a dual-core CPU with very high clock speeds rather than 4 low powered CPU cores (what the Pi and many low-end servers have). It’s literally better to have less cores with current Minecraft servers (or higher single-core clock speeds, the highest you can). Folia would solve this as it continues to develop.

      Thanks for sharing this!

  2. Avatar for Ned

    Hello there and thank you very much for this great tutorial!
    However, i have two problems with my server.

    First, it tends to use much more memory than what I want to allocate. I set the -Xmx option in start.sh to 750M but my Pi’s memory usage goes higher than 900MB, even though it’s only at 30MB when the server is stopped. The problem is, my RPI 3 only has 1 GB of memory and it freezes when the memory usage gets too high. I feel like the server does not “respect” the memory limit, and I think I have set something wrong but I can’t figure out what it is.

    Secondly, when installing the server using the script provided in the tutorial, I first chose to let the server start automatically when the Pi boots, but I then realized it was not ideal and I tried to remove this feature. I ran the update script which gave me the same choice again, I selected “no” this time but the server still starts on boot, and I don’t know how to prevent it to.

    1. Avatar for James A. Chambers

      Hey Ned,

      Great questions! I think I can help for sure. You are right that the memory limit is not being respected, but the real culprit is not the Minecraft server, it is actually the Java Virtual Machine!

      What is happening is that Java does not count the memory to hold itself as part of the 750M, the 750M are just for Minecraft. There’s another 50-150ish MB of overhead (it varies as you’ve observed) from the Java Virtual Machine itself.

      Not to worry, when I originally wrote this it was for the Raspberry Pi 1 with 512M of RAM. You should be able to get away with setting your memory usage much lower. I would try 500-600MB. This will leave space for the <150MB Java Virtual Machine (JVM) overhead and keep you under 750 leaving another 250 for the rest of the system. I believe you could go even lower. Most people run into problems setting their memory too high and very very rarely for setting it too low. It could even go under 500MB. I think there is a lower limit around 200-300MB where it will start crashing but it can be squeezed for sure.

      For the second part of your question I can definitely help with that. You can disable the automatic startup service with:

      sudo systemctl disable minecraft

      I thought answering no would do this for you but now that I think about it I’m actually not entirely sure it does, and from what you are saying it certainly seems to not be but that should take care of it for you. Hopefully that helps and thanks for the kind words!

      1. Avatar for Ned

        Thanks a lot!
        I didn’t think about the fact that the JVM would use extra memory, but it makes sense that it does.
        And for the automatic startup, it’s good to know I can change it easily!

        1. Avatar for James A. Chambers

          Hey Ned,

          No problem at all! I kind of try to include the JVM overhead in the recommended memory settings but to be honest with you they are not best tuned for 1GB anymore and are probably more appropriate for the 2-8GB range that those recommendations make the most sense. I think your adjustments will be the best for a 1GB board.

          It used to require a lot more hands-on fine tuning than it does now back in the 512MB to 1GB Pi days so this is a little bit of a throwback to that since we have to manage our resources a little bit tighter in that situation and we can’t afford to be losing 100-200MB unexpectedly. I’m glad you got the automatic startup adjusted as well!

          Definitely feel free to stop by if you run into any more issues or have any other questions!

      2. Avatar for Luke

        I am having a similar problem with memory usage on an RPI 3. It seems I can’t set the memory limit under 600, but the first few times that I have tried to run the server all the memory has eventually disappeared and the server has frozen. Any advice on how to diagnose the memory hog or how to fix the problem would be greatly appreciated. Up to this point, the tutorial has been much smoother than others, and I think that the server will work great once I get this worked out.

        1. Avatar for James A. Chambers

          Hey Luke,

          I think you’ll have to set it lower. We’re getting to the point where you simply can’t run the latest Minecraft server versions with 1GB of RAM. The requirements go up every version basically. The problem is you don’t have 1GB of RAM free. You only have 1GB of RAM for *everything*. If you set it to 600M and you don’t have 600M of RAM free there won’t be any room for anything else to run and the whole system will go down.

          You may need to edit start.sh manually to set it lower. Look for the very last line in the script. It will have a:

          screen -dmS minecraft dirname/minecraft/jre/bin/java -DPaper.IgnoreJavaVersion=true -jar -Xms400M -Xmx600M dirname/minecraft/paperclip.jar

          The one you will change is the Xmx600M. Try setting it lower than 600M. I’d try 550, 500, etc.

          You also probably won’t be able to use the desktop version of Raspberry Pi OS. If you have a desktop version installed on that Pi you will probably have to switch it to the CLI only version. You just don’t have the RAM to run a full desktop environment.

          I would bet the Pi doesn’t have anywhere near 600M of free memory. You can check this pretty easily by typing:

          free

          If it’s not the server version you’ll probably have almost nothing available. You want to look in the “available” column and not the “free” column as the “available” space can still be used. There’s a minimum amount of RAM the server requires. I would just try lowering it to 550, 500, as low as you can get it before it won’t launch at all. There is a minimum amount before it just won’t work though.

          It’s going to be a very tight squeeze if it does work. Running the Lite CLI only version I would think you’d still be able to get it going. If you have a desktop installed and your free command says you have nothing free (or if anything else is running on the Pi at all) then it might be too tight of a fit. Even 3-4 years ago you had to run the Raspberry Pi OS CLI / Lite on boards with only 1GB of RAM. Today I’m sure it’s a requirement to have even a prayer of being able to still do this.

          You could also run an older version. That’s another way around this. I think we only expect 1.20 to require even more. Every update it seems to go up just a little bit.

          Hopefully that helps!

        1. Avatar for James A. Chambers

          Hey Luke,

          Excellent, that sounds fantastic! It’s great to hear it’s still running well on the Pi 3 as I’ve heard from others running 1GB devices (even 1GB Pi 4s) that have been squeezed. They too were able to get it going if I remember correctly. I just know it gets a little harder each update and that people have to be more and more careful with their memory budgets.

          If it’s running pretty comfortably now then you’ll probably be fine for quite some time still.

          Enjoy and take care!

          1. Avatar for Luke

            Thanks for the quick replies and excellent article. I also managed to install Geyser and Floodgate in spite of being a technology novice, and it was good for a laugh to have everyone try joining. I haven’t actually tried using worldborder yet as the version from bukkit.org was outdated and caused problems so I had to remove it. I will see if using the new one improves performance. Otherwise, it was still worth it to put an old raspberry pi that was lying around into use and to learn a little bit about the linux command line in the process.

            1. Avatar for James A. Chambers

              Hey Luke,

              That’s fantastic, those are the best upgrades you can do! I actually have a Docker container available that has Geyser+Floodgate preinstalled. I’m not sure if you’ve seen that yet but I couldn’t be a bigger fan of such a setup!

              For performance improvement the biggest improvement you can do is to use a SSD. You may be doing this already but if not then I/O (storage) is definitely the major bottleneck on the Pi.

              Thanks for your comment and take care!

          2. Avatar for Luke

            I do have one question now that things are working. Do I need to back up the server or does that happen automatically (at shutdown or other times). Thanks.

            1. Avatar for James A. Chambers

              Hey Luke,

              Great question! So the backups are done automatically each time the server starts. It keeps 10 backups and they are stored in the “backups” folder of your server folder. These can be used to completely restore the server.

              It’s definitely worth pulling some of the backups out of the folder from time to time and keeping them somewhere safe. The backups are basically just a compressed archive of your server folder so it’s safe to just extract a backup over a fresh install for example to restore it.

              Hopefully that helps!

  3. Avatar for Eric E. Rudolph
    Eric E. Rudolph

    I was trying to optimize my server using your steps though once I installed “screen” on my Pi 3 (1GB ram) I got some JRE issues on install for missing files and the server hasn’t worked since. I removed screen, updated Java – nothing works anymore.
    There is insufficient memory for JRE to continue
    Mmap failed to map 419430400 bytes for committing reserved memory

    1. Avatar for James A. Chambers

      Hey Eric,

      Can you try running a couple of memory related commands? Let’s try ‘free’ and ‘cat /proc/meminfo’. It looks like the server is only trying to reserve about 400MB of memory which is pretty reasonable on a 1GB Pi. If you have plenty of free memory available (more than the 400MB) then it probably is the JRE that is messed up.

      There may be multiple versions of Java installed. Use this command to check which ones you have:

      sudo update-alternatives --list java

      If it looks like it’s using the wrong version or an old version you can change which one it uses with:

      sudo update-alternatives --config java

      Select the latest version for the list and run the server again.

      There’s one more case it could be, and it’s definitely possible what you described. If your Java installation is corrupted somehow, I recommend purging it with

      sudo apt purge yourjavapackage

      If you aren’t sure which Java packages you have installed try searching with:

      sudo apt search java | grep installed

      Purging removes left behind configuration and other files and is good for cleaning out broken installations. sudo apt remove does not clean up these remnants and it sounds like they need to be removed.

      1. Avatar for Eric

        Thanks I did some of this before your post. I purged all java and reinstalled — got it working again — though I could set a higher memory threashold for the server prior — it could have been since I updated the OS it required more memory now. I created a 2Gb swap space on my SD card for some wiggle room.
        Thanks!

  4. Avatar for Manu

    Hi, thank you for the scripts!
    They have been a huge help for me.
    I’m using a pi with 4gb of RAM, but I can’t use all the memory avaible for a single process because Raspbian is a 32bit OS.
    Do you know about other 64bit OS where I can overclock, and make a headless ssh connection as easily as raspbian?

    1. Avatar for James A. Chambers

      Hey Manu,

      That’s absolutely correct about 32 bit not being able to address all the memory to a single process. However, there is some good news. There’s actually a 64 bit beta version of Raspbian! This is a pretty recent development.

      You can get it here.

      This should have all the features you’re looking for and used to since it actually is official Raspbian in 64 bit. Be advised it’s a beta so there might be bugs!

  5. Avatar for Antonio

    Hi,

    when i try to connect to my localhost, i get this error:

    com.mojang.authlib.GameProfile@7bb9f1[id=,name=myName,properties={},legacy=false] (/127.0.0.1:36580) lost connection: Disconnected

Leave a Comment

Your email address will not be published. Required fields are marked *

Type here..

Exit mobile version