DragonflyBSD Dedicated Server Setup
From GMod Wiki
NOTICE: Linux server binaries are currently in beta and are not guaranteed to be updated as often as the Windows binaries. AzuiSleet is doing his best to keep them up to date.
Notes about CPUs / Multiple servers
In DragonFly, threads are locked to CPUs by design, and each processor has its own LWKT scheduler. Threads are never preemptively switched from one processor to another; they are only migrated by the passing of an "inter-processor interrupt" (IPI) message between the CPUs involved. Inter-processor thread scheduling is also accomplished by sending asynchronous IPI messages. One advantage to this clean compartmentalization of the threading subsystem is that the processors' on-board caches in SMP systems do not contain duplicated data, allowing for higher performance by giving each processor in the system the ability to use its own cache to store different things to work on.
The LWKT subsystem is being employed to partition work among multiple kernel threads (for example in the networking code; one thread per protocol per processor), reducing contention by removing the need to share certain resources among various kernel tasks. This thread partitioning implementation of CPU localization algorithms is arguably the key differentiating feature of DragonFly's design. - Reference: http://en.wikipedia.org/wiki/DragonFly_BSD
How does this affect my server?
It means that by default, if you choose to run more than one instance of the gmod server at the same time (eg: your community has both a Spacebuild and an RP server on the same physical server) and you are wanting to assign a dedicated server to a specific CPU to improve performance, that you don't have to do anything else because this OS will not move the processes between CPUs anyway.
|You will need to be root at one point in this guide so be careful! You can do serious damage while logged in as root.|
Install Linux Compatibility
Become root and execute the following command:
Now edit /etc/rc.conf and append the following text to the end of the file:
We're going to use pkgsrc to install linux libraries from SuSE.
If you don't have pkgsrc installed, here's how you install it
cd /usr make pkgsrc-create
Now we install the necessary Linux-compatibility libraries:
cd /usr/pkgsrc/meta-pkgs/suse100 bmake install distclean ln -s /usr/pkg/emul /compat
Finally, mount the Linux proc filesystem.
mount_linprocfs proc /compat/linux/proc
To avoid having to mount it manually like that ^ at every boot, add the following line to the end of /etc/fstab
linprocfs /compat/linux/proc linprocfs rw 0 0
Unfortunately, if you're running dragonfly 2.4.3, we are going to need to recompile the kernel because there is a bug which is stopping linux emulation from working (are you sure you don't want to just use Linux? Of course you are. Keep reading...)
Change to your /usr directory and run make src-create to check out the kernel source code from the dragonfly git repository
cd /usr make src-create
Now edit: /usr/src/sys/platform/pc32/isa/npx.c and comment out the line which looks like this: lwpsignal(curproc, curthread->td_lwp, SIGFPE);
Now recompile the kernel you've just edited
cd /usr/src make buildworld make buildkernel KERNCONF=GENERIC make installkernel KERNCONF=GENERIC
Create a user
|Never run srcds as root.|
You should use an unprivileged user to run srcds.
If you have root access:
adduser Username: gmod Full Name: Garry Mod Uid (Leave empty for default): Login group [gmod]: Login group is gmod. Invite gmod into other groups? : Login class [default]: Shell (sh csh tcsh nologin) [sh]: Home directory [/home/gmod]: Home directory permissions (Leave empty for default): Use password-based authentication? [yes]: Use an empty password? (yes/no) [no]: Use a random password? (yes/no) [no]: Enter password: (whatever you like here) Enter password again: (whatever you like here - same as above) Lock out the account after creation? [no]: OK? (yes/no): yes adduser: INFO: Successfully added (gmod) to the user database. Add another user? (yes/no): no Goodbye!
Login as gmod before continuing.
Change to home directory:
Make a folder for your server
Go to your home folder if not already there:
cd ~ mkdir srcds cd srcds
Do this bit as the "gmod" user for security reasons:
Download the dedicated server update tool, make it executable and run it.
wget http://www.steampowered.com/download/hldsupdatetool.bin chmod +x hldsupdatetool.bin ./hldsupdatetool.bin
You will need to agree to the terms of the license agreement - type 'yes' and press return.
If you receive an error about uncompressing, make a symbolic link to the gunzip tool called "/usr/bin/uncompress". If you already have a tool called uncompress, be sure to move it away from /usr/bin/uncompress first.
ln -s /usr/bin/gunzip /usr/bin/uncompress
Now run Steam - Providing you have an active Internet connection and the Steam servers are up, it will update itself.
Now we want to install Garry's Mod.
Installing GM10 Content
Enter the following:
./steam -command update -game orangebox -dir . ./steam -command update -game garrysmod -dir .
Installing the necessary Linux binary code
Now, download the GMod Linux server binaries from http://www.facepunch.com/showthread.php?t=933697, and save the zip file to your srcds folder and unzip them there:
Next, move each of the extracted files below into the places they need to be for the server to operate:
mv server_i486.so orangebox/garrysmod/bin mv lua_shared_i486.so orangebox/bin mv scenecacheproxy_i486.so orangebox/bin mv gm_sqlite orangebox/garrysmod/lua/includes/modules/gm_sqlite_486.dll
Installing extra game content
Optionally Creating a Startup Script
You can now in theory just run the server with this command: orangebox/srcds_run -console -game garrysmod +maxplayers 16 +map gm_construct -autoupdate
However if you close SSH your server will close too.
We want to attach our GMod server to a virtual screen so we can log off and come back later or share the screen with other users (Other admins for example).
Open up a file called startgmod.sh with your favourite editor, for example:
nano -w startgmod.sh
Enter the following into the file:
#!/bin/bash echo "Starting up Garry's Mod 10 server." sleep 5 screen -A -m -d -S gm10server orangebox/srcds_run -console -game garrysmod +maxplayers 16 +map gm_construct -autoupdate echo "Started. Type screen -x to resume!"
You may wish to edit maxplayers and map.
Once you've got to this stage you're good to go. Make the script executable before running it:
chmod +x startgmod.sh
Everyday Server Operations
This resumes your screen session, sharing it with any other users. If the server is still active with players, it's advisable to shut it down by typing:
Once you've done that, press Ctrl+C+X to kill the screen.
If it's hung, just press Ctrl+C+X.
If you type:
You're sitting at the console of your server.
|To disconnect from screen, type Ctrl+D+A.|