Milestone #5: Fog - wAlber47/Tech-Journal GitHub Wiki

Configuring Machine for Fog

There are some basic things that need to be done prior to installing Fog on the machine. This includes:

  • Creating an "fog" administrator account
  • Setting the hostname to "fog"
  • Static IP of 10.0.17.5
  • Adding DNS Records for IP Address
  • Configuring the Second Disk

Creating Fog Account

Fairly simple and should be able to do without a guide of sorts, however here are the steps:

  1. sudo adduser fog
  2. sudo passwd fog, then enter in new credentials.
  3. sudo usermod -aG wheel fog

Setting Hostname

Use nmtui to set the hostname to "fog".

Static IP Addressing

Use nmtui to configure as follows:

  • IPv4 Configuration: Manual
  • Addresses: 10.0.17.5/24
  • Gateway: 10.0.17.2
  • DNS Servers: 10.0.17.4
  • Search Domains: alber.local

Adding DNS Records

Fairly simple and should be able to do without a guide of sorts, however here are the steps:

  1. Open DNS Manager on server19.
  2. Navigate to the Forward Lookup Zones for alber.local.
  3. Right click and select New Host (A or AAAA), then add in the information.
  4. Make sure creating the associated PTR record is also selected. After that you can finish and close the DNS Manager.

Second Disk Configuration

Make sure that the machine has two disks, can check this using fdisk -l. We will use /dev/sdb to store our virtual machines that will be deployed from Fog.

  1. Become root using sudo -i.
  2. Run fdisk /dev/sdb to begin configuring out disk.
  3. We will use fdisk to create a second partition within the disk. We will enter n for new partition, then p, then simply follow the defaults that are set.
  4. Now we write the partition, do this by typing w. By running fdisk -l again we can see there is an empty partition. This is done with mkfs.ext4 /dev/sdb1, may take a moment.
  5. Lastly, we need to mount this to a directory as that is how Linux handles this. We muse modify a file called /etc/fstab to reflect this:

image

  1. Use mount -a to check that everything is done properly. We should have a lost+found file within our /images directory.

Installing Fog

We will use the source version of Fog directly from GitHub. Can be found here.

  1. Install git using sudo yum install git.
  2. Then clone the Fog repository using git clone https://github.com/FOGProject/fogproject.git.
  3. We should turn off SELinux as Fog does not get along with this service.
    1. Edit /etc/selinux/config, change SELINUX=enforcing to SELINUX=permissive.

image

  1. In addition to this, instead of turning off the firewall, we will create rules to allow the services we need.
  2. To start out, we can run the fogproject/bin/installfog.sh and make the configuration look as follows. The installation may take some time. Once you hit this screen, open a new root session on fog and follow the configuration.

image

Before navigating to the link seen in this image, we need to allow services through the firewall. image

Setting Firewall Rules

We need to add ftp, https, mountd, mysql, nfs, proxy-dhcp, rpc-bind, and tftp through the firewall.

This can be done by running this command while swaping out the service name: sudo firewall-cmd --zone=public --add-service=<service-name> --permanent

Once all the services are entered, run sudo firewall-cmd --reload. image

Permission Configuration

We also need to change the permissions using chmod -R 775 /images & chown root:fogproject -R /images so that they can be accessed by Fog.

image

Now that all of this is complete, we can proceed with the installation. Head to the web portal at 10.0.17.5 and follow those steps. Once you get to the login screen, head back to the terminal and proceed. This should have you set a username and password. Once the installation finishes, head back to the web portal and log in. Make sure all the graphs are green before proceeding.

Setting DHCP Options

On our domain controller, we need to configure DHCP options so that we can PXE boot onto machines. This can be done by going to Scope Options -> Configure Options..., and then setting them as follows:

image

Fog Capture and Deploy

Extracting Base Image

