Skip to content

Configuration files and performance testing scripts to setup and optimize a dedicated Minecraft (PC Java version) server

License

Notifications You must be signed in to change notification settings

TheRemote/RaspberryPiMinecraft

Repository files navigation

This script will automatically download and configure the Paper Minecraft server!
For the full article and guide visit https://jamesachambers.com/raspberry-pi-minecraft-server-script-with-startup-service/

Installation Instructions

To get started / install the server type:
curl https://raw.githubusercontent.com/TheRemote/RaspberryPiMinecraft/master/SetupMinecraft.sh | bash

Getting Help

To get help you may open an issue here or visit my web site at https://jamesachambers.com/raspberry-pi-minecraft-server-script-with-startup-service/ which contains lots of comments from myself and users helping each other out!

Changing Minecraft Server Versions

If a new version of Minecraft is out and the script hasn't been updated yet you can change it in the SetupMinecraft.sh script. If you use the command nano SetupMinecraft.sh it will be the first line in the file like this:

Version="1.18.1"
AllowLocalCopy="1"

Make sure to change AllowLocalCopy="1" to tell the script you want to actually run the local copy instead of the latest version.
Note that for this to work the Paper Minecraft server must also have released the latest version or the download will fail. You can check here: https://papermc.io/downloads

Tested Distributions

  • Raspberry Pi OS - Bullseye/Buster/Stretch
  • Ubuntu / Ubuntu Server 22.04 / 21.10 / 20.04 (LTS)
  • Debian 11 Bullseye / Debian 10 Buster / Debian 9 Stretch
  • Arch Linux
  • TinkerOS Stretch

Troubleshooting Note - Oracle Virtual Machines

A very common problem people have with the Oracle Virtual Machine tutorials out there that typically show you how to use a free VM is that the VM is much more difficult to configure than just about any other product / offering out there.
The symptom you will have is that nobody will be able to connect.
It is because there are several steps you need to take to open the ports on the Oracle VM. You need to both:
  • Set the ingress ports (TCP/UDP) in the Virtual Cloud Network (VCN) security list
  • *and* set the ingress ports in a Network Security Group assigned to your instance

Both of these settings are typically required before you will be able to connect to your VM instance. This is purely configuration related and has nothing to do with the script or the Minecraft server itself.

I do not recommend this platform due to the configuration difficulty but the people who have gone through the pain of configuring an Oracle VM have had good experiences with it after that point. Just keep in mind it's going to be a rough ride through the configuration for most people.

Here are some additional links:

Troubleshooting Note - Hyper-V

There is a weird bug in Hyper-V that breaks UDP connections on the Minecraft server. The fix for this is that you have to use a Generation 1 VM with the Legacy LAN network driver.
See the following links:

Buy A Coffee / Donate

People have expressed some interest in this (you are all saints, thank you, truly)

  • PayPal: 05jchambers@gmail.com
  • Venmo: @JamesAChambers
  • CashApp: $theremote
  • Bitcoin (BTC): 3H6wkPnL1Kvne7dJQS8h7wB4vndB9KxZP7

Update History

