User:IRJustman/Preparing FreeBSD to run the Linux dedicated server

From Team Fortress Wiki
< User:IRJustman
Revision as of 12:18, 15 May 2011 by I-ghost (talk | contribs) (Pruning left-over category from otherwiki import)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This document gives basic instructions for setting up a FreeBSD system to run the Linux dedicated server for Linux. I wrote it out of a perceived dearth of documentation for setting something like a Team Fortress 2 server up under FreeBSD.

A quick primer, FreeBSD is not a Linux distribution of any kind. In fact, it does not use Linux at all. As such, it cannot run Linux programs by default. However, it does include facilities to enable running Linux programs, which needs some setup.

Introduction

Let's say you want to host a Team Fortress 2 game on a server. However, your server runs FreeBSD, which is a very popular choice of operating system in the server space.

What to do? Simple! Install the Linux compatibility layer!

This document assumes you have some experience with FreeBSD system administration. Linux experience is a plus. However, building a custom kernel is outside the scope of this document; there are plenty of HOWTOs on the Internet which cover this, including and especially the FreeBSD Handbook.

This guide also assumes you have root on the target system.

Prerequisites

Setting up Steam and the Linux dedicated server under FreeBSD require the following:

1. A FreeBSD install (i386 or amd64) with either of the following:
  • The Linux compatibility layer built as a module and loaded into the kernel
  • The Linux compatibility layer built directly into the kernel
NOTE: If you are using FreeBSD/amd64, FreeBSD 32-bit compatibility is not required.
2. A Linux base setup installed. This usually includes necessary shared libraries, core binaries (e.g. bash, tar, gzip), and various config files found on a typical Linux system. This is typically installed via the ports collection.
3. (Recommended) A separate account for running Steam and the supported game servers. You may wish to create a separate account just for running Steam and the games it supports to keep your own account secure.

Configure FreeBSD

Linux kernel-level support

The GENERIC kernel installs with most functionality as modules which can be loaded and removed from the running kernel as needed. If you are using a module or are using the GENERIC kernel, you can install the module by performing the following command:

# kldload linux

If you are building Linux compatibility directly into a custom kernel, you must add the following to your kernel configuration file:

options             COMPAT_LINUX
options             LINPROCFS

Then build, install and reboot your kernel as usual.

NOTE: You must have Linux compatibility loaded and running at the kernel level before you install a Linux base distribution. Attempting to install the Linux base will fail if you do not have Linux kernel functionality running beforehand.

Install Linux base

You will need to install a Linux base system. The ports collection offers several, including several versions of Fedora as well as a Gentoo Stage 3 install. I recommend using Gentoo's since it is much more current than the most recent Fedora base as of this writing (19:13, 17 March 2011 (PDT)).

To install Gentoo's Linux base, type the following commands as root:

# cd /usr/ports/emulators/linux_base-gentoo-stage3
# setenv GENTOO_OPTIMIZED i686
# make && make install && make clean

If you omit the second step, the default optimization is i486. Change to suit which shell you are using. This example assumes the default C Shell which is based on tcsh.

Mount Linux's /proc

Mount Linux's /proc filesystem. The server needs this in order to set itself up based on the system's configuration.

To do this by hand, type the following:

# mkdir /compat/linux/proc (needed if this directory does not already exist)
# mount -t linprocfs none /compat/linux/proc

Set Linux kernel subsystem components to autostart on boot

To make the key parts of the Linux compatibility system come up by default when the machine starts up, perform the following:

1. Add the following line to /etc/fstab:

none           /compat/linux/proc          linprocfs      rw  0      0

2. Add the following line to /etc/rc.conf:

linux_enable="YES"

Installing a Linux base from ports handles the details of setting up how the dynamic linker handles libraries, requiring no additional user intervention.

(Recommended) Add account for Steam

If you wish to run Steam and the games it updates under a different account, type the following as root:

# adduser

Then follow the prompts.

This concludes the FreeBSD side.

Obtain and set up Steam

Log in as an unprivileged user, e.g. the steam user you just created or your own personal account.

You must first get the Steam client package for Linux and extract it. The procedure using a basic FreeBSD install with Linux compatibility is slightly different from Linux since it uses a different tool for picking up files from the Web by command line.

To pick up the Steam client package, type the following:

$ fetch http://www.steampowered.com/download/hldsupdatetool.bin
$ chmod +x hldsupdatetool.bin
$ ./hldsupdatetool.bin

You will be presented with a license agreement. Read and accept the license by typing the whole word "yes" at the prompt. The program will extract the Steam client and a README file.

The next step is to run the Steam client itself to bring it up to date:

$ ./steam

It will pick up a recent version of the file and extract it. Run the program any number of times if it asks to.

If all has worked well, it will present you with a usage page on the final run.

You are now ready to install the Linux dedicated server. Please go back to the installation section of the Linux dedicated server page and skip the first steps we already handled here for further instructions (adding the user, obtaining, unpacking and updating the Steam client).

Other notes

  • FreeBSD has support for Linux's /sys and pseudo-dev filesystems as well as Linux shared memory. It is not required to have these configured.
  • You can use Metamod: Source + SourceMod and any plugins for both without problems.

Copyright and license

Copyright (C) 2011 Ian R. Justman, some rights reserved.

This document is available via a Creative Commons Attribution 3.0 Unported License. You may disseminate and/or modify this document as long as you credit me. Any distribution under any other terms can and must be negotiated.