Raspberry Pi Minecraft Server Setup Script w/ Startup Service

Minecraft 1.17 - Caves and Cliffs Update
Minecraft 1.17 – Caves and Cliffs Update

Minecraft 1.17 (Caves and Cliffs 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.

This is the standalone version. It runs on most flavors of Linux and should work on most architectures as well (arm, aarch64, etc.).

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:

It’s now possible to convert your worlds between Bedrock and Java versions. Check out my guide on Chunker here for more information.

Features

  • Sets up fully operational Minecraft server in a couple of minutes
  • Runs the highly efficient “Paper” Minecraft server
  • Raspbian / Ubuntu / Debian distributions supported
  • Installs and configures OpenJDK 18
  • 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

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

Minecraft Java for PC
Minecraft Java for PC / Mac / Linux*
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*

Raspberry Pi 400 Kit
Raspberry Pi 400 Kit

The Raspberry Pi 400 kit includes everything you need for a full Pi 400 desktop build. The Pi 400 is the fastest Raspberry Pi ever released and comes in the form factor of a keyboard!

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: AliExpress*, 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*

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*

SD Card Setup:

SanDisk Extreme A1
SanDisk Extreme A1

The SanDisk Extreme A1-A2 SD card has the best scoring SD card on Pi Benchmarks 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: AliExpress*, 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*

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

Raspberry Pi OS – 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 / 20.04 – 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.

Minecraft Server Installation

SSH into your Raspberry Pi and paste the following commands:

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

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.

Benchmarking / Testing Storage

If you’re getting poor performance or just want to verify everything is working correctly 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 pibenchmarks.com you can compare your score with others and make sure the drive is performing correctly!

Changing Minecraft Server Version

To override the default version let’s grab a copy of the script locally:

wget https://raw.githubusercontent.com/TheRemote/RaspberryPiMinecraft/master/SetupMinecraft.sh 
nano SetupMinecraft.sh

Now make these changes from inside nano:

Version="1.16.5" 
AllowLocalCopy="1"

Now press Ctrl+X to exit nano and answer “y” to save. Now let’s run the script:

chmod +x SetupMinecraft.sh
./SetupMinecraft.sh

And the setup will run and install the version of Minecraft you set at the top of the file!

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 launch options
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
cron options

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 Mods / Plugins

The server supports plugins that are compatible with Bukkit / Spigot / Paper. A popular place that you can get plugins is at dev.bukkit.org 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
curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.12.212 Safari/537.36" -o worldguard.jar https://dev.bukkit.org/projects/worldguard/files/latest
sudo systemctl restart minecraft

The reason the middle line is so long is that “robots” (roughly anything that isn’t a web browser being used by a user in this context) including scripts and utilities are blocked by the Bukkit server. The extra parameters we’re including in this line will add the location (-L) flag as well as a user agent and an identity / language header which will allow us to fetch the files without getting a 403 forbidden error.

Make sure to change “-o worldguard.jar” (second to last parameter) and the URL (very last parameter) to match the project you want to download.

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://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.17 and go back to 1.16 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!

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.

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.

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.

Version History

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

Update History – RaspberryPiMinecraft – Official GitHub Page

Other Resources

If you’re trying to set up SSD / USB storage booting check out my Raspberry Pi USB booting setup guide

For benchmarks and recommendations on the fastest storage drives/adapters for the Raspberry Pi check out my 2021 Storage Roundup

If you’re having firmware issues and need to update/restore your firmware check out my Raspberry Pi firmware guide here

1,112 thoughts on “Raspberry Pi Minecraft Server Setup Script w/ Startup Service”

  1. Avatar for CardinalFang36

    James,

    I am using the dynmap plug with my server. It generates a log of small jpg files that can easily be regenerated later, so I am trying to exclude them from my daily backups. I tweaked the ./minecraft/start.sh script, adding “–exclude=’./plugins/dynmap/web/tiles/'” but they continue to be included in the backups. Did I edit the wrong spot? (I just noticed a trailing “/”. Is that the culprit?

    # Back up server
    if [ -d "world" ]; then
    if [ -n "$(which pigz)" ]; then
    echo "Backing up server (all cores) to cd minecraft/backups folder"
    tar -I pigz --exclude='./backups' --exclude='./plugins/dynmap/web/tiles/' --exclude='./cache' --exclude='./
    logs' --exclude='./jre' --exclude='./paperclip.jar' -pvcf backups/$(date +%Y.%m.%d.%H.%M.%S).tar.gz ./*
    else
    echo "Backing up server (single core, pigz not found) to cd minecraft/backups folder"
    tar --exclude='./backups' --exclude='./cache' --exclude='./logs' --exclude='./jre' --exclude='./paperclip.ja
    r' -pzvcf backups/$(date +%Y.%m.%d.%H.%M.%S).tar.gz ./*
    fi
    fi

        1. Avatar for James A. Chambers

          Hey Cardinal,

          Excellent, I actually wasn’t 100% sure about that but I do recall having problems with that early on when I was developing the backups and realized that had to be dropped.

          Honestly? The backups being that big previously may very likely have been contributing to your disk/corruption problem. That is a *lot* of unnecessary data flying around. It’s also something that would have been a more extreme case and helps explain why/how you could be getting the service restart/disk corruption issues so quickly. If it’s a SD card it may have significant wear on it and be wearing out / going bad.

          The service may just be timing out too if the backups take too long. I did raise the service startup timeout window not too long ago to help with that but again this sounds like an extreme case if you had a 2 GB reduction. The disk might not be corrupted at all and it was just timing out. You can usually find that with sudo systemctl status yourserver and the error message would say something related to timing out or something along those lines.

          That’s a huge reduction in size. Thanks for sharing what worked on it!

          1. Avatar for James A. Chambers

            Actually no, I’m a liar! I did *not* raise the service startup timeout in this one yet. I just checked. That was just Bedrock. I am going to raise it now though. This should solve this issue if it is related to timeouts and the backups taking too long (I think it probably was given the context of how much you reduced the size of your backups by)!

            I just uploaded this fix to GitHub. You would need to run SetupMinecraft.sh again to get this change. I think it would be worth it for yours!

            1. Avatar for CardinalFang36

              James,

              The boot drive (only drive) is a USB3 SATA SSD (from MicroCenter – Inland). Here is the fsck output:

              Aug 29 10:16:32 paynecraft systemd-fsck[147]: e2fsck 1.46.2 (28-Feb-2021)
              Aug 29 10:16:32 paynecraft systemd-fsck[147]: Pass 1: Checking inodes, blocks, and sizes
              Aug 29 10:16:32 paynecraft systemd[1]: Finished Set the console keyboard layout.
              Aug 29 10:16:32 paynecraft systemd[1]: Finished Coldplug All udev Devices.
              Aug 29 10:16:32 paynecraft systemd[1]: Starting Helper to synchronize boot up for ifupdown...
              Aug 29 10:16:32 paynecraft systemd[1]: Finished Helper to synchronize boot up for ifupdown.
              Aug 29 10:16:32 paynecraft systemd-fsck[147]: Pass 2: Checking directory structure
              Aug 29 10:16:32 paynecraft systemd-fsck[147]: Pass 3: Checking directory connectivity
              Aug 29 10:16:32 paynecraft systemd-fsck[147]: Pass 4: Checking reference counts
              Aug 29 10:16:32 paynecraft systemd-fsck[147]: Pass 5: Checking group summary information
              Aug 29 10:16:32 paynecraft systemd-fsck[147]: rootfs: 363543/7737856 files (0.2% non-contiguous), 5814971/31192150 blocks
              Aug 29 10:16:32 paynecraft systemd[1]: Finished File System Check on Root Device.

              Cross fingers, the system has successfully rebooted the last few nights…since reducing the backup size. (I did not rerun SetupMinecraft.sh yet). Will certainly keep checking…

              Tom

              1. Avatar for James A. Chambers

                Hey Cardinal,

                Looking good so far! That fsck looks normal and in fact 0.2% is a pretty good non-contiguous score (not really too important though other than it’s not filled with errors).

                Keep me posted!

  2. Avatar for Benjamin Lebron

    Hey there James! In this article you say to port forward port 25565. Is this mandatory or could I change the port being forwarded to another port, for example port 19132

    How could I do that?

    Best, Ben

    1. Avatar for James A. Chambers

      Hey Benjamin,

      You can change the port in the server.properties file in your server folder. You will see it in there and it’s just a text file.

      If you change that and restart the server the port will change for you!

  3. Avatar for Benjamin Lebron

    Hey James! Quick question could this setup run on something other than a rasberry pi? Would it run on a desktop core i2 with 8gb of ram and 120GB of storage? thanks!

    1. Avatar for James A. Chambers

      Hey Benjamin,

      That’s a great question! So it absolutely will. It will work on pretty much any system you can throw at it. I didn’t do myself many favors by putting “Raspberry Pi” in the title for sure on that one!

      That sounds like it would be a fine server. You would just install it completely normally through the same process and you’d be all set!

        1. Avatar for James A. Chambers

          Hey Benjamin,

          For sure! If you open up start.sh you will see a backups section:

          # Rotate backups -- keep most recent 10
          if [ -e "/home/james/minecraft/backups" ]; then
          Rotate=$(
          pushd /home/james/minecraft/backups
          ls -1tr | head -n -10 | xargs -d '\n' rm -f --
          popd
          )
          fi

          All you need to do is adjust the “10” to however many backups you want. If you wanted 100 you could add an extra 0. That would make it look like “head -n -100” in the rotate line. I should probably add this to SetupMinecraft.sh as this question has been coming up more recently which usually tells me I need a new feature.

          That should take care of it for you!

  4. Avatar for CardinalFang36

    James,

    I finally got around to rebuilding my RPi because of the occasional nightly crash. I used the script and it repeatably dropped out of the “screen” session. I manually ran the java command line and noted it was complaining about the eula.txt file. Did you previously set this to “true” on our behalf? Changing the contents from “false” to “true” cleared everything up. Just a heads up.

    1. Avatar for James A. Chambers

      Hey CardinalFang,

      Welcome back! So that is actually done in the SetupMinecraft.sh file here:

      # Accept the EULA
      Print_Style "Accepting the EULA..." "$GREEN"
      echo eula=true >eula.txt

      So basically it should do this for you when you run SetupMinecraft.sh. I could possibly add it to start.sh as well which would prevent this if anything is being worked on / backups are being restored / etc. Hopefully that helps!

      1. Avatar for CardinalFang36

        Not sure why it wasn’t done with the initial SetupMinecraft.sh run. I rebuilt the server, ran SetupMinecraft.sh from the curl statement above and then started to server (first run). This is where it kept returning from ./start.sh without starting. I don’t recall seeing the “Accept EULA” step.

        Separately, I have some investigating to do as the server is not running when I wake up in the morning (after the rebuild).

        1. Avatar for James A. Chambers

          Hey CardinalFang,

          You may have to look at the logs for this one. If it’s not starting upon reboot almost every time that has been the OS / disk is corrupted and the OS needs a reimage.

          If you check the logs though you may find it’s something much simpler. Probably sudo systemctl status yourserver and the logs folder logs should tell us what it is!

          1. Avatar for CardinalFang36

            I have found some articles that indicate a problem with Raspberry Pi 4’s not reliably rebooting. Some indications are poor power supplies. Others seem to point to firmware. Some to the use of USB drives. None very conclusive. Googling “raspberry pi 4 not rebooting” gets quite a few hits. This is one good one.

            1. Avatar for James A. Chambers

              Hey Cardinal,

              For sure it could be power related. The 3.0A power supplies for Raspberry Pi definitely are of varying quality. Typically the official ones are okay. If it’s an unofficial one this is worth checking.

              The main culprit see in these cases is usually related to a bad OS image. Reinstalling the latest Bullseye image might take care of this as well. Sometimes it’s the disk partitions need an fsck and that has fixed ones like this before as well.

              Usually not rebooting or the services not coming up points to it needing a reimage though. This is because all Pis are the same basically. You’re right though that all of the Pi power supplies being used are *not* the same though and this can lead to some issues. Hopefully that helps!

              1. Avatar for CardinalFang36

                Following your advice, I did recently reimage (painless thanks to your backups!) and the reboot issue happened immediately for the first three nights…then was fine for 2-3 nights, but again last night didn’t restart. I can not find anything in the logs pointing to a crash (I did see some evidence last time). These recent incidents appear to simply not reboot. Works fine after cycling power.

                I tried using my MacBooks 30A power supply one night, but it suffered the same reboot issue.

                I will look at an fsck.

              2. Avatar for James A. Chambers

                Hey Cardinal,

                Great testing! Can you tell me a little bit more about your setup? Is this a SSD boot or are you using a SD card?

                I definitely think something more is going on here. I did vaguely recall that you and I have for sure done some reimages before on this one and it does seem to fix it for a while and then it comes back.

                If this is a SD card I’m starting to suspect it might be a bad SD card. It shouldn’t get corrupted this often *unless* the Pi is frequently being turned off / losing power without being shut down. That is pretty common with Pis so if you know that power is being lost sometimes then that is why it’s corrupting (and it’s the most common reason for sure).

                If it’s never losing power and this is still happening it would point to a bad SD card to me. If it’s an SSD this is less likely (but still possible). Both are prone to corruption if power is lost (as is any regular PC) but people generally know to not yank the power from a PC or it’s going to cause trouble. People tend to not think of the Pi in this way. I’m actually guilty of this too sometimes and will be lazy and just yank the power if I am moving the Pi or done using it for the moment (but I’ve corrupted so many SD cards and SSDs doing it that I’ve learned the hard way, even though it’s probably only like a 5-10% chance of it happening each time because it won’t always be in the middle of a write when power is cut and if it’s not then nothing bad will happen).

                When it does happen though the reason it’s always the server that gets corrupted (or the services related to it) is because those are what was actively running on the machine (and thus likely to be where the disk was in the middle of a unfinished/incomplete disk write to which is where the corruption comes from, it was basically half way done with the writing job but half of it never completed) when power is cut.

                The Minecraft server is also constantly doing tiny little writes here and there even when nobody is online as some actions still run related to villages and a bunch of other things that aren’t immediately obvious but are always still constantly happening (even with 0 players online for some systems). This definitely raises the likelihood that if power is lost that the Minecraft server will in fact have been in the middle of a write because it’s doing small ones very frequently.

                The reason reimages usually fix these is because the disk is getting corrupted and certain services are failing to start on their own again. That is still true and undoubtedly a reimage would fix it again. What is strange about yours is that it keeps happening so quickly. 2-3 days is too fast for this to be happening without some kind of additional hardware issue going on I think (or another explanation like power loss without shutdown). The fsck is worth a try if only to see if you start seeing dozens or hundreds of errors you 100% know the disk has gone bad.

                Hopefully that helps, let me know what you find!

  5. Avatar for A. J.

    James – very kind of you to post this wonderful script. I also appreciate your analysis of running 32 vs 64 bit OS. After fighting with 64 bit Ubuntu performance, a quick reinstall of rasp32 bit OS and using your script had me up and running!

    I don’t, however have connectivity with my iOS clients. Do you see any issue running iOS clients against this setup? I cannot seem to find the new server on the network. Do you know of any tests I should be able to do from an iOS device to make sure it is connecting to the new Minecraft server – something analogous to a telnet session from a linux machine on port 25565?

    Thanks!

    1. Avatar for James A. Chambers

      Hey A.J.,

      Welcome! You’re definitely thinking along the right lines of troubleshooting it for sure. The # of players online is retrieved separate from joining the game.

      If you add the server to the list manually by IP address (that is where you press “Add Server” and type in the IP) does it connect? The ping / players online port typically doesn’t need to work to join although it’s a little strange it’s not working.

      If you installed a fresh OS I am guessing that ufw is not installed and it sounds like you can connect from non-iOS clients which is definitely a little strange. I wonder if it’s this:

      With the update of iOS 14, Apple has introduced many new privacy features. For example, players are prompted with a notification upon opening Minecraft for the first time. “Minecraft would like to find and connect to devices on your local network.”

      https://help.minecraft.net/hc/article_attachments/4408902743181/blobid0.png

      You must select OK and allow this connection because you will not be able to sign in to your account without allowing this permission. Some features such as the Marketplace and single-player worlds may still work, but multiplayer and Realms will not be available.

      If you already declined this popup, you may be unable to log in until Minecraft is updated for iOS 14. We are currently working on updating the game. But you may still encounter this bug until the patch is complete. Thank you for your patience.

      This is the only thing I can think of that it could possibly be. It’s basically acting like a firewall so this being a permissions issue makes sense. It also never shows you the popup again (ever) unless you take steps to get it back. I think it has to be something along these lines as you’ve already ruled out so much else with your troubleshooting (great work!).

      1. Avatar for James A. Chambers

        Whoa, whoa whoa wait a second. I just looked at which thread we are in. I know what the problem is!

        This is the Java version of the server and iOS is Bedrock. You’re trying to connect to a Java server with Bedrock.

        This is actually possible if you use my Docker Java + Bedrock together container: Minecraft Java + Bedrock Server Together – Geyser + Floodgate.

        If you only want to run a Bedrock server that version of the script is available here: Minecraft Bedrock Edition – Ubuntu Dedicated Server Guide.

        I probably would have caught this if it wasn’t the first thread/reply I did this morning but iOS needs the Bedrock server to connect (or a Java server running Geyser like my Docker container I linked to)!

        1. Avatar for A. J.

          That was exactly the problem – and your Docker script had me up and running in minutes on Bedrock (once I decided the Raspberry wouldn’t suffice). Wonderful scripting and thank you for building / supporting this community, James.

          1. Avatar for James A. Chambers

            Hey A.J.,

            No problem at all, I’m so glad you met with success and were able to get a server going the way you wanted! Thanks for letting people know what worked as well since that will help others looking in the comments.

            Enjoy and take care!

  6. Avatar for William Wright

    Hey James, I’m having a problem with my server when i run the setup:
    pi@raspberrypi:~/minecraft $ ./start.sh
    tail: cannot open '' for reading: No such file or directory
    Updating to most recent paperclip version ...
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    100 169 100 169 0 0 555 0 --:--:-- --:--:-- --:--:-- 555
    Latest paperclip build found: 109
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    100 36.2M 100 36.2M 0 0 6153k 0 0:00:06 0:00:06 --:--:-- 6223k
    Starting Minecraft server. To view window type screen -r minecraft.
    To minimize the window and let the server run in the background, press Ctrl+A then Ctrl+D

    I’m not sure how to fix this

    1. Avatar for James A. Chambers

      Hey William,

      Welcome! It looks like there’s a quote in your server name. It’s basically saying cannot open ” which means there’s a quote in your server name (this breaks the script and is actually how a lot of security vulnerabilities work, although here it’s not really a vulnerability since only the administrator / person setting it up could do this although I should probably filter it to prevent this to make it less confusing).

      Just use numbers and letters with no spaces and symbols for your server name should do it here!

        1. Avatar for James A. Chambers

          Hey Dirk,

          Are you reusing an old copy of SetupMinecraft.sh? Make sure you’re using the latest one from GitHub. I just tested updating and deploying a brand new server with the name james. Everything looks normal and in fact I updated it so it’s impossible to enter a server name that will break it anymore.

          Are you modifying the server install path? Definitely don’t do that and leave it as the default (~).

          The script only allows you to enter two things: a server name and an installation path (and the memory and a couple y/n questions but those generally won’t break it). One of the ones you are using is wrong/illegal for a path/folder and breaking it. If you leave the path as default and enter a simple alphanumeric server name with no spaces this will not happen.

          Nobody should ever change the path unless you are installing it to a different physical drive. If you don’t understand exactly how the paths work and how to enter them correctly (as absolute paths and understanding there’s a “root” folder substructure to let it support multiple servers that is shared between all your different server names) it won’t work so definitely leave that as ~.

          If you need to use this then if you wanted your server path to be at /altdisk/minecraft/server you would actually enter the path as /altdisk. You would not attempt to put minecraft in the path and you would not attempt to put your server label in the path anywhere. Every single server would have the exact same root path and simply a different name. The script does all of that for you and if you don’t understand exactly what it’s doing this will happen.

          Like I said unless you actually need this don’t even try it. I’m even confused just explaining it. If you are trying to use it though I can almost guarantee it doesn’t work how you are thinking unless you’ve looked at the source code and that you are specifying it several levels too deep. It’s supposed to be the “root” path (not even the minecraft part).

          Hopefully that gets it for you!

            1. Avatar for James A. Chambers

              Hey Dirk,

              Thanks for letting me know that worked! I think I need to improve how it handles the paths and this actually helps me. My goal with the script is for it to easily set up a Minecraft server without a bunch of weird problems.

              It failed you in my opinion. The script should be validating and detecting this stuff. Because of this I actually don’t blame you for entering something that would break the script. I blame myself for allowing something like that to happen!

              I will give some thought to this based on your experience (and you weren’t the only one, there were a few people who were impacted by this). Thanks so much for sharing that worked for you!

    1. Avatar for James A. Chambers

      Hey Thomas,

      Don’t sweat it, I think I can help!

      First make sure you have the latest version of SetupMinecraft.sh as the script hasn’t used the system’s Java for some time (but it used to, this was a problem for years until earlier this year when I moved to Adoptium). It doesn’t matter at all now in the latest version what version snap installs on the system and it won’t use that one if that makes sense. It actually stores it’s own copy in your ~/minecraft/jre folder.

      This has proved to be a much better setup overall for several reasons including you don’t have to change your system’s default Java distribution (which some things depend on sometimes and newer ones can break if they aren’t expecting a new one), the release jumps for OpenJDK no longer leave us with a period where people have a very difficult time running it, and most notably it gives us/you some control so that you can plan these upgrades and not be caught off guard by a OpenJDK release jump (which is what was previously happening approximately every 6 months to a year).

      Basically if you make sure you run the latest SetupMinecraft.sh from GitHub it will manually install the Adoptium OpenJDK that is only used for Minecraft (standalone). This was very frustrating for everyone when we had to worry about this and it was my most hated issue as a developer (because it is almost entirely outside my control both which Java versions Paper happens to be supporting as well as OpenJDK’s notoriously forceful “cutoff” of support for old versions) so I’m very glad to have fixed it for all of you (and my own sanity) thanks to Adoptium.

      I did also just update it to upgrade Adoptium to OpenJDK 18 but if you were getting this error definitely run the latest SetupMinecraft.sh as it should not be using the system Java anymore on the newest one. Hopefully that helps!

      1. Avatar for Thomas

        Thanks James, since I ran into some severe problems with removing the JDK/Oracle Java I completely reset the pi and just executed your script. Worked like a charm. I didnt know it installs JDK as well. Thank you for making these things so easy for beginners like me.
        Cheers
        Thomas

Leave a Comment

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

Type here..

Exit mobile version