This guide will show you how to install a Minecraft Server on Raspberry Pi4. Ubuntu 20.10 is used for the operating system however instructions should be similar for Ubuntu 18. This guide uses James Chambers’ excellent resources for easy install of the Minecraft software.
Requirements
This guide assumes you are familiar with operation of a Raspberry Pi, writing images to SD cards, and accessing the Raspberry Pi via SSH. It also assumes you have admin access to your local modem/router for configuring port forwarding.
It is recommended to use Raspberry Pi 4 with at least 2GB of RAM.
1. Installation of Ubuntu Server on Raspberry Pi
The following are instructions for installation of a secure 64-bit Ubuntu Server 20.10 on Raspberry Pi 4 with firewall.
Ubuntu 20.04.1 LTS can also be used.
Ubuntu Installation on SD card
- Download & Extract Ubuntu Server 20.10 64-bit Version
- Download & Install Raspberry Pi Imager v1.4 Software
- Write Ubuntu Image to SD card
- Insert SD card into Raspberry Pi
Ubuntu Setup with Headless Operation + Ethernet Connection
This guide assumes Raspberry pi is connected via ethernet and we will access via SSH.
This guide gives instructions for creating a new user and for updating the hostname. These two items are optional.
We are going to be exposing your pi to the internet outside of your local modem/router so we will setup a firewall to block access except for the single port use by the Minecraft game to connect to the server.
- Power up Raspberry Pi
- Wait a couple of minutes for initial bootup
- Determine local IP address of Raspberry Pi using your favorite method
- login into your router and check the DHCP client list. Default hostname of the Pi is ubuntu
- Fing is nice application on Android that I like to use.
- Open SSH connection. Putty is a good application for windows
- Default login
- user: ubuntu
- password: ubuntu
- On first login you will be asked to change default password
- After changing password restart the SSH session with the new password
- Default login
- Login with new password
- Switch to root environment
sudo -i
- Obtain latest versions of installed packages
apt update
- update all installed packages
apt upgrade
- Add new user admin. It will ask for password.
adduser admin
usermod -aG sudo admin
exit
exit
- Close SSH connection and login using new account
- user: admin
- password: your password
- Switch to root environment
sudo -i
- Delete ubuntu user
deluser ubuntu
rm -rf /home/ubuntu
- Configure basic firewall to close all ports except for SSH and Minecraft Server port. In a later section of the guide we will open up port 25565 to the internet however we will keep SSH port available for local network access only.
ufw allow 22
ufw allow 25565
ufw enable
- Optional: Open file and change hostname from ubuntu to minecraft.
nano /etc/hostname
- Optional: Open file and add this line:
127.0.0.1 minecraft
nano /etc/hosts
- Update Time Zone. Configure your specific timezone according to this guide – https://linuxize.com/post/how-to-set-or-change-timezone-on-ubuntu-18-04/
- To get list of available timeszones:
timedatectl list-timezones
- Configure Timezone Example:
timedatectl set-timezone America/Cambridge_Bay
- To get list of available timeszones:
- Find MAC address. This will be used later. The address will be after the line starting with link/ether
ip address show
- Reboot with new settings
reboot
2. Configure DHCP Reservation
The locally IP address of your Minecraft Server may change over time if your router or Pi is rebooted. Prior to configuring Port Forwarding it is best to reserve a permanent local address.
In the advanced setting of your router look for DHCP Reservation settings. It will look something like this. Select the MAC address and IP address of your Pi and save.
3. Port Forwarding
The Minecraft server communicates to the players via internet port 25565. This is normally blocked so you need to reconfigure this in your router.
The Port Forwarding configuration in your router should like similar to the screenshot below. In this case port 25565 has been forwarded to local IP address 192.168.1.90.
4. Install Minecraft server
James Chambers has a great installation script. The following instructions are based on his guide. See his guide for more details.
- SSH using user admin
- download james’ script
wget https://raw.githubusercontent.com/TheRemote/RaspberryPiMinecraft/master/SetupMinecraft.sh
- make script executable
chmod +x SetupMinecraft.sh
- run setup script
./SetupMinecraft.sh
The script will setup the Minecraft sever and ask you some questions on how to configure it.
- Use the recommended memory allocation settings.
- I found that the automatic reboot was not working correctly so I disabled this feature. I haven’t had a chance to debug.
- If you enable the Minecraft server to startup automatically on boot it will also do a backup before starting.
5. Start, Stop and Restarting Server
The server is setup to autostart on boot.
If you need to manually configure use the following:
cd ~/minecraft
./start.sh
./stop.sh
./restart.sh
-OR-
sudo systemctl start minecraft
sudo systemctl stop minecraft
sudo systemctl restart minecraft
To switch to server console screen
screen -r minecraft
To detach from sever console screen
ctrl-A then ctrl-D
To view running screens
screen -list
To edit server properties
cd minecraft
nano server.properties