Difference between revisions of "User:CounterPillow/Quartz64 Minecraft Server Guide"

From PINE64
Jump to navigation Jump to search
Line 1: Line 1:
{{warning|'''This article is a work-in-progress and incomplete, if you came here from a search engine, turn back.'''}}
{{warning|'''This article is a work-in-progress and incomplete, if you came here from a search engine, turn back.'''}}
{{hint|'''For prospective editors:''' This guide was authored by [[User:CounterPillow]]. Please read the lengthy comment at the top of the article in the edit window before trying to contribute to it in any way.}}
<!--FOR EDITORS PLEASE READ AND RESPECT
This guide makes a lot of deliberately chosen recommendations, and does not suggest "alternatives". This is on purpose. The author weighed the options against each other, and chose one they felt was the best fit for the situation to streamline the guide. This helps avoid needlessly bloating an already lengthy guide, and reducing user confusion. For this reason, the guide will remain in CounterPillow's user namespace.


Please respect that this is the work of an individual and you should not tamper with their author voice. In particular:
- Do not suggest alternative ways of doing a thing, e.g. alternative disk formatting tools, alternative OS images, alternative firewall management systems, the blight upon humanity that is Docker, and so on.
- Do not alter the recommendations made, especially not in the Security Advice and Maintaining Your Server sections.
- Do not reorder sections or steps, the order they're done in is usually deliberately chosen to introduce new concepts as few at a time as possible.
What you may do is contribute fixes such as typo/grammar fixes, or illustrative diagrams for explained concepts or hardware configurations. If you think you have something to contribute beyond that, please discuss it with CounterPillow first.
TL;DR: Don't shit up my guide. I put a lot of time into it, and it's opinionated for a reason.
-->
This guide details how to build and set up a small Minecraft (Java Edition) server on a [[Quartz64]] Model B single board computer. The guide is intended to cover the basics in detail so that inexperienced users can follow it.
This guide details how to build and set up a small Minecraft (Java Edition) server on a [[Quartz64]] Model B single board computer. The guide is intended to cover the basics in detail so that inexperienced users can follow it.


Line 338: Line 349:


A more advanced option is <code>vim</code>. You can run a lengthy interactive guide to using vim with the command <code>vimtutor</code>. Learning vim is a whole can of worms in of itself, so it's best to stick to nano if you're unsure.
A more advanced option is <code>vim</code>. You can run a lengthy interactive guide to using vim with the command <code>vimtutor</code>. Learning vim is a whole can of worms in of itself, so it's best to stick to nano if you're unsure.
=== Permissions ===
{{hint|'''TODO:''' Write a section explaining file ownership and permissions.}}


== Setting Up The Network ==
== Setting Up The Network ==


{{note|'''TODO:''' Explain how to either use reserved DHCP leases or configure a static IP with NetworkManager, and how to set up a persistent firewall that allows ports 22/tcp and 25565/tcp.}}
=== Configuring A Fixed LAN IP Address ===
 
By default, the Plebian images use NetworkManager to automatically configure the ethernet interface in such a way that it asks your router to assign it an IP address inside your local network with a protocol called DHCP. What happens is that the Quartz64 asks the router for an IP address, and the router hands it one from a pool of addresses for a limited span of time, a so-called "lease". Dynamically configuring the IP address like this is great for quickly getting started, especially when in combination with mDNS, as everything just works automatically out of the box.
 