For this piece, we will be extracting the snapshots that we created when initially setting up our virtual machines, specifically for xubuntu-wan.

  1. To start, open CMD and invoke powershell with pwsh.
  2. Create a connection to our vCenter instance with $vserver = "vcenter.alber.local" and Connect-VIServer($vserver).
  3. Initialize our $vm variable with $vm = Get-VM -Name xubuntu-wan.
  4. Next, we will carve out the snapshot with `$snapshot = Get-Snapshot -VM $vm -Name "Base".
  5. To use this, we are going to create another linked clone. But before we do that, we need to create some base variables to be used in the process:
    1. $vhost = Get-VMHost -Name "super4.cyber.local"
    2. $ds = Get-Datastore -Name "datastore2-super4"
    3. linkedname = "{0}.linked" -f $vm.name
  6. To create the linked clone, run $linkedvm = New-VM -LinkedClone -Name $linkedname -VM $vm -ReferenceSnapshot $snapshot -VMHost $vhost -Datastore $ds.
  7. Now that we've gotten the base in a linked clone, we want to separate this link to create a standalone VM. Use $newvm = New-VM -name "uxubuntu-20.04-base" -VM $linkedvm -VMHost $vhost -Datastore $ds, this should run and then create the new VM.
  8. Then give the VM a snapshot with $newvm | New-Snapshot -Name "Base", as it will come with none.
  9. Finally, we remove the linked VM as that was just a temporary step to create the base virtual machine. Use $linkedvm | Remove-VM.

Setting Capture Target

The steps for creating the capture target we want, are almost exactly similar to here. When we created a linked clone for the Fog virtual machine, the only switch is the $base_vm should point to the xubuntu-20.04-base. Also, the name should be xubuntu-capture-target.

Capturing Image

Before we start capturing the image and sending it to Fog, we want to prepare Fog for this process. To start, log into Fog at https://fog/fog. Navigate to "Images", then "Create New Image". Configure the settings as follows, everything else can be left to default:

image

We can add it, then view all the images to see it was created.

Then, set the Virtual Machine to force boot during the next power on. We can now boot up the machine that we created and begin sending the image to Fog.

Once it boots to the Bios, navigate to Boot and change the Network to boot first. It should load into Fog now. We are going to do a Quick Registration. It's going to begin, and we are going to shut down the virtual machine.

If we navigate back to Fog, then hosts, then List All Hosts, we should now see a New Host that has been created for our xubuntu-20.04-base machine. Select the capture task, and under the Operating System drop-down, click on the correct option.

Once that is complete, we can go to Tasks -> List All Hosts -> Capture, this should add an active task to the menu.

Now head back to vCenter, make sure the boot options are set, and then power on the Virtual Machine again. Once you boot from the Network, you should enter the image capture session, this will look very similar to this:

image

This will run for a while, then we should be able to see our virtual machine within Fog. Once this is done, we can remove the xubuntu-capture-target virtual machine.

Deploying Image

Now that the image is uploaded to our Fog server, we can pull it down when we want to create new Virtual Machines.

In order to test this, we are going to create a new VM titled xubuntu-deploy. Place this on Datastore2, set ESXi to 6.5, OS to Ubuntu Linux (64-bit), 2GB RAM, hard drive 31GB, place on 480-WAN, and make sure to thin provision the hard drive.

Just like we did with the capture, we want to force Bios setup and boot to the Network. You may get booted out quickly so when you get to the Fog menu, navigate to Deploy Image, then log in with fog credentials.

Our capture image should pop up, and that should be selected. Deploying this image may take some time and will look something like this after a minute or so:

image

Once the process finishes, we can select Boot from Hard Disk, and xubuntu should boot up.

Another OS Creation

This piece of the Wiki will hold the screenshots and deliverables for going through the base vm creation, fog capture and deploy process.

The Operating System that I will be using is Windows 10.

✅ Created Windows 10 Base VM

✅ Sys-Prepped the Machine

✅ Captured by Fog

image

image

✅ Deployed Workstation VM (wks1) to Domain using Windows 10 Fog Capture

image

✅ Booted wks1 to Windows 10 Successfully

image