Raspberry Pi Minecraft Server Setup Script w/ Startup Service

Minecraft 1.16 Nether Update
Minecraft 1.16 Nether Update

***UPDATE 10/19/2020 – Minecraft 1.16.3 is here! PLEASE make sure you have full backups of your server before attempting to upgrade your server. If you read the older comments you will see that weird things can happen with version upgrades sometimes. 1.15 was an absolute mess at first and a few people without backups in the comments wanted to roll back and had some serious regrets.

1.16.3 has been a very stable experience and is working well. It’s safe to upgrade as long as you’ve made backups!
***END UPDATE

Minecraft 1.16.3 (Nether Update) is here! 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.

Features

  • Sets up fully operational Minecraft server in a couple of minutes
  • Raspbian / Ubuntu / Debian distributions supported
  • Installs and configures OpenJDK 11 (or higher if available)
  • 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 version when server is started
  • Easy control of server with start.sh, stop.sh and restart.sh scripts
  • Optional scheduled daily restart of Pi using cron
  • Optional configuration of video memory to 16MB (default 64MB) and overclocking MicroSD reader to 100Hz (default 50Hz) for maximum performance

Requirements

  • Raspberry Pi model with 1 GB of RAM or higher. Basically a Raspberry Pi 2B or higher. (No Zero unfortunately, 512MB is not enough RAM to do this, I’ve tried!)
  • Headless Linux distribution such as Raspbian Buster Lite, Ubuntu Server 18.04.2, or any Debian based distribution (GUI distros can be used at the expense of available RAM and server performance)
  • Solid state drive highly recommended but not required.
    You can get a SSD setup on a Pi for less than most Micro SD cards cost. See my article here for details
  • If using MicroSD you want to be using a high range card otherwise you will really be hurting on IO when the server is reading/writing chunks of terrain! Click here for MicroSD card benchmarks/recommendations.

Recommended Gear

Raspberry Pi 4 Model B 8GB

Raspberry Pi 4 8GB

StarTech 2.5″ SATA to USB 3.0 Adapter -AND- Kingston A400 SSD 120GB SATA 3 2.5” Solid State Drive

Kingston A400 SSD

Or for a compact setup: SanDisk Extreme Pro 128GB USB Solid State Flash Drive

SanDisk Extreme Pro 128GB USB SSD

Best benchmarking Micro SD card: SanDisk Extreme 64 GB MicroSD Card

SanDisk Extreme A1 MicroSD Card

Choosing a Linux Distribution

The most important consideration when choosing which flavor of Linux to run the server on is simple: available RAM. Headless Linux distributions such as Raspbian Lite that don’t have a built in GUI have

Our biggest obstacle when running a Minecraft server on the Pi is available RAM since 1 GB is extremely low for this type of server. To have a playable experience you should not be running anything else on the Pi so all memory is available to be used.

After testing on many different distros I am finding Raspbian Lite and Ubuntu Server 18.04.4 32-bit to be the best choices. These distributions come with very few background processes and have rock solid support and performance.

64-bit vs 32-bit

There’s a lot of discussion in the Pi world about the up and coming aarch64 64-bit distributions vs. armhf 32-bit distributions. They have been and continue to improve dramatically. There are already use cases where 64-bit is far superior such as video encoding, advanced compression, etc.

So how about for running a Minecraft server? I have been testing extensively with Ubuntu Server 18.04 64-bit and the Debian Buster 64-bit. I have consistently had worse performance and stability than on 32-bit versions of the exact same distros.

But how can that be? It’s certainly true that Minecraft servers benefit in CPU performance from 64-bit versions of Java. The answer is actually incredibly simple: memory. The server running on a 64-bit Java Virtual Machine uses a minimum of about 100 MB more memory. This makes perfect sense because 64 bits > 32 bits by definition!

The Raspberry Pi’s 1 GB of memory has been the biggest obstacle for this project since the very beginning. Back when I first went into the Paper Minecraft developer IRC room and told them what I was trying to do I was practically laughed out of the chat room for even thinking of trying this. Most Minecraft server branches including vanilla can’t even start on the Pi because of the limited memory.

For a dedicated Minecraft server on the Pi I very highly recommend staying 32-bit. You will have more available memory which means it will be much faster and more stable. Since memory is our bottleneck the increased CPU throughput does not help us and losing *any* of our memory is disastrous!

