Setting Up a Factorio Server on Clear Linux and Adding Mods

Setting up a dedicated server for Factorio can significantly enhance your multiplayer experience, allowing you and your friends to play together seamlessly, even when the host is offline. Clear Linux, known for its performance and security, provides an excellent platform for hosting game servers. This guide will walk you through the process of setting up a Factorio server on Clear Linux and, importantly, how to Factorio Add Mods To Server, enriching your gameplay with community-created content.

Prerequisites

Before diving into the setup process, ensure you have the following:

  • Hardware: A dedicated machine to act as your server. Recommended specs include:

    • Intel G4560 or equivalent processor
    • 8GB RAM (or more depending on the size of your Factorio world and mods)
    • 120GB SSD (or larger)
    • Compatible Mini ITX motherboard
    • Reliable power supply
    • Suitable case
  • Operating System: Clear Linux Server installed. You can download the latest version and follow the official installation guide HERE.

  • Factorio Account: A Factorio account is required to download the headless server version.

Installing Clear Linux Server

Follow the official Clear Linux server installation guide. During the installation, it’s recommended to set a static IP address for your server for easier access. Crucially, create two user accounts during this stage:

  • Admin Account: For administrative tasks and server management (e.g., kyle).
  • Game Server Account: A non-admin account specifically for running the Factorio server (e.g., gamemaster). This separation enhances security.

Installing Factorio Headless Server

After Clear Linux is installed and you’ve logged in as your admin user (via SSH is recommended for easier command-line operations), proceed with installing the Factorio headless server.

  1. Install wget: wget is a command-line tool used to download files from the internet. Install it using the Clear Linux bundle manager:

    sudo swupd bundle-add wget
  2. Navigate to the Game Server Account’s Home Directory: Switch to the gamemaster user’s home directory, as this is where we will install the Factorio server files:

    cd /home/gamemaster
  3. Download Factorio Headless: Obtain the Factorio headless server package from the official Factorio website. You can find the download links on the Factorio Headless Server download page. For this guide, we’ll download the experimental version. Use wget to download the tar.gz package. Remember to replace the download link with the latest version you desire.

    sudo wget -O factorio_headless.tar.gz https://www.factorio.com/get-download/0.17.45/headless/linux64
  4. Extract the Package: Unzip the downloaded package using the tar command. This will create a factorio directory within the gamemaster user’s home directory.

    sudo tar xf factorio_headless.tar.gz
  5. Change Directory to Factorio Folder: Navigate into the newly created factorio directory:

    cd factorio

Configuring Your Factorio Server

Configuration is essential to personalize your server.

  1. Navigate to the Data Directory: Server settings are located in the data subdirectory.

    cd data
  2. Copy Server Settings Example File: Copy the example server settings file to create your active configuration file:

    sudo cp server-settings.example.json server-settings.json
  3. Edit server-settings.json: Use a text editor like vim or nano to modify server-settings.json. If you don’t have vim installed, you can install it using: sudo swupd bundle-add vim.

    sudo swupd bundle-add vim
    sudo vim server-settings.json

    Within server-settings.json, adjust the following parameters to your preferences:

    • name: Set your server’s name, which will be visible in the public server list.
    • description: Add a description for your server.
    • username: Your Factorio game account username.
    • token: Generate a token from your Factorio profile page on their website. Using a token is more secure than a plain text password.
    • game_password: Set a password for players to join your server.
    • autosave_interval: Configure the autosave frequency in minutes. A value of 60 is reasonable.

    Save the file and exit the text editor.

  4. Create saves and mods Directories: Navigate back to the main factorio directory and create directories for your game saves and mods:

    cd ..
    sudo mkdir -p saves mods

Factorio Add Mods to Server

