How-To create a “Folding farm” – Matthew Cannizzaro
Our more ambitious Folders here at Overclockers.com often build Folding ‘farms’; that is, a collection of computers, all dedicated 100% to Folding and designed to be controlled via network, therefore eliminating the need for a monitor. However, in operations such as these, it can get quite expensive to buy a Windows license for each machine.
Fortunately, this is completely unnecessary.
An operating system known as Linux, which is open source software, hence, completely free, can allow for the creation of Folding farms without the cost of the OS. You don’t need to waste those precious CPU cycles generating the Windows graphical interface that will never be used. Plus, Linux is much more stable than Windows. Less reboots = more Folding.
In this article, I’m going to discuss the monitoring of Linux farms using a program called Electron Microscope 3. It can be downloaded
EM3 will be run on a computer running Windows, which will collect information from Linux systems running the Folding client. The entire farm will be monitored from this computer. This is made possible by a Linux program called Samba. Once Samba is set up, the Folding farm should be able to virtually ‘run itself’, with little or no user intervention.
For those who don’t know, Samba is a program designed to allow Linux to serve Windows file and printer shares.
Electron Microscope 3 interacts with machines running [email protected] by reading the files in the [email protected] working directory. This is where Samba comes in – we will use Samba to share these directories over a LAN.
I’m not going to cover installation of Samba, mainly because most Linux systems install it by default. I’m going to assume a very basic knowledge of Linux console commands, that typical of your average newbie (we will not be using the X Window graphical user interface at all). If you would like to learn more about Linux and how to use it, I highly suggest you check out linuxnewbie.org.
Samba, like many Unix programs, its configured via a text file, in this case, smb.conf. To change the way the Samba server behaves, you change this file.
The first thing you need to do, assuming you have Samba correctly installed, is to locate your smb.conf file. Generally, this is located in
If you can’t find it there, this is how you can locate it:
- as root, run:
- slocate -u
This will build a database of the files on your system, and will take a while. After it is done, run:
and it will tell you where to find it.
Before we actually get started configuring Samba, we must do some preparation for the system. First, let’s create a user that Samba can run under. First, make the user with the useradd command, like so (as root, of course):
/usr/sbin/useradd -m username
The m argument tells the system to build a home directory for our new user, at /home/username. This is generally a good idea, but it is up to you.
We will set a Samba password for our new user, but that requires the samba server to be running, so we’ll wait on that for a little while. Note, that this is different from a regular user password.
The user name should be the same as the user name of the Windows computer with which you want to share. It is a good idea to make sure you know the user name and password of the Windows system that will be accessing the Folding boxes. This information will be required several times throughout the process.
Finally, it’s a good idea to change your hostname from something other than the default, ‘localhost’, before we go any further. Localhost refers to the loopback interface – this is how a computer talks to itself. Therefore, if a computer tries to connect to another machine named localhost, the request will be sent to itself, and not to the intended destination.
There are several ways to change your hostname; I will cover the way that’s most likely to work. Please consult your distribution’s documentation for more information. If you’re on a Local Area Network (LAN – which most Folding setups are) you can use any name you want. However, it is a good idea not to have any two computers with the same hostname.
We will edit three files:
- /etc/hostname, and
This must be done as root. For the purpose of this how to, we will use pico as the text editor. Type:
and change the HOSTNAME= line to reflect your new hostname. For example, if you wanted your machine to be ‘foldingbox,’ you would do this:
When you are done, hit ctrl x, y and enter a few times to confirm and save the file. Now we will edit /etc/hostname:
Sometimes this file does not exist; if so, you probably don’t need it, but it can’t hurt to have it. Replace (or add if the file is new) the hostname in the following format:
Save and exit. Some distributions use /etc/HOSTNAME instead (Linux filenames are case sensitive, so this does matter). Just follow the same steps and create(or alter) /etc/HOSTNAME just as you did /etc/hostname. Now, for the final file, /etc/hosts:
ADD a line to the file, below any other entries:
Then reboot the machine and check that your hostname is what you selected. You should be able to see it after your user name at the bash prompt. If there is any doubt, run ‘hostname’ and it should return your hostname, as you just set it.
By far, the easiest way to deal with host names is to set them correctly during installation, although there is no need to reinstall just to change your hostname.
Now we’re ready to jump into smb.conf. The basic format of smb.conf consisted of keys, organized under groups. It looks like this:
- key = value
Pretty straightforward. A very basic smb.conf looks like this:
- workgroup = yourworkgroup
- guest ok = no
- read only = no
This brings up something very important: workgroup. If your workgroup is not exactly the same for all computers you want to have access to, your Samba servers will not show up in a Windows computer’s ‘Network Neighborhood’, and you will have to search for them.
Change into your Samba directory (cd /etc/samba or whatever your directory is) and use pico to create that smb.conf file for now (pico smb.conf). If you have a sample smb.conf file, rename it so you can use it later (do it like so: mv smb.conf smb.sample.conf).
Now, lets test our Samba configuration.
Let’s test our smb.conf syntax first. Type testparm and look at what it returns. If there are any errors, it will tell you and you must fix them before continuing.
Second, start the two Samba daemons (programs that run in the background waiting for connections). As root, run:
It is possible your daemons are somewhere else; if so, just do a slocate on nmbd and smbd and you’ll find them. Make sure that the two processes are running by typing the following:
ps ax | more
Press enter to scroll down the list and look for nmbd and smbd. If they are there, you’re on track.
This is a good time to set up your user’s Samba password. This is done with the smbpasswd command, as root. The basic syntax is:
smbpasswd -a username password
If you want a blank password, use the n (as in null) argument like this:
smbpasswd -an username
Note that if you use null passwords, your smb.conf should have the following under the [global] section:
null passwords = yes
Many people have blank Windows passwords so they don’t have to type them when they log on. This tends to cause trouble with Samba, as a Windows ‘blank’ password is NOT equal to a Samba null password. If you must use a blank password, set the Samba password like this:
smbpasswd -a username
Samba will ask you for the password twice, just press enter each time.
Now, let’s make sure that your NetBIOS name is working correctly. Type the following command:
of course, replace HOSTNAME with your hostname (should be in caps though). You should see something like this:
- querying HOSTNAME on 192.168.123.255
- 192.168.123.176 HOSTNAME<00>
The IPs are for my network, yours may differ. As long as there aren’t any errors, let’s continue.
To confirm that you can log in, use the following command:
Samba should ask you for your password and ‘log you in’ to your home directory. Note that if you are using null passwords and get an error when you try to log in, it’s because you forgot the line: ‘null passwords = yes’ in the [global] section of your smb.conf.
Now that we have the basics down, use the sample smb.conf file and read the comments in it; there is a lot of information in there. Try editing the file yourself and experiment with the various features. If you put a # in front of a line, Samba ignores it. After making your changes, save the file and run testparm. If it checks out, you can force the Samba daemons to re-read the config file like this:
- killall -HUP smbd
- killall -HUP nmbd
To add a custom share, you must declare it:
- path = path/to/share
Technically, this is all you need to create a share, but it may be more functional if you set some more options, such as:
- public = yes
- # Allows any user to use the share
- writable = yes
- # Allows the share to be written to.
Here is a smb.conf that should be sufficient to share the working directory of a Linux [email protected] setup:
- workgroup = YOUR_WORKGROUP_HERE
- server string = FAH Server
- security = user
- encrypt passwords = yes
- log file = /var/log/samba.%m
- max log size = 50
- guest ok = yes
- read only = no
- path = /home/folding
- public = yes
- writable = yes
If you use this file, be sure to change the workgroup to reflect your network. Also, alter the share definitions to the directories you want to share. Note that this configuration is not terribly secure, as anyone on the network has full access to the shares.
At this point, if you smb.conf is set properly, you should be able to see your Linux server on the Windows machine.
I recommend creating a user solely for Folding (this can also be your samba user). Run the following command to do so:
/usr/sbin/useradd -m folding
Now, you have a new user name ‘folding’ and a home directory for that user, located at /home/folding. We can use this directory as the [email protected] working directory. In order to ‘become’ this user without setting a password and logging in, you can log in as root and run:
And you will become the folding user.
Before we can begin monitoring the Folding client with EM3, we have to change file permissions. EM3 needs write access to set up the first time, but afterward read-only access only is necessary, provided you don’t want to change settings remotely.
First, download the Linux [email protected] client to your folding directory. The permissions need to be changed so that the system knows it is a program that can executed. So, as root , run:
chmod +x /home/folding/FAHxxx.exe
Depending on which client you have and where your working directory is, you will have to alter that command. Now, run the folding client (as your folding user)
Once you answer the questions and it begins running, it will create several files in its working directory. We must change permissions on all these files; this is done with the following command, as root:
chmod 777 -R /home/folding/*
You may want Samba to start automatically on boot. In that case, you should add the following to a rc file, which you can find in /etc/rc.d/ (I tend to use rc.local):
If you want to start from a command prompt, use the same commands above, except append a -D to the end of each. The -D option tells the server to run as a daemon, so it won’t die if the session is closed. Samba must be started as root.
Finally, when troubleshooting problems, the most important thing to check is your physical network. Make sure the machines can ping each other, etc. Only then look at software issues, which tend to be more complex and take a longer time to deal with.
I think I’ve covered the basics here. If anyone has any suggestions, comments, or anything, feel free email me. Here are some links to more samba info:
And my personal favorite for problems you can’t seem to find a solution to:
NOTE: A reader has contacted me to inform me that a security hole has recently been discovered, in Samba versions 2.2.2 through 2.2.6, that could theoretically allow a remote user to gain root access. I doubt this would be a problem for most users, as most will run behind a NAT router, making such attacks impossible from someone outside the LAN.
Readers can download the newer version at samba.org, without the security hole.
Matthew Cannizzaro aka Titan386 on forums