Factorio - jonatello/lab-musing GitHub Wiki

Due to glibc-2.17 being compiled with the current CentOS 7 base set of packages, and the inability to update this to glibc-2.18 (or my ignorance in knowing how), this guide is using Factorio version 0.15.40 as the glibc-2.18 dependency appears to have started in 0.16.36

Note that this does require Linux binary compatibility, so on your host set "enable_linux=yes" within "rc.conf". If you're using FreeNAS, you would go under System > Tunables > Add Tunable, and add an entry with variable set to "linux_enable", value set to "yes", and type set to "rc.conf".

Configuration

Enable Linux ABI support via rc.conf (sometimes called Linux emulation)

sysrc linux_enable=yes

On the host (assuming this is a jail), load the Linux64 compatibility layer and set it to start on boot

kldload linux64

service abi restart

Still on the host, Add the following lines to /etc/fstab

linprocfs /compat/linux/proc linprocfs rw 0 0

linsysfs /compat/linux/sys linsysfs rw 0 0

tmpfs /compat/linux/dev/shm tmpfs rw,mode=1777 0 0

Run the following commands to mount these new system changes

mount /compat/linux/proc

mount /compat/linux/sys

mount /compat/linux/dev/shm

Now back within the jail's console, verify linux64 is listed

kldstat

Install the CentOS 7 base set of packages

pkg install linux_base-c7

Install wget so we can download Factorio

pkg install wget

Normally you would then want to use the URL https://www.factorio.com/get-download/latest/headless/linux64, but in our case because we want to avoid the glibc-2.18 dependency, we'll use an older version (I had to force wget to not check the certificate they are utilizing)

wget https://www.factorio.com/get-download/0.15.40/headless/linux64 --no-check-certificate -O factorio.tar.gz

Create the "opt" directory and uncompress the package to this location, remove the original compressed package

mkdir /opt

tar -xvf factorio.tar.gz -C /opt

rm -rf factorio.tar.gz

Add the factorio user

adduser factorio

Make a copy of the default server config file to be used

cp /opt/factorio/data/server-settings.example.json /opt/factorio/data/server-settings.json

Replace the token with your actual player token (replace "ReplaceMe"). You might also want to modify the User, Name, Description, and other settings (they're well commented within the config)

sed -i '' 's/"token": ""/"token": "ReplaceMe"/g' /opt/factorio/data/server-settings.json

Confirm the game can launch normally using a non-existent save file (it will fail with "File /root/savename does not exist.")

/opt/factorio/bin/x64/factorio --start-server savename

Make the saves and mods folders for saved games and mods to be added

mkdir /opt/factorio/saves

mkdir /opt/factorio/mods

Set the factorio user to be the owner of the factorio directory

chown -R factorio:factorio /opt/factorio

Change to the factorio user and launch the server

su factorio

At this point you would want to copy your existing savefile up to /opt/factorio/saves/safefile.zip and make sure you have a proper NAT firewall rule for 34197/UDP, you can then run the following to start the server

/opt/factorio/bin/x64/factorio --server-settings /opt/factorio/data/server-settings.json --start-server-load-latest /opt/factorio/saves/savefile.zip --port 34197