The 1.17 Caves and Cliffs Part 1 version of Minecraft came out for vanilla very recently but until now the Paper Minecraft server was not available for it. This means that my Raspberry Pi Minecraft script was unable to run this version until now.
Today I checked the Paper Minecraft API server available versions and sure enough 1.17 was finally in the version list so I updated the Raspberry Pi Minecraft server scripts and they are now available! Raspberry Pi not required, the script will work on most versions of Linux that have apt available.
- The minimum OpenJDK requirement has gone all the way up to OpenJDK 16 for this release. This presents a challenge because the Raspberry Pi OS repositories only contain up to OpenJDK 11! Fortunately the script will take care of this for you using a trick with snapd to install a newer OpenJDK. This does require a reboot so prepare beforehand!
- Back up your server first. Remember if you use 1.17 and it ends up being too laggy or unstable you can’t change back to the old version because the server files now contain data the old versions don’t understand and will crash on. You can go back by restoring a backup from before the first time you ran 1.17!
SSH into your Raspberry Pi and paste the following commands:
curl https://raw.githubusercontent.com/TheRemote/RaspberryPiMinecraft/master/SetupMinecraft.sh | bash
See the full installation post for more information here: Raspberry Pi Minecraft Server Setup Script w/ Startup Service
Full GitHub project repository available at: Official GitHub Raspberry Pi Minecraft Repository
Benchmarking / Testing Storage
If you want to verify your drive’s performance you may want to run my storage benchmark with:
sudo curl https://raw.githubusercontent.com/TheRemote/PiBenchmarks/master/Storage.sh | sudo bash
If you search for the model of your drive on Pi Benchmarks you can compare your score with others and make sure the drive is performing correctly!
I’m trying to set this up on Ubuntu 64-bit desktop OS 20.10 (although will likely switch to Ubuntu Server) to make the best use of my Rpi4’s 8GB RAM and get better performance. I have previously had this working on Raspbian 32bit, but this was limited to the 4GB RAM usage.
When calling: ‘curl https://raw.githubusercontent.com/TheRemote/RaspberryPiMinecraft/master/SetupMinecraft.sh | bash’ , the installation goes a bit wrong at this point:
Warning: Failed to open the file /etc/systemd/system/minecraft.service:
Warning: Permission denied
100 312 100 312 0 0 1080 0 --:--:-- --:--:-- --:--:-- 1079
curl: (23) Failure writing output to destination
sed: can't read /etc/systemd/system/minecraft.service: No such file or directory
sed: can't read /etc/systemd/system/minecraft.service: No such file or directory
Which results in the following at end of installation:
Start Minecraft server at startup automatically (y/n)?y
Failed to enable unit: Unit file minecraft.service does not exist.
Setup is complete. Starting Minecraft server...
Failed to start minecraft.service: Unit minecraft.service not found.
Server has failed to start after 30 seconds.
Executing as my user (so non root) does successfully build the server as I can then manually call ./start.sh and it builds/runs, however the SetupMinecraft.sh is not installed, neither is the minecraft.service file (those were all I’ve noticed missing).
I therefore don’t get the benefit of starting the server when RPI is powered on (very useful for me), and also the daily reboots (which I’m keen to not have to manually do).
I have assumed this is because I am not the root user? – however I tried applying sudo and the script is built to exit when run in sudo. I also tried running as the root user (using sudo -i), but this too exits.
Is there anything that can be done to e.g. alter writing/reading access to etc/systemd/system/minecraft.service? Or should I be using a different script for use on Ubuntu?
Any pointers on this would be much appreciated,
Thanks in advance!
Are you running the installation script with sudo? I’m sure you are because you installed on multiple platforms and it was previously working. I don’t even think you have to specify sudo if I remember correctly and that it will fail without it.
So if you are sudo the only reason you wouldn’t have write permissions to parts of your disk like this is if the disk is corrupt. Any time you are having issues with services installing like this it’s usually due to corruption on the drive. You could try running a fsck on the drive but it probably needs a reimage.
I suspect if you try this on the other machine again it will still work. I think this may have been a bad image or may have got corrupted here! I’ve seen this happen to a few people before and my rule of thumb is when the startup service starts failing randomly / won’t work that machine is probably due for a reimage. If you just imaged this machine it’s very likely it was a bad image.
The only time sudo will be denied access to write to files like this is if the volume is locked due to being corrupt. If you do sudo mount you’ll probably find your root OS is mounted as read-only. Sometimes a simple sudo fsck /dev/mmcblk0p2 or /dev/sda2 will fix these but honestly most times I’ve walked people through trying a fsck repair they just ended up reimaging.
Any chance you could create one of your amazing scripts for setting up a vanilla java minecraft server? (Non-paper) I ran my server on a Rpi for years and have recently upgraded my PC so I’m using my old PC as a server. I don’t need to use paper anymore and the minor differences between paper and vanilla are not something I want.
Alternately, if there already is a set of similar scripts for vanilla minecraft, I’d love a pointer.
Absolutely! In theory it’s pretty easy, you would install normally and just change paperclip.jar to run the server directly, but I may be able to put something together and package it as “vanilla” or something like that!
I just updated the minecraft paper server to 1.18 by running the SetupMinecraft.sh and specifying version 1.18.
The 1.18 paper server is in experimental now and they are updating the jar file very often. Is there someway of manually choosing a jar file the server will use? Can i just replace the paperclip.jar? Or does it automatically update?
Thank you! Your bash scripts are awesome!
Great question! It’s all completely automatic. Basically the script checks for updates via the Paper API every time you start the server. If there’s a new version of paperclip.jar available it will install it (which then paperclip.jar will update the Minecraft server itself).
You can see this in action at papermc.io/downloads. There have been 9 (NINE!) updates just today on December 4th by 12:17pm to give you an idea of how often / how much they are working on this. These are almost certainly all performance / bug fixes coming out (there is a changelog you will see next to each version though to see the specifics) as they clean up the lag in 1.18.
Basically all you need to do to get the latest updates is restart your server as the updates happen in start.sh. Hopefully that helps!
Thank you! Just what I was wondering about, thanks alot! 🙂
No problem at all, glad I could help!
Hello James and thank you for your amazing work!
I’m not sure if it has been already posted but the SetupMinecraft.sh script is forcing the installation of OpenJDK 17, even for Minecraft 1.16.5 (which is not compatible)
I figured out how to manually install and select back by default OpenJDK 11 but I’m encountering another issue and I haven’t figured out yet how to deal with :
When backing up and rebooting (at 4 am), the minecraft server crash and then even the raspberry pi couldn’t be reach via SSH (forcing electrical reboot is then the only option).
Though I noticed the backup is made.
Do you know if there’s the possibility to consult some logs other than the one’s located in /home/pi/minecraft/logs ?
For the record, I’m running RaspiOS 64bits (latest version) with usb3 SSD boot.
Welcome, thanks for your kind words as well! Yes the OpenJDK situation is a bad situation for sure. What has just happened is they forced OpenJDK 16 for 1.17 and now it’s already being forced to OpenJDK 17 because OpenJDK 16 just went end of life (they’re only good for 6 months unless it’s a LTS release). This version (OpenJDK 17) will be a LTS release so this should slow down here. It’s Paper that is changing the requirements though and I share your frustration here but things do look like they should stabilize with the OpenJDK whiplash at least! I’m glad you were able to get this piece resolved of it and thanks for leaving the details of what you did as it will help anyone else trying to stay on 1.16.
I definitely wanted to take a look at your rebooting issue here. This is strange because what should happen is if the server is crashing the Pi then your log file should leave off exactly on the line it was doing when it crashed. It sounds like you’ve looked at these files (you said the backup is being created) so we know it’s not failing during the backup process. It doesn’t sound like it’s failing during the server restart either or the logs would similarly stop right in the middle of it.
How are you setting up 1.16.5? Are you trying to restore an old backup of it or are you changing SetupMinecraft.sh using AllowLocalCopy=1? I assume that it’s the latter because of it trying to force OpenJDK 17 upon you. You may be able to actually just restore an old backup though if it seems like it’s SetupMinecrft.sh related (you could basically just use a working copy of your old scripts/files in this case).
You’d almost want to check more generic logs like /var/log/syslog (you can find some other logs in /var/log as well) as the entire Pi going down and being unreachable via SSH can’t be explained by a minecraft server crash. The entire Pi has to be crashing. You could also check the system journal with sudo journalctl -xe to see the latest journal errors. This seems like a system wide crash.
Something strange is happening for sure though. The script is not capable of crashing the system in this way. All the daily reboot does is run restart.sh from crontab. You can actually delete the reboot by typing:
You’ll see the line in there calling restart.sh. The code from restart.sh is this:
echo "Sending restart notifications to server..."
# Minecraft Server restart and pi reboot.
screen -Rd minecraft -X stuff "say Server is restarting in 30 seconds! $(printf '\r')"
screen -Rd minecraft -X stuff "say Server is restarting in 7 seconds! $(printf '\r')"
screen -Rd minecraft -X stuff "say Server is restarting in 6 seconds! $(printf '\r')"
screen -Rd minecraft -X stuff "say Server is restarting in 5 seconds! $(printf '\r')"
screen -Rd minecraft -X stuff "say Server is restarting in 4 seconds! $(printf '\r')"
screen -Rd minecraft -X stuff "say Server is restarting in 3 seconds! $(printf '\r')"
screen -Rd minecraft -X stuff "say Server is restarting in 2 seconds! $(printf '\r')"
screen -Rd minecraft -X stuff "say Server is restarting in 1 second! $(printf '\r')"
screen -Rd minecraft -X stuff "say Closing server...$(printf '\r')"
screen -Rd minecraft -X stuff "stop $(printf '\r')"
# Wait up to 30 seconds for server to close
echo "Closing server..."
while [ $StopChecks -lt 30 ]; do
if ! screen -list | grep -q "\.minecraft"; then
echo "Restarting now."
sudo -n reboot
That’s it. That’s all it does. It says some chat messages and then calls
sudo -n reboot. There’s nothing really here that could crash.
If your SSH is becoming unreachable it would suggest that your Pi can’t reboot on it’s own successfully. Is this the case? Is your Pi on a powered USB hub where it can’t reboot without doing a full power cycle where you momentarily unplug the hub by chance?
What happens if you call sudo reboot on that Pi? If you run that command does the Pi not start up normally? If not then this is for sure the issue!
It seems to me like if the backup file is getting created that would suggest that the Pi is rebooting and starting up successfully. The backup is not done before that. The backup is only done in start.sh. restart.sh just calls sudo reboot. The backup getting created is the very last step before the server starts actively listening for connections and only takes place in start.sh after successful reboot (which would bring your SSH service back up).
This would point toward the server is starting up successfully (especially if your logs are clean / you aren’t finding anything interesting in them) and something else is going wrong that is crashing the system. /var/log/syslog or dmesg may definitely provide a hint if some driver is crashing out or something is throwing a critical error / causing a kernel panic that may explain this behavior.
This doesn’t mean the script isn’t involved in any way. Clearly the daily reboot is triggering this behavior to happen somehow, but the errors are not showing up where we would expect for a Minecraft server crash. It could still be service related which will show up in sudo journalctl -xe for the minecraft service. Basically we need to find more information for sure!
I definitely don’t have a 100% definitive answer of what is going on yet but I’m hoping checking some of these will help lead you to the right answer / more information such as a error message from a crash!
Wow I didn’t expect such a detailled and quick answer, again thanks a lot !
You’re right, I went from a 1.16.5 backup (using AllowLocalCopy=1 in SetupMinecraft.sh) when I decided to upgrade the OS of my Pi4 from Raspbian Buster 32bits to RPiOS 64 bits beta. The reason was mostly to use most of the 4GB RAM of my Pi for the Minecraft server and to upgrade the bootloader to use native USB Boot.
Last year I discovered your awesome detailled website and set up my Minecraft server with your scripts using the Raspbian Buster version I mentionned earlier. At that time (early 2020), the USB boot wasn’t native on the Pi4 so I followed a guide to make it work (mostly by modifying PARTUUID and using fstab and quirks).
It worked without any significant issue.
I wanted you to know my background to have more insights on this case.
I agree with you, I also don’t think your scripts are causing the crash of my minecraft server and the SSH service. Also when this happens I noticed the Pi still answers to ping (maybe I should connect the Pi to an external display with HDMI to see what’s going on).
By issuing sudo reboot or the sudo -n reboot command at the end of Restart.sh, the Pi reboot normally.
So I think it happens after the restart and the full backup (which is completed).
I found nothing relevant in /var/log/syslog or the system journal for the moment.
For now I’ve just deleted the cron job of the backup and everything works normally, no crash at 4am or either after.
So my guesses are what’s causing this is located somewhere between this RPiOS 64bits version (still in beta) and my SSD (an old Crucial M4 128GB, which firmware is apparently up to date). Maybe this beta OS version doesn’t go well with my USB3 to SATA adapter chipset (a JMicron JMS567 one). Could be an overheat or overload because there’s a lot of IOPS on the disk at that moment ?
As I prefer to stay with RPiOS 64bits to use most of the Pi4 RAM with the server, I ordered the same USB 3.0 Startech adapter you used and tested, at least I won’t have to use quirks with this one because the chipset is different and working with UASP.
When I will receive it I will keep you updated on my progress if you want and if the crash behavior still continue I will install RPiOS 32 bits and will see what happens.
No problem at all, thanks for a great followup! This is definitely quite strange there was nothing in /var/log/syslog. That would point to storage for sure as any other way of the system crashing should leave log files. I’d definitely love for you to continue to keep me posted and to assist in diagnosing this.
It definitely could be adapter related for sure. The JMS587 one can be hit or miss. Can you tell us exactly what brand you have? Sometimes there are firmware update options for certain adapters that can alleviate things like this.
I definitely think you are on the right track here. Storage makes sense as being the culprit. It doesn’t make sense that we would have nothing in /var/log/syslog or the Minecraft server logs *unless* it was the storage device that was crashing. In that case there definitely won’t be any log files written of any kind because the storage device was lost so it couldn’t have written anything.
Power is a possibility or possibly an adapter chipset incompatibility. One test you could do is try using it on the USB 2.0 ports and see if it doesn’t crash like this upon reboot. This can often “work around” issues with adapters with compatibility issues (but does limit performance since USB 2.0 is much slower than USB 3.0). “Quirks mode” can also often fix these which I cover how to set up in my Pi USB booting guide.
Staying on 64 bit Raspberry Pi OS beta shouldn’t be an issue. I have 64 bit installed on all of my Pis and personally always use it / prefer it. I never use the 32 bit because the packages are so outdated on it that it’s difficult to use for a lot of things now with such ancient software in the repositories. The 64 bit is substantially more up to date!
Let’s see your results with the StarTech as I think there’s a good chance that may solve this. There’s a chance it’s power related and we may need a powered USB hub but to be perfectly honest the drives you listed are not known to be particularly power hungry and they aren’t ultra huge capacities. This behavior almost strikes me as more adapter related or potentially power. Definitely let me know what you find and I’ll help troubleshoot/diagnose further depending on your results/findings!
Hi, im having the same problem, ssh and mc server become unreachable after the reboot at 4 pm.
Only strange thing is that when i log on to the pi Locally everything seems to be working, there is internet access, the mc server is running and responsive to commands.
Also connection attempts ar shown as player disconnected on the mc servers console output. Only way is to force a sudo reboot og reset the power, then everything works fine inntil the next day.
Problems started when switching to the 1.18 and upgrading Java.
Was running Arch Linux, thought it was a routing error i couldt fix, and when rebooting the router didnt work i installed raspberry pi os lite 64bit,certain it would solve my problem. But the problem presist and is the exact same problem. Im going crazy 😂
That is really weird, I would have 100% thought that the clean Raspberry Pi OS install would have got this for you as well. Can you pull a:
sudo systemctl status minecraft
You would do this when it happens but you can usually find some historical start logs with:
sudo journalctl -xe
and scroll to look for the Minecraft service entries.
and then go to your ~/minecraft/logs folder and see if any log entries are being generated? I think it’s more likely the first command will tell us something. Do you have a really large server that takes more than 600 seconds to start?
I’m sure we can get it going here!