Setting up a Metin2 Linux server looks at first glance like a simple "copy the files and run them" job. But because Metin2's server side was written for FreeBSD from the very beginning, moving it to Linux takes far more planning than expected. In this guide I'll walk through the realistic ways to run the server on Ubuntu (or Debian) instead of FreeBSD, the compatibility limits, and the step-by-step setup logic.
Why move a Metin2 server to Linux?
FreeBSD is stable and fast, but the servers most people manage day to day run Linux. The vast majority of hosting providers ship Ubuntu/Debian by default; Docker, systemd, modern monitoring tools and your team's habits all live in the Linux world. So the answer to "why Linux?" is usually not technical superiority but operational comfort: you want to manage the website, MySQL, backups and the game process on the same machine with familiar tools.
The most critical truth: FreeBSD binaries do not run on Linux
Before we start, let's clear up the most common mistake. You cannot take game and db binaries compiled on FreeBSD, copy them to Linux and run them. The two systems have different syscall interfaces and ABIs. Here's the interesting part: FreeBSD can run Linux binaries thanks to its Linuxulator layer — but the reverse is not possible, Linux has no compatibility layer for running FreeBSD binaries. That's why the only correct way to run the server on Linux is to recompile the source code for Linux.
Path 1: Compile the source for Linux (recommended)
This is the cleanest solution. The Metin2 source depends on FreeBSD's kqueue-based network model and some BSD-specific headers; on Linux you need to provide their equivalents. Many Linux-adapted sources exist in the community, and they generally include these changes:
- kqueue → epoll: the network event loop is rewritten against Linux's
epollAPI. Most modern sources already abstract this. - Header differences: Linux equivalents instead of BSD headers like
<sys/event.h>; missing#includes are added. - 32-bit build: the classic source is 32-bit, so on Linux
gcc-multiliband 32-bit libraries are mandatory.
A typical dependency install on Ubuntu 22.04 LTS looks like this:
sudo apt update
sudo apt install build-essential gcc-multilib g++-multilib \
libc6-dev-i386 cmake scons \
libmysqlclient-dev libboost-all-dev liblzo2-dev
Crypto++ (cryptopp) usually ships with the source; to avoid clashing with the system version, it's safest to use the one bundled with the source. The build order follows the same logic as on FreeBSD: libraries first, then the executable processes.
libthecore -> core system abstractions
libpoly -> geometry / collision
libsql -> database layer (MySQL)
libgame -> shared game logic
db -> database process
game -> game process
When building 32-bit, make sure the -m32 flag is passed at every step; otherwise, trying to link 64-bit and 32-bit objects together will give you "incompatible" linker errors.
Path 2: Run FreeBSD in a virtual machine
If you don't want to deal with compiling the source and the files you have are already built for FreeBSD, the most pragmatic solution is to run a FreeBSD virtual machine on top of a Linux host. With Proxmox, KVM/QEMU or VirtualBox you install a FreeBSD guest, run the server there, and use the Linux side only for the website, reverse proxy and backups. This approach doesn't fully meet the "run on Linux" goal, but it lets you keep the original binaries untouched inside a familiar Linux infrastructure.
Path 3: Package it with Docker
Docker containers share the Linux kernel, which means you can't run a FreeBSD binary inside Docker either. But putting a server compiled for Linux into a Docker image makes a lot of sense: it pins the 32-bit libraries into the image, keeps MySQL in a separate container and makes the whole setup reproducible. A simple Dockerfile skeleton starts like this:
FROM ubuntu:22.04
RUN dpkg --add-architecture i386 && apt-get update && \
apt-get install -y libc6:i386 libstdc++6:i386 \
libmysqlclient21 && rm -rf /var/lib/apt/lists/*
COPY ./server /server
WORKDIR /server
CMD ["./game"]
The dpkg --add-architecture i386 line is critical: 32-bit binaries need 32-bit runtime libraries to start.
Database and configuration
Whichever path you choose, the database layer is the same. Metin2 uses MySQL; on Linux MariaDB is a compatible alternative. Load the player, account, common and log schemas, then edit the port, IP and database connection details in the CONFIG files. On the first launch, be sure to watch:
tail -f syserr # runtime errors
tail -f syslog # general flow
Most "it won't start on Linux" complaints actually come from a wrong library path, a missing 32-bit package or failing to connect to MySQL — you can quickly verify missing shared libraries with ldd game and the correct header path with mysql_config --include.
Auto-starting with systemd
One of the most concrete wins of moving to Linux is systemd. By tying the server process to a service file, you can make it start automatically when the machine reboots and restart itself when the process crashes. A simple unit file looks like this:
[Unit]
Description=Metin2 game core
After=network.target mysql.service
[Service]
Type=simple
User=metin2
WorkingDirectory=/home/metin2/server
ExecStart=/home/metin2/server/game
Restart=on-failure
[Install]
WantedBy=multi-user.target
Save the file as /etc/systemd/system/metin2-game.service, enable it with systemctl enable --now metin2-game, and watch its logs live with journalctl -u metin2-game -f. This approach feels more familiar to most admins than FreeBSD's rc.d scripts and guarantees the game core stays up continuously.
Frequently Asked Questions
Can I copy my FreeBSD files to Linux and run them?
No. The game/db binaries compiled on FreeBSD won't run on the Linux kernel; the ABI and system calls are different. To run on Linux you must recompile the source for Linux or run FreeBSD in a virtual machine.
Should I build 32-bit or 64-bit on Linux?
The classic Metin2 sources are 32-bit, so for most setups building 32-bit with gcc-multilib causes the fewest problems. If you have a source fully adapted to 64-bit, you can use it, but be ready for errors caused by the difference in pointer size.
Which Ubuntu version should I use?
A long-term support (LTS) release such as 22.04 is the safest choice: it offers stable package repositories, up-to-date security patches and broad community support. On very old versions, finding 32-bit packages becomes harder.
Want to move your Metin2 server from FreeBSD to Linux? If you're stuck on compiling the source for Linux, resolving 32-bit dependencies or packaging it into Docker, get in touch with me — let's put your setup on a solid foundation together.