Cloning Windows Workstations with FOG
(This article has been updated for version 0.27 Let me know what you think!)
Every school, even a small classroom lab, needs a means to efficiently reinstall their workstations from the ground up: operating system, applications, settings, etc. That is, essentially restoring the machine to a pristine state before it became contaminated by actually being used by students (gives me shivers). Sadly, in many schools, this process is anything but efficient and sometimes involves a couple of teachers going around and reinstalling the machines one at a time. They may well know there’s a better way, they just might not know how.
- So what is FOG?
- Basic Usage
- Configuring DHCP and MYSQL
- FOG’s Web Interface
- Management Nodes
- FOG Service Configuration
- Task Manager
- System Reports
- Other Information
- Creating an Image Definition
- Adding a Host
- Manually Add a Host
- Create a .CSV File
- Quick Host Registration and Inventory
- Creating a Group
- Uploading and Deploying an Image
- Advanced Imaging Options
- Adding a Storage Node
- Creating and Deploying Snapins
- Creating a Snapin
- Uploading to FOG, and Deploying
- Comments (128)
So what is FOG?
As mentioned before, FOG is a free alternative to products like Symantec’s Ghost, which, while being a very good product, can be too expensive for small imaging operations. Beyond just imaging, FOG also includes a client-side program, which can communicate with the FOG server and manage various things. For instance, you can remotely install new applications, network printers, scan for viruses, and track user access.
The FOG project began in August 2007, and is maintained by Chuck Syperski and Jian Zhang. As of writing this article, they’re currently working on version 0.27, and have made some significant improvements since I began using their product.
FOG is designed for Linux; it’s designed and tested on Fedora, but it also supports Ubuntu. So any machine you can install Linux on, you can probably use as a FOG server.
Before you install FOG, you should probably have an idea of how it works. The bulk of the work goes on behind the scenes (where it belongs), and you control this through a web-based gui. This can be accessed from almost any machine. From the gui, you can setup and manage all of your tasks, hosts, groups, images, etc.
FOG makes use of PXE (Preboot Execution Environment) to boot hosts machines into its own environment, in order to execute imaging tasks. Other tasks, such as deploying snapins, changing machine names, etc, is taken care of by the client-side FOG Service.
So FOG basically works like this: you add a host’s information to the FOG server, create an image type for it to use, select the task you want to execute, reboot the host and boot it to the Onboard NIC, FOG loads its own operating environment over the network, and it executes the task. Simple enough, yeah?
The installation itself is pretty easy, but there are a few things you need to think about beforehand. Do you want to run DHCP from the same machine as FOG? Do you want to keep FOG’S MYSQL database on this machine as well? If you’re using FOG in a pretty self-contained environment, you might not need separate servers for each of these. On the other hand, you may already have DHCP configured on another server (or you may use a router), and likewise for your MYSQL database. So why go through all the trouble again? By default, FOG uses the machine you’re installing it on for DHCP and database information, but we can easily configure it not to.
Before we do anything, we need to set your machine to have a static IP. If you’re running Ubuntu, go to System > Administration > Network. Select your Wired Connection, and click Properties. Set the Configuration to Static IP Address, then assign one.
If your machine is sitting on a larger network (like a campus-wide network) you may need to talk to a system administrator about getting a static IP setup.
Once that’s configured, go to FOG’s Sourceforge page, and grab the latest version. Extract it to the /opt directory:
sudo tar -xvzf fog* -C /opt
Now, cd to /opt, and there should be a folder named fog_0.XX. CD into it, and then into its bin folder. You should see a shell script, named installfog.sh. Run it:
And the installation will begin.
___ ___ ___ /\ \ /\ \ /\ \ /::\ \ /::\ \ /::\ \ /:/\:\ \ /:/\:\ \ /:/\:\ \ /::\-\:\ \ /:/ \:\ \ /:/ \:\ \ /:/\:\ \:\__\ /:/__/ \:\__\ /:/__/_\:\__\ \/__\:\ \/__/ \:\ \ /:/ / \:\ /\ \/__/ \:\__\ \:\ /:/ / \:\ \:\__\ \/__/ \:\/:/ / \:\/:/ / \::/ / \::/ / \/__/ \/__/ ########################################### # Free Computer Imaging Solution # # # # Created by: # # Chuck Syperski # # Jian Zhang # # # # GNU GPL Version 3 # ########################################### Version: 0.26 Installer/Updater
The installation begins by asking you some questions, so it can properly install the server. The default choices are shown in brackets (like above, it has , because I’m running Ubuntu). If the default is correct, you don’t need to do anything but hit enter.The questions are:
What version of Linux would you like to run the installtion for? 1) Redhat Based Linux (Fedora, CentOS) 2) Ubuntu Based Linux (Kubuntu, Edubuntu) Choice: 
Choose the OS you’re running. It should choose the right one by default.
What type of installation would you like to do? [N]
You have two choices, Normal Server, and Storage Node. Since this is our first FOG server, we need to select normal. Storage Nodes act sort of like extra image repositories, whereas normal servers are fully functioning. We’ll get to more on that later.
What is the IP address to be used by this FOG Server? [192.168.1.10]
This is the static IP we setup earlier.
Would you like to setup a router address for the DHCP server? [Y/n]
If you have a router on your network (even if it’s not running DHCP), select Yes. It will then ask for the IP.
Would you like to setup a DNS address for the DHCP server and client boot image? [Y/n]
Again, if you’re running DNS, select yes, and it’ll ask for the IP.
Would you like to change the default network interface from eth0? If you are not sure, select No. [y/N]
If you have more than one network interface on your machine, you may have to change which one FOG uses. In most situations, though, you won’t need to.
Would you like to use the FOG server for dhcp service?[Y/n]
If you already have another server or router running DHCP, and you want to keep it that way, select No.
Once it has all your information, it gives you a brief overview, and asks if you’d like to continue:
##################################################################### FOG now has everything it needs to setup your server, but please understand that this script will overwrite any setting you may have setup for services like DHCP, apache, pxe, tftp, and NFS. It is not recommended that you install this on a production system as this script modifies many of your system settings. This script should be run by the root user on Fedora, or with sudo on Ubuntu. Here are the settings FOG will use: Distro: Ubuntu Installation Type: Normal Server Server IP Address: 192.168.1.10 DHCP router Address: 192.168.1.1 DHCP DNS Address: 126.96.36.199 Interface: eth0 Using FOG DHCP: 1 Are you sure you wish to continue (Y/N)
During the installation, you may be asked to setup a MYSQL password. If you plan on using a different machine for MYSQL, you can leave this blank.
Configuring DHCP and MYSQL
If you’re using the FOG server for both DHCP and the MYSQL database, you’re in luck, all you need to do is add the MYSQL password to two files (if you set one during installation). If you’re running DHCP on another server or router, you need to tell it to use your new FOG server for PXE Booting.
If you’re using Ubuntu, open up the configuration file: sudo vi /etc/dhcp*/dhcpd.conf (probably similar if you’re using a different version of Linux) and add the following line:
next-server [Your FOG Server's IP address];
then, within the subnet declaration, add:
save and quit, then restart the DHCP service:
sudo /etc/init.d/dhcp3-server restart
If you’ve got a router, you may not have a next-server option. It depends on the router. If that’s the case, you’ll need to turn off DHCP on the router, and enable it on the FOG server (the easiest way to do this would be to just run installfog.sh again)
Changing the MYSQL information is also pretty easy. There are two files you need to update (open them as root): /opt/fog/service/etc/config.php and /var/www/fog/commons/config.php.
In each file, you’re looking for three values: MYSQL_HOST, MYSQL_USERNAME, and MYSQL_PASSWORD. If you’re using the FOG server for your MYSQL database, just insert the correct password. If you’re using a different machine, change the host, username, and password accordingly.
FOG’s Web Interface
So FOG’s been installed, everything’s been configured. Now it’s time to open the web interface. Open your browser, and type http://[FOG IP Address]/fog/management
The first time you run it, FOG will ask to install/update the SQL database schema. If that’s successful, you will then see a login screen. By default, the username is ‘fog’, and the password is ‘password’ (you’ll probably want to change that). Once you login, you’ll be greeted by the main menu.
As you can see, the main page displays some information about your server’s usage and activity. Along the top is the menu bar:
The icons are, from left to right: Home, User Management, Hosts, Groups, Images, Storage Management, Snapins, Printers, Fog Client Service, Task Management, System Reports, Other Information, and Logoff. Hosts, groups, images, and such are managed through their respective page, or, as FOG refers to them, node. Any tasks you wish to perform on a machine or group of machines is done through the Task Manager.
The different management nodes(user, host, group, image, node, snapin, and printer) all work roughly the same. For instance, when you click on the Host Management icon, you’re given a list of all host entries:
The menu on the lefthand side lets you navigate through the various sections of each Management node. List All brings you back to the initial page you see. This page shows you some basic information about the hosts, groups, etc. You can click the different headers at the top of the list to sort it as you choose. Clicking Edit shows you some more in-depth information, and allows you to change it.
Clicking Add New takes you to a page, from which you can fill out all the necessary information. Once you click Add, you will see a popup, declaring either that it was successful, or that there was a problem with the information you filled in. Some values, like mac addresses, must be in a specific format. Clicking the question marks next to some areas (as in the image below) can provide helpful information.
The only exception is adding groups, which is done through Host management. This is because you need to select the hosts which belong to the group.
Some of the nodes also have a Search function. This is pretty self-explainatory; if you’ve got a lot of hosts, for instance, and you’re looking for a specific one, you can search for it.
FOG Service Configuration
This node allows you to configure what actions the FOG Client Service will take. the FOG Client Service is something you can choose to install on host machines. It’s not required, but it can be very helpful in automation. This node lists twelve services that the FOG Client Service can run: Auto Log Out, Client Updater, Directory Cleaner, Display Manager, Green FOG, Hostname Changer, Host Registration, Printer Manager, Snapin Client, Task Reboot, User Cleanup, and User Tracker.
Most of these are self-explanatory, and the only option for most is whether or not to enable the service. Other, like the Display Manager, allow you to set more specific options (like default screen resolution).
From this node, you can start a number of different tasks. Simply find the host or group you want to perform the task on, and select the task. You can also view tasks that are currently active by clicking one of the Active Tasks buttons on the lefthand side.
There are three common tasks: Upload, Deploy, and Deploy Multicast. Upload is used to pull an image from a host to your server, and Deploy is used to push it back to another host. Multicasting can only be performed on a group of machines.
The Advanced section allows you to perform other useful tasks. For instance, you can run Debug mode, which allows you to execute common Unix commands from the host, or deploy just the Snapins. FOG also offers a few disk utilities, such as disk wiping, antivirus, file recovery, Memtest86, password reset
Through this node, you can view logs for different tasks, to see a history of past operations. These logs include imaging, snapin deployment, user logon, virus history, and inventory. On some (such as the imaging log) you can choose a range of dates to display. FOG also generates Excel spreadsheets and PDF files that you can download for your own use.
This node gives you access to some system information, and lets you edit some settings. It also provides you with links to FOG’s homepage and Sourceforge page. It’s through this node that you can access the FOG settings; this is the information stored in /var/www/fog/commons/config.php. It provides you with a more user-friendly way to edit this information. Ideally, you shouldn’t have to deal with this section too often, only when problems begin arising.
Creating an Image Definition
Before you can begin adding hosts, you should create an image definition. Open the Image Management node, and select New Image. Name the image, select the Storage Node to save it on (you should only have one at the moment, Default), and name the Image File. The description is not necessary, it’s for your use.
Next we need to choose the proper Image Type. There are four choices:
Single Partition (NTFS Only, Resizeable),
Multiple Partition Image – Single Disk (Not Resizeable),
Multiple Partition Image – All Disks (Not Resizeable), and
Raw Image (Sector by Sector, DD, Slow).
Single Partition is probably okay if your host machines don’t have more than one partition on the harddrive. It should be noted that this image type is “destructive”; it modifies the partition on your drive. So if it fails or is killed prematurely, it’s possible that your machine won’t boot. Also, these images are resizable–if you take an image from a 100 GB hard drive, you can put this image onto a 10 GB drive, provided there isn’t more than 10 GB of data.
Multiple Partition images are for machines with multiple partitions on a drive (ie dual-boot machines, or recovery partitions) or systems with multiple drives that you need to backup. These image types are not resizable, meaning you must restore them onto a drive of equal or greater size. Also, they supports several file systems: NTFS, XFS, JFS, HPFS, FAT16/32, Reiser3, EXT2, and EXT3.
Raw Image is a very slow imaging process; it copies every sector exactly, so you will often end up with an unnecessarily slow, large file. It should work with nearly any file system, but I wouldn’t recommend using it unless you absolutely must.
Once everything is filled out, click Add, and you should get a confirmation that the image definition was added.
Adding a Host
Before you can do anything to your machines, you need to add them to the FOG system. You’ve got three ways you can do this: you can manually enter the information, you can put together a .csv file, and upload that, or you can pxe boot the machines, and have FOG run an inventory on it.
Manually Add a Host
In the Hosts node, click Add New Host. Simply fill out the form, and click Add. There are four fields that are required: Hostname, Mac Address, Host Image, and Host OS.
Notice that the MAC address must be formatted properly (00:11:22:33:44:55) or FOG will reject it.
Create a .CSV File
In the Hosts node, click Upload Hosts. This is where you will attach your .csv file for upload. Grab the template file they include, and open it with a spreadsheet editor. There are six fields, but only MAC address and Hostname are required. Also, you don’t need to leave the top row in, it’s just for the template. If you decide to leave it, FOG will still accept and process the file, but you’ll always get an error.
Save the file, and upload it. FOG will then give you the results, showing number of successful hosts added, and any errors it ran into.
Note that if you don’t include an Image ID, you’ll need to edit each host and select one, before you perform any image-based tasks.
Quick Host Registration and Inventory
If you pxe boot a machine without running a task, FOG gives you a screen with a few options on them, one of them being Quick Host Registration and Inventory. This pulls information about the hardware, MAC address, and such, and registers the machine as a host in the FOG server. The host name is set to the MAC address, without colons (001122334455).
Note that you’ll need to edit the Host entry to select an Image ID before you can do any image-based tasks.
Creating a Group
As mentioned earlier, groups are not created from within the Group node, but rather the Hosts. Along the left side, beside the host names, are checkboxes. The box at the top can be used to check or uncheck all hosts. Simply select the hosts you want, and either type a new name in the text box to create a new group, or select an existing group to add the hosts to it.
Click Process Group Changes, and you should see a confirmation. Now, when you go to the Group Management node, you’ll see your new group. Click Edit to see and change more detailed information. Adding hosts to groups lets you deploy images easier, but it also lets you override host settings. For instance, you can associate a specific image with a group, so that it will be deployed instead of the image associated with the hosts. The same goes for OS association, Active Directory, FOG Client Service settings, and Snapins.
Uploading and Deploying an Image
So you’ve got your image definitions created, and your hosts and groups associated with them. Now you need to upload an image for deployment. Build the machine exactly as you want it, and prepare it to be imaged. Open the Task Management node, find the right host, and select Upload. A confirmation screen will show you the host name, MAC address, and image you’re about to use for this task, along with a few options (we’ll get to those in a bit). If it’s correct, click Upload Image.
Boot the machine from the Onboard NIC. If everything goes well, the FOG splash screen will appear, FOG will gather some information about the disk, then a blue screen with a progress bar and other information about the upload progress will appear.
Depending on a few factors (size of image, drive speed, network speed) the upload can take a while. We average about 300-350 mbit/sec, or about 20-25 minutes for a 9 gigabyte image. Uploading usually takes longer than deploying.
Deploying an image works exactly the same way. Select the host you wish to image, and select deploy. If you want to deploy to a whole group of machines, click List All Groups, and select either Deploy or Deploy (Multicast). Boot the hosts from the NIC, FOG will load, and you’ll see a progress screen like above. Once they’re done, they’ll reboot and be ready to use.
There’s a big difference between regular deployment and multicast deployment. Normal (unicast) deployment sends one copy of the image to one machine, so if you need to image ten machines, that’s ten copies of the same image. Multicast deployment only sends the data once, and your router or switch then copies it to multiple machines. It saves wear on your server and bandwidth on your network.
Advanced Imaging Options
You probably noticed that the Task Confirmation page lists a few options. These were introduced in version 0.27, and allow you to schedule a task to run at a later date.
You have two options: Single Task Execution, and Cron Style Execution. If you just want the task to run once, select Single Task Execution. If you click in the white box just underneath it, a handy little calander pops up for you to select the date and time.
Cron Style Exectution allows you to setup a recurring task. It’s called Cron Style, because it’s based on the Cron scheduler found in many Linux/Unix operating systems. The five sections are minute, hour, day of month, month, day of week. Each section can take a number of different operators:
– comma usage (,) can be used to list a set of numbers
– hyphen (-) can be used to list a range from one number to another
– asterisk (*) can be used as a wildcard, and divided by a number, to get every nth (i.e. */2 is every other, */5 is every 5th)
A simple example would be running a task every day at 10:30 PM:
30 22 * * *
A more complex example could be running a task every Wednesday on the hour from 5 to 9 PM:
0 17-21 * * 3
the FOG User Guide has some more examples of setting up these tasks.
Adding a Storage Node
Adding storage nodes allows you to take some of the burden off of your main server. You can image more machines at the same time, and it provides some redundancy, so if one fails you don’t lose all your images. And just as you can have different groups of hosts, you can have different Storage Groups, which can handle different images.
To create a storage node, download FOG from the Sourceforge page, and follow the installation instructions for setting up a static IP, extracting the files and starting the installfog.sh script.
When you’re asked to select between a Normal Server installation, and a Storage Node, select Storage Node (s). Next it asks for the node’s IP address, and then the FOG server’s IP address. Finally, it needs the fogstorage username and password; this can be found in the FOG Settings, under FOG Storage Nodes. Once you’ve given it the information it needs, it will complete the installation, and give you a username and password for the node. Write this down, because you’ll need it for adding the node to the FOG server.
In the Storage Management node, select Add Storage Nodes. The form has several fields, most of which is information from the storage node you just created.
The username and password are the oens you wrote down from before. And, unless you’ve added a new storage group or changed the location where images are stored, the defaults will work. Do not select Is Master Node unless you’re absolutely sure you want this. Master Nodes copy their images to all other nodes within the group, so if your Master node has no images, it will delete the images on the other nodes.
Creating and Deploying Snapins
Snapins are deployed to machines after they’ve been imaged, through the FOG Client Service. Once the machine boots, the Client Service talks to the server to see if there are any new tasks to perform. If it finds a new snapin, it downloads it and installs it. While a snapin can be any .exe, .msi, or .bat file, it’s most useful if used with a custom snapin.
Creating a Snapin
You can create a custom snapin with a free program called InstallRite, from Epsilon Squared. Download the program and install it. When you open it, select Create a manual “Snapshot” of your PC. What this does is it makes note of all your files and registry values.
Then you make changes to your machine, either by installing new software, or removing unwanted software. Then select Perform an “Analysis” of the changes since the last “Snapshot”. As the name implies, this finds all the changes you made. When it’s finished, it asks “What is the name of the software you installed?”. This is the name of the InstallKit you’ll be building, you can name it whatever you want.
When you’re ready to build the .exe, select Build an InstallKit. This opens up a menu of all the InstallKits you can make. If this is your first one, you should only see the name you gave it in the last step. Select it, then select where you want to save the .exe to.
Uploading to FOG, and Deploying
Before you can upload this snapin to the FOG server, you need to change a few settings. By default, you can only upload an 8 megabyte file. This is a PHP setting, not FOG. On your FOG server, we need to make changes to two files: /etc/php5/cli/php.ini and /etc/php5/apache2/php.ini. In both files, look for upload_max_filesize andpost_max_size. Set them to 1900M. Save, and restart the webserver with sudo service httpd restart. In the FOG web interface, go to the Snapins Node, and select New Snapin. Fill out the information as you’d expect, and click Add.
To associate a host or group with a snapin, open it for editing, and on the lefthand side, select Add Snapin. Select the one you wish to associate with it, and click Add. Now, whenever you deploy an image, the snapins will be deployed along with it. You can deploy a snapin by itself by selecting Deploy Snapins from the Advanced Tasks section under Task Management.
FOG Discussion Forum: FOG has a very good forum on Sourceforge. Most problems you run into can be solved by searching for similar problems, and if you can’t find it, just post a question.
FOG Wiki: The FOG Wiki is a good source of general information; they’ve got a user’s guide, machines known to work (or not work) with FOG, a knowledge base, video tutorials, all sorts of stuff.
Trackback from your site.