I created an Ubuntu 24.04 VM inside Windows 2022 Standard Hyper-V.  I am consolidating minecraft games we play as a family onto one Ubuntu server.   The address is 10.10.10.9 currently.   A new server has replaced it.  Notes are still the same.  IPv4 and IPv6 changed.  

I created systemd service files to launch Java Minecraft on boot of Ubuntu.  The screen instances stay up for about a minute and crash.  I can’t find the reason why.   I gave up for now.  

Hyper-V configuration of Ubuntu Server for Minecraft 

10 vCPUs
20 GB RAM

New-VHD -Path ‘E:\Hyper-V\Java2404_10.10.10.9\Java2404_10.10.10.9_boot.vhdx’ -SizeBytes 1500MB -Dynamic -BlockSizeBytes 1MB 
New-VHD -Path ‘E:\Hyper-V\Java2404_10.10.10.9\Java2404_10.10.10.9_root.vhdx’ -SizeBytes 50GB -Dynamic -BlockSizeBytes 1MB 
New-VHD -Path ‘E:\Hyper-V\Java2404_10.10.10.9\Java2404_10.10.10.9_swap.vhdx’ -SizeBytes 16GB -Dynamic -BlockSizeBytes 1MB 

 df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 392M 956K 391M 1% /run
efivarfs 128M 32K 128M 1% /sys/firmware/efi/efivars
/dev/sda1 49G 5.9G 41G 13% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sdb2 927M 105M 759M 13% /boot
/dev/sdb1 537M 6.2M 531M 2% /boot/efi
tmpfs 392M 12K 392M 1% /run/user/999

Protecting the minecraft games from outside attacks

The Fortinet Firewall blocks all outside access from these minecraft servers.  I made sure no virtual IPs or policies exist.   My next plan is to get IPv4 and IPv6 configured on the server.   The Fortinet DNS Server will have entries for IPv4 and IPv6.   The server has UFW installed on it.   

UFW firewall commands
sudo ufw allow 25560:25595/udp
sudo ufw allow 25560:25595/tcp

My wife, son, daughter and I play minecraft.   I researched the best configuration for 4 players.   Currently, I have it set for only IPv4. It is set for 2 vCPUs only per game.  Only our Folia multicore server is allowed more vCPUs.  Most Java Minecraft games use 1 vCPU for most of the processing.  

Configuration of each Minecraft game

user_jvm_args.txt

-Djava.net.preferIPv4Stack=true
-Djava.net.preferIPv4Addresses=true
-Xmx4G
-Xms1G
-XX:+UseZGC
-Dio.netty.transport.noNative=true

Server.properties

view-distance: 6 Reduces the number of rendered chunks per player.
simulation-distance: 6 Limits the number of chunks that are actively simulated.
max-players: 4 Sets the maximum number of players allowed on the server.
allow-flight: true Enables flight for players using mods in Survival mode.
sync-chunk-writes: false Allows asynchronous chunk saving, reducing server load.

The Ubuntu servers have IPv4 and IPv6 running on them.  Java Minecraft has issues with IPv6.  I am looking at upgrading the network to 2.5G with adapters that fully support IPv6.   Java Micnecraft authentication servers are having IPv6 issues.  I added the commands for IPv4.  Check out the section above on Install Oracle Java 25 .  I spun up a new Java Master Server with 50 GB of root space and 16GB swap partition.  It is using Oracle Java 25 (OJ25).   All the instances below are working on OJ25.  I did this to start upgrading Java Minecraft to 26.1.2.  To get OJ25 working, I added to the run.sh /usr/jvm/jdk-25/bin before java.   See the Java notes.  

sudo useradd -r -m -d /opt/minecraft mcserver

The user that was created for Java Minecraft is mcserver.  It is a normal user.  No root or sudoers.   I set its home to /opt/minecraft.  The group is mcserver:mcserver.   I boot up this user for setting the screens for 6 instances.   

Java_26.1.2

10.10.10.9:25560
neoforge-26.1.2.42-beta-installer.jar

It is using four mods including Xearo’s World Map, Enhanced Farming, Security Craft, and JEI.

screen -dmS java-26.1.2
screen -r java-26.1.2
cd /opt/minecraft/java-26.1.2
sudo ./run.sh

java-neoforge-mod

10.10.10.9:25565
neoforge-21.1.226-installer.jar

Commands to create the session java-neoforge-mod and load the first Java Minecraft Server

screen -dmS java-neoforge-mod
screen -r java-neoforge-mod
cd /opt/minecraft/java-neoforge-mod
sudo ./run.sh

java_neo_easy_surv

10.10.10.9:25570
neoforge-21.1.226-installer.jar

Commands to create the session java_neo_easy_surv and load the second Java Minecraft Server

screen -dmS java-neo-easy-surv
screen -r java-neo-easy-surv
cd /opt/minecraft/java-neo-easy-surv
sudo ./run.sh

java_peaceful_survival

10.10.10.9:25575
server.jav (26.1.2)

Commands to create the session java_peaceful_survival and load the third Java Minecraft Server

screen -dmS java-peaceful-survival
screen -r java-peaceful-survival
cd /opt/minecraft/java-peaceful-survival
sudo ./run.sh

skyblock

10.10.10.9:25580
neoforge-26.1.2.42-beta-installer.jar

Commands to create the session skyblock and load the fourth Java Minecraft Server

screen -dmS skyblock
screen -r skyblock
cd /opt/minecraft/skyblock
sudo ./run.sh

java_oneblock

10.10.10.9:25585
minecraft_server_1.21.11.jar

Commands to create the session java_oneblock and load the fifth Java Minecraft Server

screen -dmS java-oneblock
screen -r java-oneblock
cd /opt/minecraft/java-oneblock
sudo ./run.sh

A quick backup script for my Hyper-V VMs.

# Import the Hyper-V module
Import-Module Hyper-V

# Define parameters
$BackupDriveLetter = "E" # Change to your backup drive
$VMHost = "localhost" # Change if backing up from a different host
$VMNames = @("Bedrock2404_10.10.10.3",
"Bedrock2404_10.10.10.4",
"Bedrock2404_10.10.10.5",
"Java2404_10.10.10.6",
"Java2404_10.10.10.7",
"Java2404_10.10.10.9",
"PaperMC_10.10.10.8" ) # List of VMs to back up

Remove-Item -Path E:\VMBackups -Recurse -Force


# Function to back up VMs
function Backup-VMs {
param (
[string]$BackupDriveLetter,
[string]$VMHost,
[string[]]$VMNames
)

foreach ($VMName in $VMNames) {
# Export the VM
Export-VM -Name $VMName -Path "E:\VMBackups\$VMName"
}
}

# Call the backup function
Backup-VMs -BackupDriveLetter E -VMHost $VMHost -VMNames $VMNames