However, a bit later on in this guide, we'll want the router to know exactly what IP address our Quartz64 Model B is going to respond to even across power cycles of either device. That's why at this point, we'll set it up to have a fixed local network address, with '''one''' of two methods.
 
==== Method A: Using Reserved DHCP Leases ====
 
With this method, we'll simply configure your router to always hand the same IP address out over DHCP for the hardware address (MAC) of your Quartz64 Model B.
 
Many routers will have a web interface through which you can configure them. To find your router's IP address, type <code>ip route</code> into your SSH session with the Quartz64 Model B and hit enter to run the command. It should output something like:
 
default via 192.168.0.1 dev end0 proto dhcp src 192.168.0.58 metric 100
192.168.0.0/24 dev end0 proto kernel scope link src 192.168.0.58 metric 100
 
In this case, we can see that our router is <code>192.168.0.1</code>, as the ''default via'' route goes through it. Yours may be different.
 
You can now type this router IP address into your web browser, and with any luck, you'll be greeted with a web login prompt. If you've never set a password on your router's management interface, check the bottom or sides of your device for a sticker that lists a default password.
 
The precise management interface differs from router to router, so this guide can't give precise instructions. However, once logged in, there is usually a section labelled "DHCP". In it, you may be able to configure reserved IP addresses for a specific MAC address. To find the MAC address of your Quartz64 Model B, run "ip link" on it, which will give you output like this:
 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: end0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 76:36:c7:c4:57:e2 brd ff:ff:ff:ff:ff:ff
 
What we want here is the first colon separated address in the second link (end0), in this case <code>76:36:c7:c4:57:e2</code>. Your router should let you enter this MAC address somewhere to reserve a specific address from the DHCP pool for it.
 
==== Method B: Using A Fixed IP ====
 
If Method A isn't available to you, this method should always work.
 
Instead of using DHCP to request a lease for an IP address, our Quartz64 Model B can also simply assume it can communicate using a fixed IP address.
 
'''Important:''' Our fixed IP address should be ''outside'' the range of IP addresses our router hands out through DHCP, as otherwise collisions may occur! In the router web interface, look for a DHCP start address field and DHCP pool size field. An IP address either smaller than the start address (though above 0 and not colliding with the router's address) or larger than the start address plus the pool size (though below 255) will work; you may have to reduce the size of the DHCP pool if it's all maxed out though.
 
For example, with a DHCP pool that starts at 192.168.0.40 and has a size of 215, we could use a fixed IP address like 192.168.0.10 without accidentally colliding with one the router hands out.
 
Run the command
 
sudo nmtui
 
which should open up an interactive connection editor. Use your cursor keys to highlight the entry "Wired connection 1", and hit the right arrow key to navigate towards the "Edit" option, and hit enter.
 
Navigate to "IPv4 CONFIGURATION" and hit enter on "&lt;Automatic&gt;", then select "&lt;Manual&gt;". Navigate to the right over the "&lt;Show&gt;", and hit enter again. You should now be greeted by a whole host of options:
 
# In "Addresses:", hit "&lt;Add...&gt;" and enter your chosen fixed IPv4 address followed by <code>/32</code>, for example <code>192.168.0.21/32</code>.
# In "Gateway", enter your router's IPv4 address.
# In DNS Servers, enter on "&lt;Add...&gt;" and add <code>1.1.1.1</code>. Repeat the same process, but with <code>1.0.0.1</code>. This will add Cloudflare's DNS servers, as we'll no longer be receiving the router's DNS servers with manual configuration.
# Check the box next to "Ignore automatically obtained DNS parameters" by navigating over it and hitting the space bar. This makes sure that if our router tries to give us some DNS servers anyway, we don't use them.
# Check "Require IPv4 addressing for this connection" in the same way.
# Just to be consistent, go to "IPv6 CONFIGURATION", but this time leave it on Automatic. Hit "&lt;Show...&gt;" to expand it.
# Add the following two Cloudflare DNS servers: <code>2606:4700:4700::1111</code> and <code>2606:4700:4700::1001</code>.
# Check "Ignore automatically obtained DNS parameters".
# Navigate down to "&lt;OK&gt;" and hit enter
# Hit escape twice to quit nmtui
 
The easiest way to make sure your new network connection settings are used is to reboot your board with
 
sudo reboot
 
After logging back in, the command
 
ip addr
 
should show your chosen IP under end0 after "inet".
 
=== Configuring A Firewall ===
 
{{note|'''TODO:''' Explain how to set up a persistent firewall that allows ports 22/tcp from LAN and 25565/tcp from anywhere.}}


== Formatting The NVMe Drive ==
== Formatting The NVMe Drive ==


{{note|'''TODO:''' Explain how to wipefs + fdisk + format the NVMe drive, make a mountpoint and put it in fstab.}}
{{note|'''TODO:''' Explain how to wipefs + fdisk + format the NVMe drive, make a mount point and put it in fstab.}}


== Setting Up The Minecraft Java Edition Server ==
== Setting Up The Minecraft Java Edition Server ==

Revision as of 18:05, 11 September 2023

Warning: This article is a work-in-progress and incomplete, if you came here from a search engine, turn back.
For prospective editors: This guide was authored by User:CounterPillow. Please read the lengthy comment at the top of the article in the edit window before trying to contribute to it in any way.

This guide details how to build and set up a small Minecraft (Java Edition) server on a Quartz64 Model B single board computer. The guide is intended to cover the basics in detail so that inexperienced users can follow it.

Note: If you have a 12+ year old child interested in computers and have some experience yourself, this could be a great guide to work through with them.

Introduction

Motivation

You may ask yourself why one would want to host a Minecraft server themselves instead of renting one. That is a valid question, and one big consideration is running cost. Buying the hardware and running the software yourself from your own internet access means that you're only paying a one-time cost (ignoring the minuscule power draw), whereas renting a server would usually incur a monthly fee. Since it's your server, you also have complete control over the software you run. Lastly, it's a great and fun way to learn about Linux system administration.

As for disadvantages, the server will only be as available as your home internet connection and electricity supply, and you yourself are responsible for keeping your system safe and up-to-date. The server is also not very high performance. It's best for a small group of friends, and not suitable for a public server that is likely to come under DDoS attacks.

In the below table, you can see a comparison between paying Microsoft for a realms server and self-hosting it according to this guide.

Minecraft Realms Self-Hosted
Setup Cost USD 0 USD ~130
Monthly Cost USD 7.99 USD 0
Modifications No Yes
Players 10 Uncapped
Availability Always Depends on you
Security Provided by Microsoft Your responsibility
Performance High Low
Full Shell Access No Yes
Teaches You Linux No Yes

Ignoring all points other than cost and assuming a USD 0.30/kWh rate for power with an average power draw of 3W for the board, the Quartz64 Model B as it is set up in this guide will have paid for itself in less than 18 months.

Game Plan

Let's get a high-level overview of what will be set up in this guide.

The goal is to have the base operating system (Debian Bookworm, using the Plebian images) installed on the microSD card. The Minecraft server itself will read and write its data from an NVMe M.2 SSD. The Minecraft server we'll use is PaperMC. We'll run it as a locked down systemd service. To make the server available to others on the internet, we'll use ddclient with DuckDNS to get ourselves a domain name for our (likely) dynamic IP, and forward the ports on the router.

Shopping List

Total cost: Around USD 130 excluding shipping.

From Pine Store

Note: When choosing "Courier Shipping" on Pine Store, you may unfortunately be charged additional import duties once the package arrives. How high these are depends on your jurisdiction, the order value and the courier Pine Store chooses.

From Elsewhere

  • A good 32GB microSD card for the operating system — USD ~15
    • SanDisk Max Endurance is a decent brand, Samsung EVO is fine too.
    • Even if the brand looks correct, buy from a reputable marketplace and seller: fakes are common! Double-check who's selling it to you on e.g. Amazon.
    • Avoid no-name cards, like the ones from Pine Store, or cards that aren't intended for longevity but maximum speed.
  • A TLC flash 500GB or higher capacity NVMe M.2 drive — USD ~35
    • Look at the SSD spreadsheet and pick a cheap one with TLC, and either DRAM or HMB
    • PCIe 3/4 doesn't matter, it'll run at one lane of PCIe 2 anyway
    • Decent usually cheap options: Kioxia Exceria, Patriot P300, Lexar NM620, WD Blue SN570
    • Avoid: Kingston NV1/NV2 (no cache, meaningfully slow here), anything with QLC flash (could be meaningfully slow here), anything SATA/AHCI (won't work), anything Aliexpress (fraud).
    • Shop around for deals and used drives! Just look up the manufacturer and model in the spreadsheet to verify that it's both TLC and has either DRAM or HMB cache. Bandwidth will be severely limited by the Quartz64's one lane of PCIe 2 here so paying a lot is not worth it.

Things You Hopefully Already Have

  • A microSD card reader (your laptop may have one built-in already), USB3 microSD card readers are cheap and useful.
  • An ethernet Cat5e or Cat6 or Cat6a cable (though technically you could run it on Wi-Fi)

Getting Started

Unbox your Quartz64 Model B. Carefully attach the U.2 wireless antenna (the little grey wire with the sticker on the end) to the antenna connector that can be found near the Wi-Fi chipset (the shiny metal square). If you do not need Wi-Fi, you can skip attaching the antenna. Now is a good time to stick on the tiny aluminium heatsink; remove the protective film on its bottom and stick it onto the black chip in the centre labelled "Rockchip".

Take the baseplate from your Acrylic Open Enclosure, the small screws, and the brass nuts. Insert the screws from below the base plate (top side is the one with the acrylic standoffs) through the standoffs. Place your Quartz64 Model B board on the standoffs such that the screw threads poke through its mounting holes, oriented such that the board ends up in the middle of the base plate; the standoffs are not centred on purpose, so orientation matters. Now, secure the board by fastening the four brass nuts onto the exposed screw threads.

Next, get the large screws and metal posts, as well as the top acrylic plate. Insert the large screws through the bigger outside holes of the base plate, and fasten the metal posts on the other side. Lay the top plate on the four metal posts, and fasten it down with the remaining four large screws.

Connect the board with an ethernet cable to your network, but do not hook up power yet.

Stick your microSD card into your SD card reader, then follow Plebian's official flashing instructions.

Once it's flashed successfully, stick the microSD with the black bottom facing upwards into the underside of the board, below the metallic Wi-Fi chipset. This can be fiddly to get in with the board mounted to the acrylic base plate. If you're unsure of where exactly the microSD connector on the Quartz64 Model B is, peer through the transparent bottom of the acrylic base plate.

Next, unbox the M.2 NVMe SSD, flip it around and stick it in right below where you mounted the SD card; it will awkwardly protrude from the side of the case, and the spring loading mechanism of the connector will push it against the acrylic bottom plate. As sketchy as this is, it should work, so long as you don't violently bump the protruding SSD.

First Contact

After you hook up the power supply to the barrel connector (important: not the audio jack, that would be bad), your board's LEDs should light up. After a couple dozen seconds, one of the LEDs should begin rhythmically blinking in a "heartbeat" like fashion. If the heartbeat pattern does not appear even after a minute or so, try hitting the little white switch closest to the antenna mount to reset the board. If it still doesn't appear after another minute, go to #Connecting UART.

Once you see the heartbeat pattern, you may now connect to the board over the network, using SSH.

Note: If you see a heartbeat pattern but the board never gets a DHCP lease, please follow the steps in #Is My Ethernet Broken?.

Using SSH on Windows

Recent versions of Windows 10 and 11 have SSH as well as mDNS support built-in. Click on the start menu, search for the Command Prompt and open it.

Into the command prompt, type:

ssh pleb@plebian-quartz64b.local

if everything went well, it should prompt you with a host key question. Type "yes" to accept and remember the host key for future use. If the Command Prompt says ssh is not a recognised command, look at #Installing OpenSSH On Windows.

ssh will now ask you for a password for the user "pleb". Type in "pleb" as the password. You will then be prompted to change your password; change it to something secure, then log back in (with the same ssh command again, hit the up arrow to get the previous command from your history) with your new password.

Congratulations, you are now logged into your Quartz64 Model B.

Using SSH on Linux or BSD

Make sure the OpenSSH client is installed; how depends on your distribution. If your system is set up with an mDNS resolver such as Avahi or systemd-resolved with mDNS resolution enabled, you can open a terminal and type:

ssh pleb@plebian-quartz64b.local

if everything went well, it should prompt you with a host key question. Type "yes" to accept and remember the host key for future use.

ssh will now ask you for a password for the user "pleb". Type in "pleb" as the password. You will then be prompted to change your password; change it to something secure, then log back in (with the same ssh command again, hit the up arrow to get the previous command from your history) with your new password.

Congratulations, you are now logged into your Quartz64 Model B.

Using SSH on macOS

Open a terminal by clicking on the Launchpad icon in the Dock, typing Terminal in the search field and then clicking on Terminal.

Into the newly opened terminal, type:

ssh pleb@plebian-quartz64b.local

if everything went well, it should prompt you with a host key question. Type "yes" to accept and remember the host key for future use.

ssh will now ask you for a password for the user "pleb". Type in "pleb" as the password. You will then be prompted to change your password; change it to something secure, then log back in (with the same ssh command again, hit the up arrow to get the previous command from your history) with your new password.

Congratulations, you are now logged into your Quartz64 Model B.

First Steps

TODO: Validate this.

Changing The Hostname

First up, you may want to change the hostname the board uses. We can do this quite easily; in your ssh session with the board, type

sudo hostnamectl hostname yourhost

to change the hostname to yourhost. You will be prompted for your password.

Explanation: What we just did was run the hostnamectl command as the superuser with sudo. The superuser, or sometimes called the root user, is the ultimate administrator account on Unix-like systems such as Linux: it has access to everything, and should therefore be used with appropriate caution. By prefixing a command with sudo like this, we ask for it to be run as the superuser. The user "pleb" is allowed to use sudo in this way because it is in the necessary supplementary group.

After changing our hostname, a reboot is usually a good idea; type

sudo reboot

to reboot the board. To connect to it after doing this, you'll have to use the new hostname with the .local top-level domain, for example

ssh pleb@mcserver.local

if you set your hostname to "mcserver". You will be prompted to accept the host key again, only this time, it should tell you that it already knows the host by a different name.

Changing The Username

Being called a pleb isn't very nice, so we'll change this as well. In your ssh session, type:

sudo usermod -l yourname -md /home/yourname pleb

to update your username and home folder to yourname. Don't try to use spaces in your name and don't start your new username with a number. For example, if we wanted to rename the user pleb to greg, we would type:

sudo usermod -l greg -md /home/greg pleb
Explanation: The command usermod here is run with several arguments, each separated by space. The first argument, -l, signals that the next argument will be the new user name. What follows next in our example is "greg", which is the new username we chose.

Next is the argument -md. This is actually two arguments in one, and could be written instead as -m -d in usermod's case, though this depends on the command. -m tells the command to move our old home to our new home, and -d tells it that the next argument is the path of the new home directory. In this case, we chose "/home/greg/". This is the usual expected location for a home directory for a user called "greg", though it's not a strict requirement.

Finally, the last argument is a positional argument, which usermod expects to be the current username you wish to operate on.

Then, we should also rename the user group:

sudo groupmod -n yourname pleb
Explanation: Each user also has a "login group" they belong to, usually named the same as their username (though not necessarily so). To keep it consistent with your new username, we're renaming it with the groupmod command.

Finally, log out (by either typing logout or hitting Ctrl+d, and start a new ssh session with:

ssh yourname@yourhost.local

Your prompt should now show you your new name, and the command id -gn (no sudo!) should show you that your group has been renamed as well.

Getting Our Feet Wet

If you are already familiar with basic Linux/Unix usage from the command line, you can skip this section. However, to ensure nobody is left behind, this will be a quick crash course into how to do very basic things.

Where Are We?

There is a concept of a "current working directory". Any command we run assumes relative paths are relative to this working directory. We can show the current working directory with:

pwd

This should currently show your home directory.

Creating Directories

Using the mkdir command, we can create a new directory.

mkdir foo

would create a new directory called foo in our current working directory. That's because the argument we gave it is interpreted as a path relative to the current working directory, as it does not begin with a forward slash (/).

Changing The Current Working Directory

With the cd command, we can change our current working directory:

cd foo

we should now be in the directory foo; we can verify this by running pwd again:

pwd

This should output /home/yourname/foo.

If we want to ascend the directory hierarchy by one level, we can change to the path ".." to do so; ".." has a special meaning to be the parent directory:

cd ..

If you are ever in a hurry, you can run cd without any arguments to return to your home directory.

Further Explanation: Another special directory name is .: this refers to the current directory. For example, cd . would do nothing.

cd foo/./bar would be equivalent to cd foo/bar, and cd foo/../bar would be equivalent to cd bar (into foo, up one level, into bar).

Another path component with special meaning is ~. Our shell expands this to our user's home folder. cd ~ would be equivalent to cd with no arguments.

We can also give cd an absolute path. Absolute paths start with a forward slash, and the highest level directory is simply /, the root level directory. We can change your working directory to / with cd /, but be aware that we're not allowed to write any files or make any directories here.

Listing Directories

If we want to find out what's in our current directory, we can use the ls command:

ls

We can also give it a path as an argument to list the contents of that path instead:

ls /usr

This would list the contents of the system usr directory.

To get a more detailed list, including who owns the files and what their access rights are, we can use the -l argument to ls:

ls -l

By default, ls does not list files or directories starting with a dot (.). We can give it the -a argument to list those as well, including the special . (the folder itself being listed) and .. (its parent folder) directories:

ls -al
Further Explanation: Note that we once again were able to combine the two single-letter short options into one argument. ls -al is equivalent to ls -a -l or ls -l -a.

Creating (Empty) Files

To create empty files, we can use the touch command:

touch foo

would create a new empty file named foo in our current working directory.

Further Explanation: What touch actually does is update a file's last-modified time, and create the file if it doesn't already exist. Running touch on an already existing time would only update its last-modified time, and not alter the file contents in any way.

Deleting Things

To delete an empty directory, we can use the rmdir command:

rmdir foo

would remove the foo directory, but only if it's empty.

To remove a file, we can use the rm command:

touch foo
ls
rm foo
ls

This would create a file called foo, list the current working directory to show you that it's there, then remove the file, and then list the current working directory again.

rm can also remove things recursively, in this case it's able to remove directories. Be aware though that there is no undo, if you rm something near and dear to you, you better have had backups. In the following example, we'll create a directory, then create a file in it, then delete the directory recursively by passing rm the -r argument:

mkdir foo
touch foo/bar
ls foo
rm -r foo
ls

More Useful Commands

A short list of handy commands to know:

  • cp: Copy a file (or, when recursive, a whole directory)
    • Example: cp foo bar copies file "foo" to "bar".
    • Example: cp -R foo bar recursively copies the directory "foo" and its contents to "bar".
  • mv: Move/Rename a file or directory
    • Example: mv foo bar moves a file or directory "foo" to its new name "bar".
  • man: Show manual page for a command.
    • Example: man ls shows the manual page for the ls command.
    • Use this whenever you're not sure about a command's invocation. It'll be more accurate to your situation than what an internet search will tell you, and a lot less annoying to use.
  • wget: Download a file from the internet
Useful Reminder: You can tab-complete a lot of things! For example, if you don't want to type out a whole directory name, hit tab once to complete it as far as possible, and hit tab twice to show the remaining options with how far you've completed it so far. Try typing ls /u and hitting tab, and you should have it complete to ls /usr/.

Editing Text Files

For the rest of the guide, we'll be spending significant amounts of time editing text files. That's why it's good to familiarise yourself with a terminal text editor. The simplest to use of these is nano.

nano foo.txt

opens up nano, writing to the file foo.txt. We can save to the file with Ctrl+o, and quit nano with Ctrl+x.

A more advanced option is vim. You can run a lengthy interactive guide to using vim with the command vimtutor. Learning vim is a whole can of worms in of itself, so it's best to stick to nano if you're unsure.

Permissions

TODO: Write a section explaining file ownership and permissions.

Setting Up The Network

Configuring A Fixed LAN IP Address

By default, the Plebian images use NetworkManager to automatically configure the ethernet interface in such a way that it asks your router to assign it an IP address inside your local network with a protocol called DHCP. What happens is that the Quartz64 asks the router for an IP address, and the router hands it one from a pool of addresses for a limited span of time, a so-called "lease". Dynamically configuring the IP address like this is great for quickly getting started, especially when in combination with mDNS, as everything just works automatically out of the box.

However, a bit later on in this guide, we'll want the router to know exactly what IP address our Quartz64 Model B is going to respond to even across power cycles of either device. That's why at this point, we'll set it up to have a fixed local network address, with one of two methods.

Method A: Using Reserved DHCP Leases

With this method, we'll simply configure your router to always hand the same IP address out over DHCP for the hardware address (MAC) of your Quartz64 Model B.

Many routers will have a web interface through which you can configure them. To find your router's IP address, type ip route into your SSH session with the Quartz64 Model B and hit enter to run the command. It should output something like:

default via 192.168.0.1 dev end0 proto dhcp src 192.168.0.58 metric 100
192.168.0.0/24 dev end0 proto kernel scope link src 192.168.0.58 metric 100

In this case, we can see that our router is 192.168.0.1, as the default via route goes through it. Yours may be different.

You can now type this router IP address into your web browser, and with any luck, you'll be greeted with a web login prompt. If you've never set a password on your router's management interface, check the bottom or sides of your device for a sticker that lists a default password.

The precise management interface differs from router to router, so this guide can't give precise instructions. However, once logged in, there is usually a section labelled "DHCP". In it, you may be able to configure reserved IP addresses for a specific MAC address. To find the MAC address of your Quartz64 Model B, run "ip link" on it, which will give you output like this:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: end0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 76:36:c7:c4:57:e2 brd ff:ff:ff:ff:ff:ff

What we want here is the first colon separated address in the second link (end0), in this case 76:36:c7:c4:57:e2. Your router should let you enter this MAC address somewhere to reserve a specific address from the DHCP pool for it.

Method B: Using A Fixed IP

If Method A isn't available to you, this method should always work.

Instead of using DHCP to request a lease for an IP address, our Quartz64 Model B can also simply assume it can communicate using a fixed IP address.

Important: Our fixed IP address should be outside the range of IP addresses our router hands out through DHCP, as otherwise collisions may occur! In the router web interface, look for a DHCP start address field and DHCP pool size field. An IP address either smaller than the start address (though above 0 and not colliding with the router's address) or larger than the start address plus the pool size (though below 255) will work; you may have to reduce the size of the DHCP pool if it's all maxed out though.

For example, with a DHCP pool that starts at 192.168.0.40 and has a size of 215, we could use a fixed IP address like 192.168.0.10 without accidentally colliding with one the router hands out.

Run the command

sudo nmtui

which should open up an interactive connection editor. Use your cursor keys to highlight the entry "Wired connection 1", and hit the right arrow key to navigate towards the "Edit" option, and hit enter.

Navigate to "IPv4 CONFIGURATION" and hit enter on "<Automatic>", then select "<Manual>". Navigate to the right over the "<Show>", and hit enter again. You should now be greeted by a whole host of options:

  1. In "Addresses:", hit "<Add...>" and enter your chosen fixed IPv4 address followed by /32, for example 192.168.0.21/32.
  2. In "Gateway", enter your router's IPv4 address.
  3. In DNS Servers, enter on "<Add...>" and add 1.1.1.1. Repeat the same process, but with 1.0.0.1. This will add Cloudflare's DNS servers, as we'll no longer be receiving the router's DNS servers with manual configuration.
  4. Check the box next to "Ignore automatically obtained DNS parameters" by navigating over it and hitting the space bar. This makes sure that if our router tries to give us some DNS servers anyway, we don't use them.
  5. Check "Require IPv4 addressing for this connection" in the same way.
  6. Just to be consistent, go to "IPv6 CONFIGURATION", but this time leave it on Automatic. Hit "<Show...>" to expand it.
  7. Add the following two Cloudflare DNS servers: 2606:4700:4700::1111 and 2606:4700:4700::1001.
  8. Check "Ignore automatically obtained DNS parameters".
  9. Navigate down to "<OK>" and hit enter
  10. Hit escape twice to quit nmtui

The easiest way to make sure your new network connection settings are used is to reboot your board with

sudo reboot

After logging back in, the command

ip addr

should show your chosen IP under end0 after "inet".

Configuring A Firewall

TODO: Explain how to set up a persistent firewall that allows ports 22/tcp from LAN and 25565/tcp from anywhere.

Formatting The NVMe Drive

TODO: Explain how to wipefs + fdisk + format the NVMe drive, make a mount point and put it in fstab.

Setting Up The Minecraft Java Edition Server

TODO:
  1. Install build-essential and git, download https://github.com/Tiiffi/mcrcon and build and install it.
  2. Add a minecraft system user with a minecraft group that has write permissions to the minecraft directory on NVMe, add minecraft to supplemental groups for user.
  3. Install Java, download PaperMC to the Minecraft directory, symlink it to paper.jar, run it once, accept the EULA.
  4. Edit server.properties, enable rcon with a password, enable whitelist, edit motd and set difficulty.
  5. Add the systemd unit to /etc/systemd/system/, set it to auto-start, then start it.
  6. Add player to whitelist and ops through rcon.
  7. Connect to the server for the first time!

Making The Server Accessible From Outside Your Home Network

TODO:
  1. Explain what a dynamic IP is, set up ddclient with DuckDNS, have a systemd timer for that.
  2. Explain what port forwarding is, why it's needed, and why this depends on your router. Warn not to forward port 22/tcp, only port 25565/tcp.

Maintaining Your Server

TODO:
  1. Explain how to start, stop, restart the Minecraft server with systemctl.
  2. Explain how to access server logs with journalctl.
  3. Explain how to keep PaperMC updated (including changing the symlink).
  4. Explain apt update and apt upgrade. Recommend unattended-upgrades.
  5. Explain Debian major releases and to keep an eye out for them.
  6. Recommend htop to see how CPU and RAM usage is looking.
  7. Recommend some backup solutions; rsync to flash drive, short mention of borg/borgmatic over the network.
  8. Explain how to transfer files to/from server: sftp, rsync, winscp, etc.

Security Advice

TODO:
  • Using SSH pubkey auth and disabling password login.
  • On the dangers of Minecraft server mods/plugins.
  • Do not rely on obscurity in the age of whole IPv4 scanning.
  • Not using it anymore and can't be bothered to maintain it? Turn it off.
  • On kernel updates and why they need a reboot here.
  • Why not Docker: on software supply chains and understanding how to maintain your setup.

Troubleshooting

This section contains various subsections for helping you troubleshoot problems you may have while following this guide.

Connecting UART

To hook up UART serial debug, connect your Woodpecker, ideally with a decent USB extension cord, to your computer's USB port. Make sure the yellow jumper is set to 3.3V.

Connect the GND pin of the Woodpecker to a GND pin of your Quartz64 Model B, which are coloured as black pins. A good one to use is pin number 6 (the one after the red pin 2 and pin 4), as it's right next to the other UART pins we'll need.

Next, hook up the Woodpecker's RXD pin to the Quartz64 Model B's pin number 8, which is next to (lengthwise down the row of pins) the aforementioned pin number 6, coloured in green.

Finally, hook up the Woodpecker's TXD pin to the QUartz64 Model B's pin number 10, which is down yet another pin in the same direction, also coloured in green.

TODO: Add a diagram showing the connections here.

Accessing The Serial Console On Windows

TODO: Add a guide on how to install, configure and use PuTTY

Accessing The Serial Console On Linux

TODO: Validate the serial settings here.
Warning: Some poorly written software, like gpsd or brltty, will randomly and happily claim and mess with any USB-to-serial adapters on the system, especially when you least want them to. Use sudo lsof /dev/ttyUSBn to determine whether this is the case for you if you run into any trouble with the following steps.

First, list all the available USB-to-Serial adapters on your system:

ls /dev/ttyUSB*

If you only have one plugged in, this should probably only return /dev/ttyUSB0.

Next, you have some choice of serial terminal to use: screen (likely already installed), minicom and picocom.

For screen, (replacing n with the number of your serial adapter) use:

screen /dev/ttyUSBn 1500000 cs8 -cstop

You can quit screen by hitting Ctrl+a, then hit backslash (\) and confirm with y.

For minicom, (replacing n with the number of your serial adapter) use:

minicom -D /dev/ttyUSBn -b 1500000 -8

You can quit minicom by hitting Ctrl+a, then hit q.

For picocom, (replacing n with the number of your serial adapter) use:

picocom /dev/ttyUSBn -b 1500000

You can quit picocom by hitting Ctrl+a, then hit Ctrl+q.

Accessing The Serial Console On macOS

TODO: Validate the serial settings here, and validate the device name.

Open up a terminal, then list all the available serial devices on your system:

ls /dev/tty.*

This will likely return something starting with /dev/tty.usbserial-.

Now we can open this serial port with screen as follows, replacing foo with the adapter name from the previous step:

screen /dev/tty.usbserial-foo 1500000 cs8 -cstop

You can quit screen by hitting Ctrl+a, then hit backslash (\) and confirm with y.

Using The Serial Console

If you just hooked it up to a running system, you're unlikely to see any output. You will only be able to see messages from the point on when you've opened up your serial communication program.

If your board is doing the heartbeat pattern (i.e., it booted, but you're unable to log in over the network) you can hit Enter to (hopefully) make it show you a login prompt. If the login prompt is your first time communicating with the board, use username pleb and password pleb. From then on, the serial terminal should work like any normal shell you'd have on the system, modulo some possible weirdness with special escape sequences making things a little more prone to drawing in broken ways.

If your board is not doing the heartbeat pattern, hit the reset button (small white button on side of board, the one closer towards the antenna mount) and you should be getting serial output from a fresh boot.

If you still don't get any output, make sure that you flashed the microSD card correctly, and make sure the TXD and RXD lines aren't the wrong way around. If you still don't get any output after that, your Quartz64 Model B may have defective level shifting transistors on the serial lines, and you should open a ticket with Pine Store immediately and ask for a replacement or refund.

Installing OpenSSH On Windows

On Windows 11, open the start menu, go to Settings > Apps > Optional features. If "OpenSSH Client" doesn't show up in your installed features, click on "View features" in "Add an optional feature" and search for "OpenSSH Client" and check it, then hit "Next" and "Install".

Is My Ethernet Broken?

Pine Store has sold a number of boards where the ethernet PHY chip was seemingly broken. If your board exhibits the heartbeat LED pattern but never shows up on the network, either hook up a monitor and a keyboard or use your Woodpecker to hook up to serial (see #Connecting UART) and try to log in.

After logging in, type:

sudo dmesg | grep rk_gmac-dwmac

If the output contains any lines like

rk_gmac-dwmac fe010000.ethernet end0: __stmmac_open: Cannot attach to PHY (error: -22)

then your hardware is defective, and you should open a ticket with Pine Store immediately and ask for a replacement or refund.