December 1st 2024

  • Upgrade to 1.21.3 (make backups first, and make sure you've copied backup out of the main backups folder as they are rotated)

May 19th 2024

  • Upgraded Java to OpenJDK 21
  • Upgraded default version to 1.20.6
  • 32 bit ARM is no longer supported -- make sure you are running a 64 bit OS to use 64 bit ARM (aarch64)

April 27th 2024

  • Upgrade to 1.20.5 (make backups first, and make sure you've copied backup out of the main backups folder as they are rotated)

January 4th 2024

  • Upgrade to 1.20.4 (make backups first, and make sure you've copied backup out of the main backups folder as they are rotated)

October 1st 2023

  • Upgrade to 1.20.2 (make backups first, and make sure you've copied backup out of the main backups folder as they are rotated)

March 16th 2023

  • Upgrade to 1.19.4 (make backups first, and make sure you've copied backup out of the main backups folder as they are rotated)

January 14th 2023

  • Change connectivity check from google.com to papermc.org to prevent blocking in some countries

December 9th 2022

  • Upgrade to 1.19.3
  • Upgrade to OpenJDK 19

September 20th 2022

  • Update to OpenJDK 18.0.2.1

September 11th 2022

  • Fix memory recommendation to allow a little bit more breathing room to prevent heap errors

September 4th 2022

  • Remove pointless and confusing automation code

September 2nd 2022

  • Fix tail warning message if there is no existing log file

August 26th 2022

  • Raise server startup timeout from 600 seconds to 1800 seconds to prevent startup failure when backing up large servers

August 10th 2022

  • Moved custom directories to the top of SetupMinecraft.sh to eliminate confusion about how to use the feature (and almost nobody should unless you are storing your server on a separate drive)
  • Improve JRE update detection in SetupMinecraft.sh

August 6th 2022

  • Upgrade to 1.19.2

August 4th 2022

  • Script now removes non-alphanumeric characters from the servername variable (to prevent using quotes and other symbols that will break it)

August 2nd 2022

  • Fix ARM link for Adoptium OpenJDK (thanks zqigolden, PR #42
  • OpenJDK will now detect if you have an older version than SetupMinecraft is installing (or a broken Java install) and reinstall the newest version

July 31st 2022

  • Upgrade Adoptium OpenJDK to 18.0.2 -- if you want to upgrade your Adoptium you can remove the ~/minecraft/jre folder and run SetupMinecraft.sh again to upgrade to the latest one

July 27th 2022

  • Update to 1.19.1 (always make sure you've copied some backups out of the backups folder first!)

June 15th 2022

  • Fix Paper 1.19 version upgrades (thanks Meganium97, issue #41)

June 11th 2022

  • Update to Paper experimental 1.19 release as default installation
  • Make sure you have backups of your server from your "backups" folder stored separately before upgrading
  • If you have problems with 1.19 you need to restore a backup to go back to 1.18 as it will not take your server data files on 1.18 once the 1.19 structures/data have been added
  • Change update.sh to /bin/bash instead of /bin/sh
  • Add PATH variable to update.sh

May 22nd 2022

  • Update OpenJDK installation paths

May 21st 2022

  • Switched from JDK to JRE to save space
  • Added Adoptium OpenJDK support for s390x and ppc64le architectures

May 16th 2022

  • Add -DPaper.IgnoreJavaVersion=true to allow OpenJDK 17 to run the older Paper Minecraft versions (thanks NotMick, issue #39)

May 15th 2022

  • Added screen -wipe to beginning of start.sh to prevent a startup issue that could occur if there was a "dead" screen instance (thanks grimholme)

May 11th 2022

  • Fix Adoptium arm and aarch64 OpenJDK links (thanks 407pilot, issue #38

May 10th 2022

  • Update Adoptium OpenJDK version
  • Add safety check for backups to make sure folder exists before pruning

May 8th 2022

  • Fixed a problem with restart.sh having a #!/bin/sh at the top which could cause restart.sh to run in a POSIX shell that doesn't recognize the [[ operator (thanks jmswan, issue #37

May 4th 2022

  • Fixed "route" command used to detect internet access to be compatible with Debian

April 24th 2022

  • Fixed mistake in new multicore compression (thanks pmcmorris) and related mistake in SetupMinecraft.sh dependency check

April 16th 2022

  • Remove "jre" folder if JDK installation fails so it will attempt to download a fresh copy upon running SetupMinecraft.sh again
  • Added support for the tar command to use multiple CPU cores instead of a single core. This should speed up backups and reduce instances of when it takes longer to back up than the server's startup time (thanks SudosFTW, issue #36)

April 6th 2022

  • Fixed issue that prevented detecting a broken OpenJDK installation
  • Added language headers to OpenJDK download

March 24th 2022

  • Dedicated OpenJDK 17 install is now used (stored in your server's directory) to avoid apt / snap issues
  • Create "logs" folder for new servers to avoid harmless error messages (cleanup)
  • Add new "jre" folder to backup command's ignore list to avoid bloated backups

March 23rd 2022

  • Removed snapd installation as the snapd repository will only install OpenJDK 18 or higher which won't work with Paper
  • Paper still does not support OpenJDK 18 and will give errors using a version that high
  • Working on a new more reliable method to install OpenJDK 17

March 23rd 2022

  • Removed obsolete requirement not allowing OpenJDK versions above 17 as Paper now supports this

March 5th 2022

  • Update to 1.18.2 -- make sure you have backups first if you are upgrading from an existing server!

December 12th 2021

  • Update to 1.18.1 -- make sure you have backups first if you are upgrading from an existing server!
Update_Sudoers

November 30th 2021

  • Update to 1.18 -- make sure you have backups first if you are upgrading from an existing server!

September 15th 2021

  • Update to allow OpenJDK 17 which is now the default "snap"

September 2nd 2021

  • Update to Paper Minecraft Server API v2

August 1st 2021

  • Fixed a missing -A parameter for a curl command (thanks davie2000, issue #27)

July 27th 2021

  • Added PATH variable to scripts to improve compatibility on some distros
  • Server now fixes permissions upon startup

July 21st 2021

  • Switched from wget to curl to fix spacing issues experienced by some users
  • Added error redirection to crontab line to help diagnose failures during scheduled restarts

July 19th 2021

  • Fixed an issue where SetupMinecraft.sh could throw an error if no Java version was installed

July 17th 2021

  • Fixed server name prompt
  • Added username missing to fix service issue
  • Reduced memory recommendation by 100MB to allow more space for the OS / other processes since newer versions of Minecraft are requiring more memory. Remember, if you don't leave enough memory for other things the Minecraft server will crash for memory issues, but it's because you set it too high (counterintuitive I know) and didn't leave enough for the OS and it killed your Minecraft server to prevent the entire OS from crashing.
  • Added in check to ensure start.sh and other scripts are not being ran as root. If this happens you have to use sudo screen -r to find the screen and the permissions will be wrong since root isn't the owner of the server files
  • If you know you ran the script/server as root (which starts creating files owned by root instead of the regular user) and your server won't start/is wonky run the fixpermissions script from your server folder with ./fixpermissions.sh and it will correct them for you!

July 15th 2021

  • Added safety check for path to server -- please use the default path of ~ if you aren't familiar with fully qualified Linux paths/directories -- you really don't want to change the safe defaults unless you have a really specific need.

July 14th 2021

  • Fixed a issue that was causing backups to not rotate (it should only keep 10). Thanks Olli

July 8th 2021

  • Update to 1.17.1
  • Update documentation to explain new AllowLocalCopy="1" flag. This flag tells the script not to run the latest online version and to run the local copy. You want to use this if you are changing the version or making any modifications to the script itself before running it.
  • Added update.sh convenience script that calls the latest version of SetupMinecraft.sh
  • Fixed a bug where having an OpenJDK greater than 16 was not triggering the snap configuration (usually only seen on the cutting edge Ubuntu flavors)

July 5th 2021

  • Fixed an issue with SetupMinecraft.sh saving scripts to the home folder instead of the minecraft folder (thanks Ryan A J.)

July 3rd 2021

  • Add option to choose a custom directory instead of forcing the home path

June 24th 2021

  • Removed installation of OpenJDK above OpenJDK 16 as the Paper Minecraft server is not working with versions higher than 16
  • If you have a higher version of Java installed use the following command: sudo update-alternatives –config java and select OpenJDK 16

June 19th 2021

  • 1.17 Release
  • Make sure you have backups and take copies of your backups and place them outside the Minecraft folder to be 100% safe
  • Once running the new version you can't go back to the old one without restoring a backup because it writes new stuff in your server the old version doesn't understand and crashes on
  • As long as you have backups you should be okay!

June 16th 2021

  • Raised minimum OpenJDK requirement to 16 in preparation for the 1.17 Paper Minecraft server release
  • If a new enough OpenJDK is not available in apt (Raspberry Pi OS is on OpenJDK 11 for example) it will be installed via snapd
  • If snapd is not installed it will ask you if you want to install it (reboot required) or abort
  • After the reboot run SetupMinecraft.sh again and it will finish installing OpenJDK 16! Be patient, it can take some time, even 10-15 minutes on a good connection and longer on a bad one
  • Sorry for the inconvenience, there isn't an easier way to get it until the Raspberry Pi OS apt repositories are updated!

June 12th 2021

  • Fixed syntax error (thanks aruthir!)

June 10th 2021

  • Added OpenJDK 17 and 18 placeholders for prerequisite installations
  • Added a fallback to the non-headless JRE for platforms that don't offer that metapackage
  • Paper Minecraft 1.17 is not yet available but should be soon. If you go to https://papermc.io/api/v1/paper/ and see 1.17 in the list it's available and you can change the version variable at the very top of SetupMinecraft.sh otherwise it hasn't been released yet. Should be soon!

March 22nd 2021

  • Lowered amount of recommended memory by a flat 200MB due to so many people having "Out of Memory" errors
  • Note: Nobody has ever really been "out of memory" on the Pi since like the Pi 1. The problem is you're using TOO MUCH.
  • If you're getting memory related crashes you need to turn your memory DOWN. The server will recommend lower amounts going forward.

March 16th 2021

  • Added backup rotation - server keeps the last 10 backups by default
  • If you want to change the amount of backups held it is located in the "start.sh" script with a comment of '# Rotate backups -- keep most recent 10'
  • This adds a little responsibility for saving really old backups but fixes the issue I and many others have had of the server getting filled with backups and crashing

January 31st 2021

  • Update to 1.16.5
  • Server now takes ownership of server files on each start to prevent folks a whole heap of trouble and heartache when restoring backups/moving files/etc.
  • Added check to make sure script isn't being ran as sudo to prevent installing to the /root folder

December 5th 2020

  • Update to 1.16.4
  • Fixed a bug where if your username on the Pi was Minecraft it would cause the script to break (thanks Minecraftschurli, pull request #20)
  • Fixed a bug that could cause OpenJDK 10 to try to be installed even if OpenJDK 11 installation was successful

September 25th 2020

  • Update to 1.16.3

August 28th 2020

  • Update to 1.16.2

July 4th 2020

  • Update to 1.16.1

January 25th 2020

  • Update to 1.15.2

December 28th 2019

  • Backup system now takes a backup of your entire server folder (minus logs and cache) instead of just the world folders. This mean it now backs up things like server.properties and other worlds if you are running a multiverse setup.

December 20th 2019

  • Updated to version 1.15.1
  • Added more information to script installation warnings to help with initial configuration
  • Added warning to 2700MB limit on 32 bit operating systems explaining that you can lift the 3 GB limit by using a 64 bit Pi distribution
  • Cleaned up Java installation in setup script

August 26th 2019

  • Fixed a silly bug causing recommended memory to be stuck at 2700

August 25th 2019

  • Improved server startup detection after running SetupMinecraft
  • Added terminal colors to improve visibility
  • Cleaned up script substantially by breaking out duplicate code to functions
  • Fixed issue where when reconfiguring an existing server you would not be prompted to configure daily reboots
  • Removed /boot/config.txt tweaks as they are no longer compatible with Pi 4

August 24th 2019

  • To prevent startup failure on 32bit ARM the maximum memory for the Minecraft server is capped at 2700MB. This is a per process limitation of 32 bit on ARM and Linux. This restriction can be lifted by using a 64 bit operating system.

July 19th 2019

  • Updated development version to 1.14.4
  • Added OpenJDK 13 support

July 2nd 2019

  • Removed bc dependency to improve portability

June 30th 2019

  • Raspberry Pi 4 support (all memory sizes)
  • Updated development version to 1.14.3
  • Fixed issue that could cause 1.13.2 servers to crash when going to the Nether

June 1st 2019

  • Added option to select stable or development version
  • Current stable version of the Paper Minecraft server is 1.13.2
  • If you want to install 1.14.2 you may select to do so during installation
  • Be aware that 1.14.2 continues to have severe performance issues for the entire Minecraft server/hosting community. After playing on it myself and talking to the Paper developers I can personally state that performance on 1.14.2 is really bad right now and highly recommend sticking with the stable version.

May 31st 2019

  • OpenJDK 12 and OpenJDK 10 package checks added into the script
  • Script will attempt to install OpenJDK 10 from package on Raspbian if it isn't in apt
  • Added many paper.yml, bukkit.yml and spigot.yml changes to server config files to help with the ongoing lag affecting all Minecraft servers in 1.14
  • To configure them open start.sh in nano after running SetupMinecraft and you will see the different options and what they do
  • Updated Java certificates installer link
  • Fixed bug where changing GPU memory wasn't being applied

May 30th 2019

  • Updated to 1.14.2

May 19th 2019

  • Updated to 1.14.1

April 18th 2019

  • Changed StopChecks++ to StopChecks=$((StopChecks+1)) to improve portability (thanks Jason B.)
  • Added TimeoutStartSec=600 to server to prevent it being killed if taking longer than usual to download paperclip

March 31st 2019

  • Added x86_64 support

March 9th 2019

  • Changed Paper download URL to use API (Issue #7 Fix)
  • Added \n to beginning of printf to config.txt to prevent adding our line to the end of another config line

March 7th 2019

  • Added support for OpenJDK 8 to improve portability
  • Added Armbian support
  • Tinkerboard platform now supported. Other Armbian capable boards should also work
  • Added ca
  • certificates
  • java OpenJDK 11 fix for a broken package on some platforms
  • Added checks for paper.yml and world backup folders before attempting to back up
  • Fixed portability issue with route vs /sbin/route

March 4th 2019

  • Shared GPU memory reduction and MicroSD overclock now supported on distros that use /boot/firmware/config.txt such as Ubuntu Server and Debian
  • Removed vcgencmd usage for portability to other distros
  • Added check for sudo for compatibility with more distros
  • Improved MicroSD clock detection
  • Setup now sets paper.yml option for watchdog warnings to wait until 120 seconds after the server starts to suppress excessive warnings

March 2nd 2019

  • Added a configuration option for memory to dedicate to the Minecraft server (along with a recommended amount)
  • Added support for Debian and Ubuntu Server Raspberry Pi distros
  • Server now installs OpenJDK
  • 11
  • jre
  • headless if it is available, otherwise OpenJDK 9 will be selected
  • Improved CPU architecture detection
  • Added sudo, net
  • tools, wget to server dependencies to improve portability
  • Removed absolute paths from scripts to improve portability
  • MicroSD overclock and GPU memory split config are now split if vcgencmd is not present (non
  • Raspbian systems)

February 18th 2019

  • The SetupMinecraft.sh script will now update all of your scripts to the latest version when ran and reinstall the startup service
  • Implemented a workaround for Java 9 installation since the ca
  • certificates
  • java package broke in Raspbian on the 16th

February 15th 2019

  • Server now starts correctly on Raspbian Full (Raspbian Lite still highly recommended due to more available memory)
  • Added network connectivity check before attempting to update server
  • skips update if no connection available to prevent .jar corruption
  • Service now waits up to 20 seconds for network connectivity before starting up to prevent service starting before server gets an IP address
  • Fixed typo in stop.sh that was causing server to say it wasn't running when it was
  • Removed unnecessary sleep time on stop.sh script so it returns as soon as the minecraft server closes
  • Added automatic backups performed when server starts (located in minecraft/backups)

February 9th 2019

  • Added check to make sure service isn't already running when started

February 3rd 2019

  • Added optional service configuration to start minecraft automatically on boot
  • Added optional daily reboot configuration via Cron in setup script
  • Added a check in the installer to make sure Java was installed properly before continuing
  • Installer script now goes into the started screen window after installation
  • Server now checks for updates to the server on startup

February 2nd 2019

  • Script now checks to make sure we are running on the ARMv7 CPU architecture with 1024MB of RAM to ensure Java 9 works
  • Script helps you overclock SD card and change gpu_mem to 16MB
  • Increased memory usage of server from 800MB to 850MB due to gpu_mem tweak
  • Improved reliability and validation checks on setup script

Sponsor this project

 

Languages