If the Raspberry Pi 4 has more memory like we all expect it to this recommendation will change completely. Even 2 GB of memory would make the extra memory that 64-bit uses a non-issue and the CPU throughput performance gains very desirable. For now though stay 32-bit for a Minecraft server!

Tested Distributions

Raspbian Lite – It’s Raspbian. It has very low memory usage and is the official distribution of the Raspberry Pi. The server runs very well on this. It’s overall the best choice. The Buster release has made OpenJDK 11 available on it so it’s no longer behind the rest of the distros.

Ubuntu Server 18.04.3 – Ubuntu Server is my favorite Linux distro. I use it for nearly all of my projects. The performance of the 32-bit armhf version is on par with Raspbian. It’s a great choice! Click here for my Ubuntu setup guide for Raspberry Pi. The 64-bit version is not a fantastic choice and not recommended because of the higher memory usage. Stick with 32-bit and you’ll be a happy camper with Ubuntu Server.

Debian Buster 64-bit – Debian is the distribution Raspbian is based on. This version is a preview of Debian “Buster” which is the successor to Stretch and will be the next version of Raspbian when it is released. I like this distribution but it is currently still unofficial and unsupported. Performance and stability was less than Ubuntu and Raspbian.

Benchmark Your Storage

Make sure your storage is running fast enough to be an effective Minecraft server. I wrote a benchmark for this purpose to make this extremely easy. To get accurate results make sure nothing is running when the benchmarking is taking place.

Run the benchmark by pasting/typing:

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

Ideally you will score around 1000 for a good quality Micro SD card (and much higher for solid state storage). A low score (< 700) here indicates here that it is probably time to upgrade to a solid state drive or a faster Micro SD card. Click here to view all the existing benchmarks.

You can still run the server if you’d like with a low storage score but be advised when operations like saving the server’s blocks take place the people online may experience quite a big of lag!

Installation

SSH into your Raspberry Pi and paste the following commands:

wget https://raw.githubusercontent.com/TheRemote/RaspberryPiMinecraft/master/SetupMinecraft.sh
chmod +x SetupMinecraft.sh
./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.

“Enter amount of memory in megabytes to dedicate to the Minecraft server” – The amount of memory that will be dedicated to the Minecraft server. The more the better, but you must leave some room for the operating system background processes.

If you exceed the total available memory either the server will crash or the Pi will get incredibly slow to the point where your SSH session will start timing out. The setup script will make a recommendation to you which is your available memory – 10% for headroom. If you aren’t sure what to put just go with the recommended amount.

Note for Raspberry Pi 4: Currently on 32-bit Raspbian 2700 MB is the maximum that Linux will let us allocate in a 32 bit environment. The script has been updated to check for this as the server will not start if it is set over 2700M on a 32 bit server. 64 bit operating systems will be able to allocate all available memory as Pi 4 support rolls out for them.

“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 backs up the server and updates to the latest version. See the “Scheduled Daily Reboots” section below for information on how to customize the time or remove the reboot.

That is it for the setup script. The server will finish configuring and start!

Check Java Version

Sometimes if you have multiple versions of Java installed the wrong version of Java will be selected as the default. If the server didn’t start check that the right version of Java is selected with this command:

sudo update-alternatives --config java

If you get the message “update-alternatives: error: no alternatives for java” then you only have one version of Java installed and can skip to the next section.

If you are presented with a list of choices then your machine has multiple versions of Java installed. It will look like this:

update-alternatives: warning: /etc/alternatives/java has been changed (manually or by a script); switching to manual updates only
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1101      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1101      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

You will usually want to just select the newest version of OpenJDK that is listed so you would type 0 and press enter. In some cases on some platforms you may want to switch to the official Oracle JDK although I strongly recommend sticking with OpenJDK!

First Run

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.

Changing Minecraft Server Version

If you want to change which version your Minecraft server is running it can be changed by opening SetupMinecraft.sh with any text editor (example: nano SetupMinecraft.sh).

Change the line Version=”1.15.1″ to whichever Minecraft server version you want to run. Note that that version must already exist for Paper Minecraft. You can view all available versions at the following URL:

https://papermc.io/api/v1/paper/

Changing Minecraft Client Version

If you are wisely running the “stable” branch instead of the “development” branch there will be times where you need to select the version of Minecraft to run otherwise you will get an error message that your client is outdated when you try to log in.

Fortunately this is very easy. Open up the Minecraft launcher and instead of hitting “Play” choose “Launch Options” in the menu at the top of the window. It will look like this:

