A new Skyblock island
A new Skyblock island

How to Make a Minecraft Server on a Raspberry Pi Zero

When the Raspberry Pi Zero, the most compact single-board computer in the Raspberry Pi family, was released, my mind immediately jumped to an exciting project: setting up a Minecraft server. Despite its modest specifications, I wondered if careful optimization could transform it into a functional server.

Initial online research offered little encouragement. Critics highlighted the Pi Zero’s limited 512MB of RAM and a 1 GHz processor. These constraints are certainly significant, but the Raspberry Pi Zero has proven capable of remarkable feats with dedicated effort – and that includes hosting a Minecraft server.

However, it’s important to acknowledge some limitations right away.

The Strategy: Skyblock on Raspberry Pi Zero

Given the hardware limitations, I immediately faced a crucial decision: should I opt for an older, less demanding version of Minecraft, or choose a game mode that is inherently less resource-intensive? The former seemed less appealing, so I decided to focus on the Skyblock game mode for the server.

A new Skyblock islandA new Skyblock island

Alt text: A player’s perspective in Minecraft Skyblock, showcasing a small island with basic resources floating in the sky, emphasizing the minimalist environment suitable for low-resource servers.

Skyblock starts players on a small, isolated island with minimal starting resources. The objective is to expand the island and generate more resources. This mode is ideal for low-powered servers because it minimizes the number of blocks and entities that need rendering, significantly reducing server load. To enhance the experience and enable multiplayer functionality, I chose to use the ASkyBlock plugin instead of a custom world file. This plugin allows multiple players to easily create their own Skyblock islands and interact within the server environment.

Raspberry Pi Zero Server Setup: Hardware and Initial Configuration

Here’s a list of the hardware components I used for this project:

  • Raspberry Pi Zero
  • Micro-SD card
  • 5V, 1000mA USB power adapter
  • Micro-USB cable
  • Affordable micro-USB to Ethernet adapter (bandwidth requirements for a small-scale server are minimal, so quality isn’t critical)
  • Ethernet cable

The first step is to install Raspbian onto the micro-SD card. Once Raspbian is installed, connect the Raspberry Pi Zero to power and the internet via the Ethernet adapter, insert the SD card, and power it on.

Next, enable SSH. SSH provides the easiest way to remotely manage the Raspberry Pi. After enabling SSH, use a tool like PuTTY on your computer to log in to the Pi.

Building the Minecraft Server Software

Setting up a basic Minecraft server (PaperMC) involves a few key steps. I’ll outline the general process without going into exhaustive detail.

On your Windows PC, download and execute BuildTools. This process requires Git to be installed on your system.

After BuildTools is complete, download and run Spigot. I opted for Minecraft version 1.12.2 because it strikes a good balance between features and performance, making it suitable for resource-constrained environments.

Finally, download and run PaperMC. PaperMC is a highly optimized Minecraft server software that we will use instead of the Spigot JAR file. PaperMC enhances performance, which is crucial for maximizing the capabilities of the Raspberry Pi Zero.

Now, create a .bat file on your Windows machine to streamline starting the server. Launch the server using the .bat file, accept the Minecraft End User License Agreement (EULA), restart the server, and it should load all necessary files without issues. You should now be able to access the server in Minecraft using the IP address “localhost”.

Initially, you will spawn into a standard Minecraft world. However, our goal is a Skyblock server. To achieve this, navigate to the server files and delete the “world” folder. Replace it with a completely empty world – a superflat world consisting only of an air layer. I added a small platform for players to spawn on. With the empty world set up, we can now proceed to configure the ASkyBlock plugin.

Plugin Configuration for Enhanced Gameplay

To enhance the server functionality, I incorporated several plugins:

While ASkyBlock is the only essential plugin for the core Skyblock gameplay, the others significantly simplify server administration and player experience.

Using ASkyBlock is straightforward. Once a player joins the server, they simply type /island to generate their personal Skyblock island. The plugin also offers the option to create cooperative islands, allowing friends to start near each other and play together.

With the server software and Skyblock setup complete, the next critical step is optimizing the server to run smoothly on the limited resources of the Raspberry Pi Zero.

Performance Optimization for Raspberry Pi Zero Minecraft Server

Performance monitoring with htopPerformance monitoring with htop

Alt text: A PuTTY terminal window displaying htop output on a Raspberry Pi Zero, showing CPU and memory usage during Minecraft server operation, illustrating real-time performance monitoring.

Optimizing the server configuration files is paramount for running a Minecraft server on the Raspberry Pi Zero. Standard server settings are designed for more powerful hardware, so adjustments are necessary to reduce resource consumption.

I followed a comprehensive guide on Spigot server optimization. I implemented all recommendations listed as having “Medium” or “High” performance impact. One of the most effective changes was reducing the view-distance in the server.properties file to a minimal value of 3. While this severely limits visibility in a typical Minecraft world, it is less impactful in Skyblock. I also reduced the max-players setting to 5 to further minimize server load.

