Setting Up a Skyfactory 4 Server on a Raspberry Pi
A while back me and my brother were looking into games that we could play together in. We decided that we were going to play a modded version of Minecraft called skyfactory. However, renting a server can be pricy. Then it hit me. I have a tiny computer, called a Raspberry Pi, that could be my solution for a cheap Minecraft server.
The Raspberry pi is without a doubt an amazing computer for its size. It’s newer generations sports up to 8Gb of RAM and a quad core CPU. It’s power and how customizable it is makes this a very popular computer for DIY projects.
Running a video game server is no light task, especially a modded version Minecraft. However, small servers have been made on Pi’s before, so I decided to see how far I could push the computer.
Before you start, you’re going to need to have a few things things to get the pi set up. The Pi that I’m using is the 4GB version. You will absolutely need the 8GB version of the Pi. 4 is simply not enough for the server to run properly.
- Raspberry pi 4 (8GB)
- 32GB micro SD card
- Micro SD card reader
- USB drive (2GB or more)
- keyboard and mouse
- Micro-HDMI cable
- Type-C Power cable
- Ethernet cable
Now that you have everything, you’ll need to load an OS on to the SD card. For this I used Raspberry Pi OS (formerly Raspbian). Alternatively you can run ubuntu, you can find a good tutorial for that here. To load the OS onto an SD card I used Raspberry Pi Imager, which can be found here.
After the imager finishes, put the SD card into the Pi and follow the steps for setting up your Pi’s OS. Make sure to use your ethernet cable to connect to your router instead of WI-FI, this will ensure a more stable connection to the server.
Next we’ll need to get our sever files on to a USB drive. We’re doing this because there is no way that I know of to get the Skyfactory 4 files through our Pi’s CLI. You can get the files from their download page here. Then just extract the files into you’re USB drive and you’re ready to go.
At this point you can optionally go to your configuration to turn on ssh. This will allow you to connect to the pi with another computer through it’s CLI.
System Setup & Install
Once you’re in your terminal type this to make sure everything is up to date:
$sudo apt update
$sudo apt install git build essential
This lets us use git commands in our CLI.
Now we want to go into our config and change our GL driver to “GL (Fake KMS)
The setting is in “Advanced Options” then “GL Driver. Once you’ve changed it exit out of the config and reboot your system.
For our server to run, we need to install the Java Development Kit 8 on our pi.
sudo apt install openjdk-8-headless
It will ask you to confirm, hit yes. once it’s done installing run the next line to check if it installed properly
Minecraft User & Tools
For security reasons we don’t want to run our server on a user with sudo privileges’. So we’re going to make another user called ‘minecraft’ that we will run our server through. To do this run:
$sudo useradd -r -m -U -d /opt/minecraft -s /bin/bash minecraft
To dissect the above code. -r creates the user as a system user, -m -d adds it to a specific home directory which is /opt/minecraft, -U creates and adds a group with the same name as the user, -s sets the default shell which in this case is /bin/bash.
Now we can switch into our new minecraft user to make some new directories to work with.
$sudo su - mincraft
Next make a directory where our server tools will live in.
$mkdir -p tools
Now we’ll get a tool that we’ll use when we run our server called mcrcon. So we’ll switch to the tools directory and use git to get the files we need.
$git clone https://github.com/Tiiffi/mcrcon.git
Next lets cd into our downloaded files, and compile the tool so we can use it.
$gcc -std=gnu11 -pedantic -Wall -Wextra -O2 -s -o mcrcon mcrcon.c
We can test that it works by typing:
Getting our server files set up
Now we need to get our server files from our USB drive to our minecraft directory. First exit the minecraft user by typing:
Next, find your USB drive (usually /media/pi) and cd into it. Now we can move our files (mine are named ‘server-files’)
$mv server-files /opt/minecraft
Now we need to cd into that directory, rename it to ‘server’ and change its ownership to the ‘minecraft’ user.
$mv server-files server
$sudo chown -R minecraft:minecraft *
That last line goes through the entire directory and sub-directories and changes all of it and it’s files ownership to the mincraft user.
Now we can switch back to our mincraft user and continue setting up our files.
$sudo su - minecraft
Now that we have our server files where we want them we can run it’s install file to set up the server.
We also need to generate our eula and property files. To do that, we’ll run our server and it will crash, generating the files we need.
$java -Xms512M -Xmx768M -jar forge-1.12.2–188.8.131.5254.jar nogui
The server will crash and ask us to change the eula.txt to true. So lets do that.
This file has a line saying ‘eula=false’ change this to ‘eula=true’. Exit and save the file. Now we need to update our server.properties to accept mcrcon.
Change ‘enable-rcon=false’ to true. And add the lines ‘rcon.port=25575’ and ‘rcon.password=strong-password’ to the lines above enable-rcon (use your own secure password).
Take note of the server port (25565) this will be important. Our server files are now set up! We can exit the minecraft user.
Minecraft as a Service
We’re not exactly done yet. Next we’ll setup minecraft to run as a service on the Pi. So we’ll create a systemd unit file.
$sudo nano minecraft.service
Now we have a blank system file we’ll fill with these settings:
ExecStart=/usr/bin/java -Xmx4096M -Xms512M -jar forge-1.12.2–184.108.40.20654.jar nogui
ExecStop=/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p strong-password stop
Exit and save the service file, and run:
$sudo systemctl daemon-reload
That reloads our system to accept the changes we made. We can now run our server by typing:
$sudo systemctl start minecraft
We can also check the status of the server.
$sudo systemctl status minecraft
and lastly we can stop our server.
$sudo systemctl stop minecraft
Now lets test if it works. Start the server, and type the following to get the Pi’s IP address.
Wait a little while (It can take a bit for the Pi to load the server) and try to connect with the IP address and the server port (EX: 123.45.678.90:25565). You should be logged in and playing minecraft on your own private server.
Finally we’re done!
IP Address & Routers
You may be able to connect and play, but nobody else can at the moment. There are a few things we need to do to make this work so that people can join.
- Set the Pi’s IP to a static address
- Configure your router to reserve that IP for the PI
- Configure your router to open the port that our server is using
To set the IP to be static type:
$sudo nano /etc/dhcpcd.conf
Add these lines to it (* use the ip address you got from typing: hostname -I)
The next two steps depend a lot on what router you have, and differs from service to service. Here is more information on reserving an IP address (DHCP reservation info). And here is more information on opening a port on a router (can be found using this)
Preferably we would also want to buy a static IP for our router from our ISP. This is because at the moment every week or so we’ll have to search our routers IP (whatsmyip) for anyone to connect to our server. More info on setting up a static IP here.
Now that your pi has a static IP and your router is configured. We can connect to our server from anywhere using your router’s IP (whatsmyip) and the server port (255645). which should look somthing like this: 123.45.678.90:25565. Now we’re done!
My Experience & Conclusion
I ran this server on my Pi for about a month until we switch to an old computer that had more RAM. We did this because my Pi was the 4GB version, and it did not let me dedicate more than 2GB. Because of that, our world lagged out A LOT, and completely crashed if we entered any other dimensions like the nether. That being said the Pi still lasted for a month before becoming unplayable. If I had the 8GB Pi, I think the experience would be fine, albeit with only two players.
I strongly believe that the 8GB Raspberry Pi is a great candidate for a small cheap personal Minecraft server.
If you are interested in setting up just a regular Minecraft world this article walkthrough will help, and did help me when making this walkthrough.