Minecraft Launcher “Launch Options” Tab

Click the “Add new” button and pick which version you want to add. You can optionally gave it a name or just click save.

Now when you go back to the “News” tab you will see a dropdown arrow where you can select which version of Minecraft you want to play!

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:

cd ~/minecraft
./start.sh
./stop.sh
./restart.sh

-OR-

sudo systemctl start minecraft
sudo systemctl stop minecraft
sudo systemctl restart minecraft

Automatic Backups

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:

cd ~/minecraft/backups
ls

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:

cd ~/minecraft
./stop.sh
rm -rf world world_nether world_the_end
tar -xf backups/2019.02.15.22.06.30.tar.gz
./start.sh

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.

Scheduled Daily Reboots

The daily reboots are scheduled using cron. It’s very easy to customize the time your server restarts.

To change the time that the server restarts type: crontab -e

This will open a window that will ask you to select a text editor (I find nano to be the easiest) and will show the cronjobs scheduled on the Pi. The Minecraft one will look like the following:

0 4 * * * /home/ubuntu/minecraft/restart.sh

There are 5 fields here. The default restart time is set to reboot at 0 minutes of the 4th hour of the day (4 AM). The other 3 fields are left as * to represent every day of every month. Make any desired changes here and press Ctrl+X to exit nano and update the cronjob.

To remove the daily reboot simply delete the line and save.

Installing Plugins

The server supports plugins that are compatible with Bukkit / Spigot / Paper. A popular place that you can get plugins is at where there are thousands of them!

To install a plugin you simply download the .jar to the minecraft/plugins folder and restart the server. For example, WorldGuard is a very popular plugin that lets you add protection to different areas of your server.

To install this plugin on our Minecraft server we would use the following commands:

cd ~/minecraft/plugins
wget https://dev.bukkit.org/projects/worldguard/files/latest
sudo systemctl restart minecraft

The server will restart and the plugin will be installed. It’s that simple! To use the plugin refer to the documentation on the plugin download page to find out which commands you use to configure/interact with it.

Warning: be advised that plugins are the #1 issue for performance degradation on Minecraft servers. This isn’t because all plugins are bad. Some plugins are coded very inefficiently or perform features that require a lot of hooks in the code.

You should be careful about what plugins you install on the server and if you start having bad performance disable your plugins one by one until you find the culprit!

Reconfigure / Update Scripts

The scripts can always be reconfigured and 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.

Running SetupMinecraft.sh again will also give you a chance to reconfigure options such as the memory dedicated to the server, daily reboots, starting the server on boot, etc.

This will not overwrite your world or any other data so it is safe to run!

Port Forwarding

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.

Upgrading

PLEASE BACK UP YOUR SERVER FIRST! The server makes automated backups by default for you in the backups folder but I recommend you back up the entire server folder yourself (basically the entire minecraft folder) any time you attempt to upgrade or downgrade. If you need to roll back to older versions it won’t work without a backup from that version or older!

The easiest way to upgrade an installation is to download the latest SetupMinecraft.sh and run it. This will automatically upgrade you to the latest version.

Upgrading and downgrading to versions that aren’t the default the script chooses is pretty simple. Simply change the Version line at the top in the SetupMinecraft.sh script:

#!/bin/bash
# Minecraft Server Installation Script - James A. Chambers - https://www.jamesachambers.com
# More information at https://jamesachambers.com/raspberry-pi-minecraft-server-script-with-startup-service/
# GitHub Repository: https://github.com/TheRemote/RaspberryPiMinecraft

# Minecraft server version
Version="1.16.1"

Edit this file in your favorite text editor (you can use nano or vi on the Pi like nano SetupMinecraft.sh) and change the Minecraft version to what you want.

Downgrading

PLEASE RESTORE USING A BACK UP FROM THE VERSION YOU ARE DOWNGRADING TO

If you are having problems on a newer version of Minecraft and want to downgrade you can do so using a complete backup of your server before you ran it on a newer version.

The reason you can’t take server data that has been touched by a version such as 1.16.1 and go back to 1.15 is that the new version adds all sorts of new data types/structures for the new content into your server data files. If you try to roll back the old versions of the Minecraft server will not understand these data types since they didn’t exist in that version and will crash.

As long as you use a backup for your server files from that version (or older) it’s as simple as changing the version in SetupMinecraft.sh just like I show in the “Upgrading” section.

