newtelligence poweredRSS 2.0
# Wednesday, September 26, 2007

Get a new server, get volunteered to run a dedicated game server. This is the position I find my self in. Being a Microsoft guy, I do occasionally like to dabble in Linux just to see what all the hype is about, and Linux makes for a pretty good dedicated game server, and so begins my foray into installing and configuring Linux.

Install Linux

I began by downloading a distro, and Ubuntu is a distro I've played around with before. I opted for the server version, which only installs a core set of files. The installation was extremly easy, as I opted for all the defaults, and did not install the DNS or LAMP packages either. I could see myself installing apache at a later date to host a small website that has info, and stats (if supported) for the games I will be hosting. My other option would be to FTP the stats up to my hosted environment. After the install, I was using around 515MB of my 8GB main drive, and approximately 70 MB of my 1GB of allocated memory. I am a little concerned that the default installation settings only gave me a 400MB swap file. In the past when installing Linux, it has always been suggested that you create a swap file that is the size of 2 * Ram, or in my case 2 GB. I will leave it as it is for now. I found some instructions on how to make a swap file on the main partition and have noted them below for future use.

Add Swap File

  • sudo su
  • dd if=/dev/zero of=/swapfile bs=1024k count=256
  • mkswap /swapfile
  • swapon /swapfile (not persisted, see next step)
  • Edit fstab included the following line (remember to use sudo)
    • /swapfile none swap sw 0 0

Setup 2nd Hard drive

The next step was to setup the 2nd virtual hard drive I had configured as the 2nd scsi device. I followed these instructions. First, you can view your current disk usage, by typing "df -h", which will display in MB. Next, you can use the fdisk command to view and create partitions. First I did "sudo fdisk /dev/sda" to view the current partition setup of my main boot disk (p to view partitions, q to quit fdisk). Next, I ran fdisk on the drive I wanted to setup, "sudo fdisk /dev/sdb", and created (n) a primary partition (p) as the first (partition). Finally commit the changes using the w command. Now that we've created the partition, it needs to be mounted. This can be done by typing "sudo mkfs -t ext3 /dev/sdb1". I chose the ext3 file system for my new partition.

After battling with vi for 15 minutes, I decided to try out nano as my text editor for this next step, and it worked like a charm. It looks like it might be an updated version of pico, but I don't know. Anyway, the last thing that needs to be done is to mount the drive so that you can access it.

  1. Create the directory you wish to mount the partition to. I create a directory called data in root using "sudo mkdir data".
  2. Edit fstab using nano. "sudo nano /etc/fstab"
  3. Add the following line (the spacing between each word of text is a tab)
    1. /dev/sdb1     /data     ext3     defaults     1 2
  4. Save by pressing ctrl+O, followed by ctrl+X to exit
  5. Type "sudo mount /dev/sdb1"
  6. Now you can see your new hard drive (partition) when you do "df -h". You can also cd /data to go to the root of the new partition.
  7. I wanted to test persistence, so I rebooted linux using "sudo /sbint/shutdown -r now"

I noticed after my reboot (besides my new partition being mounted), that I was only using 32MB of ram, and 0 swap. I left the server run overnight, and now I'm up to 65MB of ram used, still alot better then the 150-200 a clean Win2k3 uses at startup.

Directory Setup, Download and Install

Now that I have my HD all setup, and a new /data folder, I can proceed with getting the game server files. I am creating a games sub folder, as I like my stuff very neat and organized. All game servers will obviously go in this folder. Since I don't want to run the game servers as root, I will need to either use my user account or create a new user account. I decided for the later, and created a new user called gamer, which also created a gamer group. I decided to use the existing games group, adding gamer and my account to games, then removing the gamer group. Then I gave the games group permissions over the games folder. I'd like to have game files updated automatically, so I will give the games account rwx permissions over the games folder. If I was really paranoid, I could create a new user account for each game, and only give it read permissions on the directory for that specific game. Then set execute and write permissions only on the necessary files and directories, but I don't think I need to go to that level.

  • sudo adduser games
  • edit the /etc/group file to add my account and the gamer account to the games group
    • Find the new group you just added at the end of the file, and add the users you want to belong to the group, separated by commas.
  • Change ownership to the games group
    • sudo chgrp games games
    • sudo chown games games
  • sudo usermod -g 60 gamer (Change gamer's primary group to games)
  • groupdel gamer (delete the gamer group)

Following these instructions, I setup the steam client and started the download for TF2. The instructions are for a CS server, but they work up to the point were you specify the game you want to download.

  • Create the hdls_l directory
  • Use wget to download the file (I could be downloading a trojan here for all I know, but I'm guessing the forum thread wouldn't be stickied on Steams Site).
  • Extract the steam program using tar -zxvf steam.tar.gz, and remove the .gz file.
  • Make steam executable and run

Now I ran into some problems here, when I decided I wanted to move my steam program, and subsequent downloads into a steam folder. After coping steam to the steam folder, I deleted some files I shouldn't have and got an error message saying I had an incompatible version. Use this command to reset steam and force it to download the latest version: rm ~/.steam/ClientRegistry.blob

I finally got the game downloading but spent so much time messing around that I forgot what I did. So ends this section :(

TF2 server configuration

I found a server.cfg on a forum post that looks pretty promising, although, it does error out in some places. I also installed screen, so that I can start up the server and leave it running in the background after I log out from SSH. While I've used screen before, I forgot about it until I came across this tutorial for running a dedicated source server. I finally got around to giving the Linux server a dedicated IP address, setup port forwarding, and gave the game server a password to join. I'm able to connect to it locally, but have not tried from outside my own network.

Server Lock down

Basically, I want to add some precautions incase the Linux server is by some chance, hacked or taken over. Primarily, I want to isolate the Linux server from the rest of the network. I know that there are a couple of options out there, I just need to research them. More to follow.

Other Linux Commands I always forget

  • passwd - Change the current users password
  • adduser [username] - Adds a new user, with the username specified by [username], to a group called [username]
  • chgrp group directory/file- change group ownership
  • chown user directory/file
Wednesday, September 26, 2007 5:30:32 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Linux
Archive
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Copyright 2010
Adam Salvo
Sign In
Statistics
Total Posts: 234
This Year: 13
This Month: 1
This Week: 0
Comments: 34
Themes
Pick a theme:
All Content 2010, Adam Salvo
DasBlog theme 'Business' created by Christoph De Baene (delarou)