I wanted to set up a Minecraft server (there’s not as much activity this summer due to the pandemic) but I know very little about it. So I did some quick research, found some guides that seemed to look like they would work, and dove right in. Mostly this post is for me to remember which guides I followed. There were lots of possible ways to do it but the ones listed here happen to be the ones I followed.
I used some really old hardware I had hanging around. A Dell Dimension 5150 with a Pentium D 925 in it with 4 Gb RAM and an 80 Gb hard drive that I pulled from another computer to max out this old computer. I actually started by trying the other computer which is a Dimension E520 but remembered that computer ended its regular service life when something failed on the motherboard and the fan would turn on max speed but the 5150 motherboard was still working so I moved the stuff to the 5150.
With such old hardware, I didn’t want to tax it with Windows 10 or Windows anything really. Ubuntu seemed like the best OS to get that’d be free and would work on old hardware without needing lots of admin work on my part. And the 80 Gb drive didn’t have anything on it I needed to keep so I had no problem wiping it all during the Ubuntu install.
First, I tried to burn a DVD to do the install but I couldn’t get it to be bootable correctly. It could be related to UEFI and the fact that the old computer doesn’t have an option for that in the BIOS. I’m still annoyed about that but I figured it was going to be faster to just follow instructions for a USB installation. For the part of the instructions where it says to download the latest, I used 20.04 Desktop.
I booted up into the test environment just to make sure the computer would be usable before I went through the trouble to do the install. It was slow but I figured it was at least partly due to running from the USB drive (and this computer long predates USB 3.0 ports). So after it was booted up and running, I clicked the icon to proceed with the installation. From then on, I did follow instructions for the installation but it was pretty much the standard default install. When it came to the question of what to do with the existing system installed on the hard drive, I gave the go-ahead to wipe it out and use the whole drive which really simplifies the Ubuntu installation.
Now for the Minecraft installation, I followed instructions at linuxconfig.org. I liked the fact that the tools used are pretty basic and don’t require a lot of additional work. I really don’t want to turn this into a thing I spend time on. Just something where I can turn the power on or turn the power off. The instructions give the option of having a second Minecraft server running on the same computer but this computer is old enough I figured one was going to be plenty. The instructions suggest naming the first server “survival” but that seems confusing to me since that’s a mode in Minecraft so I went with “server1” (and therefore needed to substitute “server1” in all the places where it has “survival”). I almost simplified the process by skipping the level of separate servers but decided against it in case there was a reason to keep the levels separate.
The server software I downloaded is minecraft_server.1.16.1.jar and I saved the download with that name in the directory described in the instructions. Then in that same directory I created a symbolic link from minecraft_server.jar to that file. I actually tried the wget method described in the instructions but strangely the download failed without me realizing and I ended up with a corrupt jar file. I did it in the web browser and it worked fine. When the download was corrupt, nmap reported that the port state was closed. But once I got the right jar, nmap reported the port state was open.
I also did follow the instructions for making it so the Minecraft server starts up every time the server boots. And I also ran the following command to make sure I didn’t hit any firewall issues:
sudo ufw allow 25565/tcp
And then I configured my router to allow for external access. I was able to confirm that it worked in a Minecraft client. Woo hoo!
Well, almost woo hoo. One snag is that in the log file (/opt/minecraft/server1/logs/latest.log) there are a lot of messages that say “Can’t keep up! Is the server overloaded?” followed by how many milliseconds and “ticks” it is “running behind”. I think that means that the hardware is just too old to ideally do this. So far, from a player perspective, it doesn’t look like there are any delays. (Or at least from what I’ve been told.) So I’m going to let it go for now. But I may need to find some newer hardware to properly run the server.
And yes, I have considered possibly upgrading the CPU in this old hardware. I found that the Pentium D 945 is the fastest chip that can be used in this hardware and I can get one on eBay for about $10. That’d be super cheap if it made a difference. But would it? The risk of popping in a new CPU chip almost doesn’t seem worth it for what I suspect is a slight difference. I’d probably be better off with newer hardware.
Finally, some other tweaks to make it more friendly to use. The user I used to set up Ubuntu and install the server was with my name and that makes me the admin. But I wanted to make it so the minecraft user could log in directly. I used the Ubuntu Users panel in Settings to set a password for the minecraft user. But that didn’t get the sudo privileges and shell set up like the admin user had. For that, I needed to do the following commands logged in as the original admin user.
sudo usermod --shell /bin/bash minecraft sudo usermod -aG sudo minecraft
Then I logged in as the minecraft user and edited the .bashrc file to add the following handy aliases at the end:
alias mc-log='tail -f /opt/minecraft/server1/logs/latest.log' alias mc-start='sudo systemctl start minecraft@server1' alias mc-stop='sudo systemctrl stop minecraft@server1'
The first alias is useful because it’s nice to monitor what is going on even when not running in the GUI version of the Minecraft Server. The other two aliases will likely not be used often since generally the server will be started when the computer starts up and only turn off as part of the computer shutdown. But in case anything weird happens and we want to manually restart the server, it’s nice to have simple access to these two things. (I could have probably done a “restart” but having the ability to have separation between when the stop finishes and when the start is kicked off seemed wise.)