You can upgrade any old version of Minecraft to any version, but again make sure you have a backup first as it is a one way street and you will need that backup if you want to roll back!

Version History

To view the version history check out the GitHub README here:

https://github.com/TheRemote/RaspberryPiMinecraft#update-history

438 thoughts on “Raspberry Pi Minecraft Server Setup Script w/ Startup Service”

  1. Avatar for Michael

    Great instructions. Thanks for the update. I have 2 questions….

    1. Should I run wb world fill…is there added benefit from this?
    2. Whenever there is 1 person in the world and they disconnect the server shutdown. Any thoughts why?

    1. Avatar for jamesachambers

      Hey Michael,

      These days on a modern Pi I usually don’t bother pregenerating with a world fill anymore. Like on a good Raspberry Pi 4 (like a 4-8 GB one) it can keep up well enough to not have to pregenerate. The exception is if you are planning on having more than a few people playing at once or if your Pi / storage is on the older side. Then pregenerating will take a *lot* of load off if there’s going to be more than a few people.

      Your second question is a bit curious. Have you installed any plugins or changed anything from the default configuration? Because I don’t think there’s any such functionality actually built in. Have you tried keeping the server window opened and logging out to see if there’s any red text or messages? It almost sounds like an error to me when someone logs out, like maybe when it’s trying to save their data, are they in the same spot they logged out at when they log back in after the server is restarted?

      Did you happen to install the WorldBorder plugin? Because I think that the creator stopped working on that one so if you installed that plugin it might be too old of a version and be crashing the server. If you did install it go ahead and remove WorldBorder.jar from the plugins folder as that would almost certainly be why. I’ll add an update in that WorldBorder isn’t being updated again as I could definitely see this causing some trouble!

  2. Avatar for Robbin Veldboer

    Hi!

    It seems that when I reboot the minecraft server on Ubuntu (Raspberry 4 8 RAM), without waiting at least 15 minutes after removing the power supply, the minecraft server becomes very laggy (and this does not improve over time). However, when I remove power from the Raspberry and wait +/- 15 minutes before restarting it, there is no problem whatsoever.

    What can cause this problem?
    And is there a possibility to delay the startup of the server for 15 minutes after it is powered up?

    Thanks in advance!
    Gr.
    Robbin Veldboer

    1. Avatar for jamesachambers

      Hey Robbin,

      That’s pretty unusual on a 8GB Pi. Even 4GB Pis have performed much better than that for a long time and usually stop lagging after about 1-2 minutes. The 8GB Pi for me stops lagging around 30-60 seconds after startup for me (in recent tests on 1.16.3 with some friends).

      My first thought is to check your storage. Do you have any alternative SD cards or SSDs? Also, was this a fresh install on your Raspberry Pi of your OS or does it have other things running/installed as well?

      A good test would be to do a fresh image on a different SD/SSD and do a quick test and see if it lags in the same way. Copy your existing Minecraft folder over from your original server after doing a quick test Raspbian image on the alternative media. It may be worth testing without your original server as well with this test environment (just remove the folder and let it create a fresh one, or do this test first before you copy the old server over) as that will help you narrow down if it’s something specific on your server (some things can be built that lag it extensively) or if perhaps your storage device or Raspbian install is having issues!

      I can definitely tell you something is wrong if you’re having to wait 15 minutes to get a stable experience so these steps will just help to narrow down what that is. I’ve been doing a server with about 4 friends for the past month and after things like the daily reboot it only takes about 30-60 seconds before it is completely stable for 3-4 people. My Pi I’m using is a Raspberry Pi 8GB and just a standard 64GB Samsung Evo Plus (red label) SD card (not using a SSD yet at this time on it, I wanted to see how fast it would be on SD).

      Let us know what you find and we will try to help further if possible!

      To answer your original question, it’s possible to add a startup delay. You can edit /etc/systemd/system/minecraft.service like this:

      sudo nano /etc/systemd/system/minecraft.service

      We are going to add the following line in right before the ExecStart= line:

      ExecStartPre=/bin/sleep 30

      This would make the service wait 30 seconds. You can adjust this to a longer delay as the # is just the number of seconds.

      The complete service would look like this:

      [Unit]
      Description=minecraft server service
      After=network-online.target

      [Service]
      User=pi
      WorkingDirectory=/home/pi/minecraft
      Type=forking
      ExecStartPre=/bin/sleep 30
      ExecStart=/bin/bash /home/pi/minecraft/start.sh
      ExecStop=/bin/bash /home/pi/minecraft/stop.sh
      GuessMainPID=no
      TimeoutStartSec=600

      [Install]
      WantedBy=multi-user.target

      IMPORTANT NOTE: After changing this service you need to run a special command to let the system know the service needs to be updated. After you finish making the edit press Ctrl+X then Y to save the file and issue the following command:

      sudo systemctl daemon-reload

      If you don’t do this step the system won’t start up the process and if you do a sudo systemctl start minecraft you’ll get an error saying the service changed. This command lets the system know we updated the service on purpose and to accept the changes!

      -James

    2. Avatar for Robbin Veldboer

      Dear James,

      Thank you very much for your detailed answer!
      I tried adding the ExecStartPre = / bin / sleep 30 script to startup (as described).
      Unfortunately the server did not start at all after I added this script.

      Regarding the SD card: I have already tried two SD cards, I have also used your test script and the SD card I am currently using should be sufficient.

      Just to be clear:
      The server will not become stable if the server is already on and the entire Raspberry Pi 4 is rebooted.
      Only if you turn the power off and wait at least 15 minutes (to let it cool down) before turning it back on, you will get a stable connection.

      Is it possible that Ubuntu 20.04 is downgrading computing power when the hardware is a bit hot (65 degrees Celsius) at boot?

      I also have a Philips Hue system. Maybe I can use one of their sockets to remove power for at least 15 minutes after the Raspberry Pi automatically reboots at 4am (strange solution though …)?

      Gr.
      Robbin Veldboer

    1. Avatar for D.

      You can try (and then write back), but really running anything else along with a minecraft server on a pi will slow everything down (the minecraft server and whatever else you are trying to run). Maybe a pi4 with 8GB would be ok, but limiting other things running on the pi is advised.

  3. Avatar for Fionn O

    Hey James,

    Great shell script and article!!

    I have made a fork and pull request to your github repo for a few changes to the shell script.
    The main thought is that it allows the user to decide which version of paper-MC they would like to install and run, checks that there is an available distro, updates start.sh, and then d/l’s and runs that version.

    I have also written a tiny extra script called update.sh which, when run, will allow the user to change the version of paper-MC running on the raspi and update start.sh once again.

    I have tested these scripts pretty rigorously and they are solid, all potential user errors are handled with loops for graceful correction.

    Thanks,

    Fionn O’Connor
    (outInsideOut)

  4. Avatar for Cesar Pimentel

    Everytime I try to wget a plugin from Bukkit’s servers I get a 403 Forbidden error; any ideas what might be happening?

    1. Avatar for D.

      They have Cloudflare protection turned on. You’ll need to download via a web browser and then sftp/copy the file over to your pi.

  5. Avatar for Patrick

    It may be a good idea to update the 32bit / 64bit section to include more info about the Pi4 now that it is widely available and there is an 8 GB version. Should be able to run Ubuntu 20.04 64 bit or the beta Raspberry Pi OS 64 bit without issues.

      1. Avatar for Patrick

        I more meant that the original instructions listed above still advise NOT running the 64 bit version and to wait for the Pi 4, which has been out for a while now.

        As written:

        “64-bit vs 32-bit
        There’s a lot of discussion in the Pi world about the up and coming aarch64 64-bit distributions vs. armhf 32-bit distributions. They have been and continue to improve dramatically. There are already use cases where 64-bit is far superior such as video encoding, advanced compression, etc.

        So how about for running a Minecraft server? I have been testing extensively with Ubuntu Server 18.04 64-bit and the Debian Buster 64-bit. I have consistently had worse performance and stability than on 32-bit versions of the exact same distros.

        But how can that be? It’s certainly true that Minecraft servers benefit in CPU performance from 64-bit versions of Java. The answer is actually incredibly simple: memory. The server running on a 64-bit Java Virtual Machine uses a minimum of about 100 MB more memory. This makes perfect sense because 64 bits > 32 bits by definition!

        The Raspberry Pi’s 1 GB of memory has been the biggest obstacle for this project since the very beginning. Back when I first went into the Paper Minecraft developer IRC room and told them what I was trying to do I was practically laughed out of the chat room for even thinking of trying this. Most Minecraft server branches including vanilla can’t even start on the Pi because of the limited memory.

        For a dedicated Minecraft server on the Pi I very highly recommend staying 32-bit. You will have more available memory which means it will be much faster and more stable. Since memory is our bottleneck the increased CPU throughput does not help us and losing *any* of our memory is disastrous!

        If the Raspberry Pi 4 has more memory like we all expect it to this recommendation will change completely. Even 2 GB of memory would make the extra memory that 64-bit uses a non-issue and the CPU throughput performance gains very desirable. For now though stay 32-bit for a Minecraft server!”

    1. Avatar for RYAN A JONES

      I’m running the Raspbian 64 bit OS but I’ve noticed my Mindcraft Server (created with this sop) is still running 1.16.1. I’ve tried changing manually without success.

      1. Avatar for D.

        Stop the minecraft server with:
        ./stop.sh
        Edit SetupMinecraft.sh script with:
        nano SetupMinecraft.sh
        change the version line to the version you want. Currently the latest version is: 1.16.3
        Close out of nano and save. (Ctrl-X and then y)
        You need to rerun SetupMinecraft.sh which will update the other scripts (start, restart) with the new minecraft version, so:
        ./SetupMinecraft.sh
        (answer the memory, restart, etc questions as you did upon initial setup).
        After completing the SetupMinecraft.sh screens, the server should be version 1.16.3
        Make sure your Minecraft client is on the same version.

    1. Avatar for Max Kuhlmay

      RetroPi is a totally different OS which contains emulators for some old consoles.

      Your kid doesn’t need to understand Raspberry OS (the new name).
      You install the server on the Pi and you can connect to the server via a PC, you don’t Play Minecraft directly on the server.
      You could connect a controller to your pc but you have to google for how to do this.

    2. Avatar for D.

      I believe Max meant to reply to Adriano down below. Anyway… yes you can use this for a previously created minecraft world. You would need to copy the Minecraft saves folder for the world you want, into the minecraft folder on the Raspberry Pi. My steps would be:
      1 – Setup Raspberry Pi utilizing James’ script with the same version of the previously created minecraft world and stop Minecraft.
      2 – Delete the world folders from the minecraft folder on Raspberry Pi (I think the default world name is called “new_world” and the other folders will end with “_the_end” and “_nether”).
      3 – Copy the previously created world folder into the Minecraft folder on the Raspberry Pi, update the server.properties file’s “level-name” setting.
      4 – Start minecraft server on Raspberry Pi.
      5 – Cross fingers.

      (PaperMC will split the previously created world folder into the necessary three folders.)

      1. Avatar for D.

        Just a note if you do change your world name to something other then “world”, the automatic backup will not work.

        The start.sh script looks for a directory called “world”, if it can’t find one it doesn’t start. You can either change your world name to world, or edit the start.sh script at:

        # Back up server
        if [ -d “world” ]; then

    3. Avatar for Daryl Dawkins

      I just finished testing this as I had a minecraft server on a linux x86_64 box that my kids have been creating in for a while. I literally just tar the minecraft folder on the linux server, copied it to to my Pi4 4GB, uncompressed, installed JDK 8 for ARM from oracle and fired it up and to my surprise it booted and I was able to log in but it would crash immediately. I restarted it with -Xmx2048M -Xms2048M and it has been stable so far.

  6. Avatar for Adriano

    Is there a way to:
    1 – install it in retropie (my kid is too young to use raspberry pi os)
    2 – use a controller instead of keyboards/mouse (my kids is too young to use keyboard/mouse too lol)

  7. Avatar for rjdapirate

    We are hosting two Raspberry PI4 4gb Minecraft Java Servers in our home. I’m trying to prove a point to my 13 yr old son. His version is running on 32 Raspbian where mine is on the 64 beta. I know that one of them needs to have their forward port change to 25566 instead of the default 25565 but I cannot for the life of me figure out how to get into “setupminecraft.sh” to make the change. Please advise.

    1. Avatar for jamesachambers

      Hey Patrick,

      That sounds great! I’ll check it out as I have some work to do on the scripts and that would be a good section to rewrite since WorldBorder isn’t working anymore.

      -James

  8. Avatar for Kooshy

    Hi James,

    Thanks for all the work you do, your setup guides and scripts have been great to work with and very informative. We currently have an RPi4 (4Gb) SDCard running a 1.16.1 minecraft server beautifully and is perfect for the family and friends. Thanks!

    One idea: It would be great to include some method of limiting the number of backups retained in the setup script. We’ve filled the SD card and caused issues (we’ve also pre-generated a world large enough with WorldBorder to require the systemctl timeout to be adjusted on the service startup) I’ve currently implemented something similar to jeff’s zsh suggestion from here: https://unix.stackexchange.com/questions/480898/keep-only-a-certain-amount-of-backups-tarballs-in-a-directory
    and it works well. My concern is if your script is updated, my changes will vanish and need to be constantly re-added.

    On another note: We currently have an NVME, and RPi4 (8Gb) on the way and I’m curious to explore any performance increases we’ll see with both Mass Storage Boot off the NVME as well as running PiOS 64b. Exploring this will give my kids and I more to tinker with during pandemic lockdown. Have you tried 64bit OS yet with an 8Gb Pi? Any thoughts? Warnings or Gotcha’s to watch out for? Got a beta script you need testing 😉

    Thanks Again!
    -Chris

    1. Avatar for D.

      Could you put your “limiting backups script” into a separate bash file, and then run that bash file via cron before the restart script runs? In that way your script won’t be replaced when you update.

      How big was your pre-gen using WorldBorder? I had problems using WorldBorder. It was slow and would crash. I’m not sure if I set it too large or something (I think my setting was 10000… I moved my world to a full fledge computer to run it with that setting), though I had also been in the world for a while, so maybe that caused issues too. I found Chunkmaster, another pregen plugin, to be great (and still updated). Ran a 1000 border pregen with it on a Rasp3b, it was able to complete in a little under 2 hours (and mere minutes on my main computer).

      1. Avatar for Kooshy

        I initially did a pregen of an 8000 block radius. With default commands the pi would run out of memory and crash, so I set the rate of generation to 5 blocks per second/tick/whatever (rather than fastest possible) and let it cook overnight and throughout most of the next day. I think slowing it down gave the Pi time to clean up / manage its memory and it didn’t run out. The trouble with a world that big is that it takes 20-30 minutes to backup, and the backup script is executed during server startup, making server boots annoyingly slow when troubleshooting. I’ve since trimmed the world to a 5000 block radius and the world directory is significantly smaller. Your idea of setting it as a separate cron job is a good one and I might go that route, my main reason for mentioning it here was that many others might benefit from limiting the number of backups in a directory and was honestly hoping someone would say you don’t need zsh for that…do it this way with one less dependency! Hehehe. I’ve finally received the new 8Gb Pi yesterday, but so far… I took it out of the box to look at it and thats it. Going to have to start tinkering with it soon. (8Gb RPi w/ 500Gb NVME SSD and potentially a 64bit OS…fun fun fun)

  9. Avatar for Kevin

    I want to choose in which directory I want the server to be installed. It’s now always installing it in the /home/ directory. Is this possible?

    1. Avatar for jamesachambers

      Hey Kevin,

      You’re the second one to request it in the past few days, so I’m going to make it possible! I’ll update the script to let you specify the installation directory.

      -James

      1. Avatar for Dave

        Happy to see this is getting done! I manually moved my Minecraft folder over from my MicroSD to my flash drive after installing (and changed all of the scripts along with it), but now I can’t update. Hopefully with this change I’ll be able to update my server! Thanks for all of the work you do, 4GB Pi server is running great!

  10. Avatar for Minecraftschurli
    Minecraftschurli

    What do I have to change in the script to install the server with a user “minecraft” in the /var/lib/minecraft directory (like other programs such as netdata do it)?

    1. Avatar for jamesachambers

      Hey Minecraftschurli,

      I haven’t tried it but theoretically you could do a find and replace of ~/ to /var/lib. I’d use an editor like VSCode or something that can search all files in a directory at once (or your favorite tool). You will want to get all files like start.sh, etc.

      I chose the home directory so it would be easy to find as it’s meant to be easily approachable for beginners. If you try this and experience problems let me know. I could definitely add a directory choice in there if other people are interested in this!

      1. Avatar for Minecraftschurli
        Minecraftschurli

        I found a bug (and PRed a fix for it on GH)!
        When the username contains “minecraft” the server won’t start because grep finds the username that is contained in the response of “screen -list”
        Also to have it in a separate user that user needs to be passwordless sudo because of this line in start.sh
        sudo sh -c “echo 1 > /proc/sys/vm/drop_caches”
        and this line in restart.sh
        sudo reboot

Leave a Comment

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

Type here..