I also incorporated the JVM startup flags detailed in the optimization guide. To limit memory usage, I allocated precisely 400MB of RAM to the server process using the argument -Xmx400M. This is also the point where you should create the startup script ( start.sh ) for use in Raspbian.

While performance-enhancing plugins like ClearLagg exist, I found them unnecessary for this setup after the configuration adjustments.

For an additional performance boost, consider overclocking the Raspberry Pi Zero CPU. This involves adding a few lines to a configuration file and rebooting. Proceed with caution and at your own risk. Although overclocking the Pi Zero is generally considered safe due to its low power consumption, it carries a potential risk of hardware damage. Research thoroughly if you are unsure.

I utilized this tutorial for overclocking. To quantify the performance improvement, I ran benchmarks before and after overclocking.

The benchmark command used was:

sysbench --test=cpu --cpu-max-prime=2000 run

Benchmark results (without overclocking):

Test execution summary:
    total time:                          54.4052s
    total number of events:              10000
    total time taken by event execution:   54.3295
    per-request statistics:
         min:                                  2.47ms
         avg:                                  5.43ms
         max:                                 45.62ms
         approx.  95 percentile:              12.90ms

Threads fairness:
    events per thread:                  10000.0000 +/- 0.00
    execution time per thread:           54.3295 +/- 0.00

Benchmark results (with overclocking):

Test execution summary:
    total time:                          48.6731s
    total number of events:              10000
    total time taken by event execution:   48.5755
    per-request statistics:
         min:                                  2.24ms
         avg:                                  4.86ms
         max:                                 22.65ms
         approx.  95 percentile:              12.61ms

Threads fairness:
    events per thread:                  10000.0000 +/- 0.00
    execution time per thread:           48.5755 +/- 0.00

Across multiple tests, overclocking consistently yielded approximately a 10% performance increase, which is a worthwhile gain for minimal effort.

Launching the Minecraft Server on Raspberry Pi Zero

With the Raspberry Pi Zero prepped and the server software configured and optimized, we are ready to start the Minecraft server.

Transfer the entire server folder to your Raspberry Pi. SSH, which was enabled earlier, simplifies this process. Use a program like WinSCP to log in to the Pi and transfer the files over your local network.

Once the files are transferred, access the server folder on your Raspberry Pi using a PuTTY session. Locate the start.sh file created earlier and execute the command sudo bash start.sh to launch the server. The server should start successfully, although it may take a few minutes to fully boot up.

To allow your friends to join, they will need to connect to your public IP address. To enable external connections, you must configure port forwarding on your router to direct traffic on Minecraft’s default port, 25565, to the Raspberry Pi Zero’s local IP address. If you have a domain name (like wordpress.com), you can link it to your home’s IP address, allowing players to connect using the domain instead of the numerical IP.

Occasionally, the server may fail to start due to perceived RAM limitations, resulting in an error message similar to this:

Exception in thread "main" java.lang.OutOfMemoryError
        at java.io.FileInputStream.readBytes(Native Method)
        at java.io.FileInputStream.read(FileInputStream.java:233)
        at com.destroystokyo.paperclip.Paperclip.getBytes(Paperclip.java:170)
        at com.destroystokyo.paperclip.Paperclip.checkJar(Paperclip.java:181)
        at com.destroystokyo.paperclip.Paperclip.run(Paperclip.java:67)
        at com.destroystokyo.paperclip.Main.main(Main.java:14)

If this occurs, simply re-run the startup command. Repeating the command usually resolves the issue.

Conclusion: Minecraft Server on a Tiny Computer

Minecraft server running smoothlyMinecraft server running smoothly

Alt text: A screenshot from Minecraft showcasing gameplay on a Skyblock server hosted on a Raspberry Pi Zero, demonstrating smooth performance with a small player base, emphasizing the project’s success.

In conclusion, running a Minecraft server on a Raspberry Pi Zero is surprisingly feasible. While it won’t accommodate dozens of players, the server is definitely capable of handling a small group of friends. With just myself playing, the server ran almost perfectly, typically utilizing around 70% CPU. If CPU usage becomes consistently high, further optimization can be achieved by fine-tuning the server configuration files to even more conservative settings.

Given the limited resources, it’s wise to prepare for potential server crashes. Implementing a script that automatically detects and restarts the server if it goes offline is highly recommended. Ideally, this script should also be configured to launch on Raspberry Pi reboot, ensuring server uptime.

It’s truly impressive that a functional Minecraft server can be hosted on a device as small and inexpensive as the Raspberry Pi Zero, especially with only a few additional components. And with careful optimization, the compromises made are minimal and shouldn’t significantly detract from the player experience, particularly within the Skyblock game mode.

If you have a Raspberry Pi Zero gathering dust, consider trying this project. It’s a fun and educational way to repurpose the device.

In a future project, I plan to explore a similar server setup using an old smartphone, so stay tuned for that!

Thank you for reading!

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

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