This is where we focus on factorio add mods to server. Adding mods to your Factorio server is straightforward.

  1. Locate the mods Directory: You’ve already created the mods directory in the previous step: /home/gamemaster/factorio/mods.

  2. Upload Mods: Mods for Factorio are typically distributed as .zip files. You need to upload these .zip files into the /home/gamemaster/factorio/mods directory on your server. The easiest way to do this is using SFTP (SSH File Transfer Protocol).

    • Enable SFTP (if needed): Clear Linux disables SFTP by default. If you need to enable SFTP, follow the official Clear Linux guide HERE.

    • Use an SFTP Client: Use an SFTP client like FileZilla, WinSCP (for Windows), or Cyberduck (cross-platform) to connect to your Clear Linux server using the gamemaster user credentials.

    • Upload Mod .zip Files: Drag and drop your downloaded mod .zip files into the /home/gamemaster/factorio/mods directory using your SFTP client. Do not unzip the mod files. Factorio server automatically detects and loads mods from .zip files in this directory.

    Example: Replace image_url_filezilla_sftp_client.png with a relevant image URL or consider adding a screenshot of an SFTP client uploading mods if possible.

  3. Server Restart (If Already Running): If your Factorio server is already running, you will need to restart it for the mods to be loaded. If you are setting up the server for the first time, the mods will be loaded when you start the server in the next steps.

Creating a Save File and Starting the Server

Before starting the server, you need to create a save file.

  1. Create a Save File: Generate a new Factorio save file. This will be the initial world for your server.

    sudo ./bin/x64/factorio --create saves/my_save.zip
  2. Start the Factorio Server: Run the Factorio server, loading the save file you just created.

    sudo ./bin/x64/factorio --start-server saves/my_save.zip
  3. Find Your Server IP: Determine your server’s IP address using the command:

    ip a

    Note down the IP address (e.g., 192.168.85.135).

  4. Test the Server: Launch your Factorio game client, select “Play,” then “Multiplayer,” and “Connect to server.” Enter the IP address of your server. If you set a server password, you’ll be prompted to enter it. You should now be able to join and play on your new Factorio server with mods enabled!

Setting Up Factorio Community Updater (Optional but Recommended)

To keep your Factorio server updated, especially if you are using the experimental version, the Factorio Community Updater is a helpful tool.

  1. Install Prerequisites: The updater requires git and python-extras (which includes the requests library). Install them using:

    sudo swupd bundle-add git python-extras
  2. Clone Factorio Updater Repository: Use git to clone the Factorio Updater repository into your factorio directory:

    sudo git clone https://github.com/narc0tiq/factorio-updater.git
  3. Give gamemaster User Permissions: Change ownership of the Factorio directory to the gamemaster user, allowing it to run the server and updater:

    sudo chown gamemaster:gamemaster /home/gamemaster/factorio -R
  4. Switch to gamemaster User: Switch to the gamemaster user account:

    su gamemaster
  5. Create Bash Scripts: Create two shell scripts to simplify starting and updating the server.

    • start_factorio.sh: Create a file named start_factorio.sh in the /home/gamemaster directory and add the following content:

      #!/bin/bash
      ./factorio/bin/x64/factorio --start-server-load-latest --server-settings ~/factorio/data/server-settings.json
    • update_factorio.sh: Create a file named update_factorio.sh in the /home/gamemaster directory and add the following content (for experimental version updates):

      #!/bin/bash
      python3 ~/factorio/factorio-updater/update_factorio.py -xDa ~/factorio/bin/x64/factorio

      If you are using the stable version, use -Da flags instead of -xDa.

  6. Make Scripts Executable: Make both scripts executable:

    chmod +x start_factorio.sh update_factorio.sh

Open Factorio Port on Your Router

For players outside your local network to connect, you need to forward port 34197 UDP on your router to your server’s static IP address. Consult your router’s documentation for specific instructions on port forwarding.

Running Your Factorio Server

You can now start your Factorio server by running the start_factorio.sh script:

./start_factorio.sh

For persistent server operation, even when you disconnect from SSH, use tmux. Install tmux with sudo swupd bundle-add tmux and then run tmux before starting the server script. You can detach from the tmux session by pressing Ctrl+b then d. To re-attach, use tmux attach.

To update your server, stop the server (if running), and execute the update_factorio.sh script. Then, restart the server using start_factorio.sh.

Conclusion

Congratulations! You have successfully set up a Factorio server on Clear Linux and learned how to factorio add mods to server. Your server is now ready for you and your friends to embark on epic factory-building adventures, enhanced by the mods you’ve chosen. Remember to keep your server updated and explore the vast library of Factorio mods to continually expand your gameplay experience. If you encounter any issues, double-check the steps and consult the Factorio server documentation and community forums for further assistance.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *