Installing Minecraft server on a Raspberry Pi 4
Running Minecraft on a raspberry Pi 4 is fun and simple. Device is powerful enough to host several players and plugins.
I set up one for my son and his friends and it has been running ever since without any issues.
First install ubuntu on a SD-card.
- Download 64Bit version of ubuntu server from https://ubuntu.com/download/raspberry-pi
- Write image to SD-card by using etcher
- After writing is complete edit network-config file on card to set your Raspberry Pi for static IP (replace with something from your own network).
ethernets:
eth0:
addresses:
- 192.168.1.20/24
gateway4: 192.168.1.1
nameservers:
addresses: [192.168.1.1]
optional: true
After editing the file plug SD-card to Raspberry Pi and power it on.
- SSH to Raspberry (User: ubuntu Password: ubuntu)
- Update packages by running sudo apt-get update && sudo apt-get upgrade -y
- Install Java JDK. I choose Amazon Corretto for it’s security and speed.
wget -O- https://apt.corretto.aws/corretto.key | sudo apt-key add -
sudo add-apt-repository 'deb https://apt.corretto.aws stable main'
sudo apt-get update; sudo apt-get install -y java-17-amazon-corretto-jdk
Now it is time to install Minecraft. I selected PaperMC again for it’s speed.
- Create new directory for Minecraft server: mkdir minecraft
- Download latest PaperMC build from https://papermc.io/downloads wget https://api.papermc.io/v2/projects/paper/versions/1.20.1/builds/84/downloads/paper-1.20.1-84.jar
- Move paper-1.20.1-84.jar to minecraft folder and rename: mv paper-1.20.1-84.jar minecraft/server.jar
- create euta.txt echo eula=true > minecraft/eula.txt
Now we are ready to start the server but it would not survive reboots. For that we need to create service configuration.
- create new file and paste configuration below to it sudo nano /etc/systemd/system/minecraft-server.service
[Unit]
Description=Minecraft Server
After=network.target
[Service]
WorkingDirectory=/home/ubuntu/minecraft
Environment=MC_MEMORY=3072M
ExecStart=java -Xmx${MC_MEMORY} -Xms${MC_MEMORY} -jar server.jar nogui
StandardOutput=inherit
StandardError=inherit
Restart=always
User=ubuntu
[Install]
WantedBy=multi-user.target
After saving the file run sudo systemctl daemon-reload and enable service sudo systemctl enable minecraft-server.service
Now you are ready to start your server by issuing sudo systemctl start minecraft-server.service
If you want to be able to interact with server using your keyboard, then use alternative service configuration below. Also adjust Environment=MC_MEMORY=3072M to match your Rpi version. (i.e. 7168M for 8GB model).
Remember to install screen if not already installed by running command: sudo apt-get install screen
[Unit]
Description=Minecraft Server
After=network.target
[Service]
WorkingDirectory=/home/ubuntu/minecraft
Environment=MC_MEMORY=3072M
Type=forking
ExecStart=/usr/bin/screen -dmS minecraft /usr/bin/java -Xmx${MC_MEMORY} -Xms${MC_MEMORY} -jar server.jar nogui
StandardOutput=inherit
StandardError=inherit
Restart=always
User=ubuntu
[Install]
WantedBy=multi-user.target
With this configuration you can access console by typing screen -R minecraft and close it with key combination ctrl+a+d
Nice guide!