Automating the Build of the VM for the Lab Prep

This is part of a larger series on earning an RHCE.  For the first article, click here, and for the one immediately previous to this one, click here.

This week I decided to focus on automating the build of the lab systems.  This first walkthrough is just for the creation of the three virtual machines that will be needed for the lab work.  For ease of reference, I uploaded a YouTube video, which you view here:

Starting out VirtualBox will need to be installed on your system.  The link to that website is here.  I assume that those who will be taking the RHCE exam can handle downloading and follow the directions to install VirtualBox on the machine being used to prep for the exam.  But please feel free to email me with questions david@opensource.io

Once that is installed, I have worked out the CLI commands to create the virtual machines.

The first thing we need to do is to create a nat network so that the machines are all on their own subnet and can access the internet.  I have picked 192.168.154.0/24 as the CIDR address, but if that conflicts with your network scheme, feel free to adjust the network and remember that change when doing the rest of the labs.  My directions moving forward will assume this network is the network you are using for the labs.

VBoxManage natnetwork add --netname labNAT --network "192.168.154.0/24" --enable --dhcp on

Next, we create one of the virtual machines.  I am using a group of /lab so that it will be easy to start and stop the virtual machines.  The first machine will be control.  This machine will be used later to setup a single sign on and kerberos for the lab.  This setup is not needed knowledge for the test but knowledge on using a machine that is setup using kerberos is expected knowledge for a RHCE.

This command creates the basic virtual machine.

VBoxManage createvm --ostype RedHat_64 --groups /lab --register --name control

This command adds the storage controller that the DVD-ROM will be attached.  The next command adds the DVD-ROM to the storage controller.

VBoxManage storagectl control --name IDE --add ide --controller PIIX4 VBoxManage storageattach control --storagectl IDE --type hdd --port 0 --device 0 --medium emptydrive

This command adds the storage controller that the hard drive will be attached.  The next commands create a 30G hard drive and the next command adds it to the controller.

VBoxManage storagectl control --name SCSI --add scsi --controller LSILogic VBoxManage createmedium disk --filename control1hd.vdi --size 30000 VBoxManage storageattach control --storagectl SCSI --type hdd --port 0 --device 0 --medium control1hd.vdi

This command modifies the memory to 2G and adds a nic that resides on the nat network we created earlier, labNAT.

VBoxManage modifyvm control --memory 2048 --nic1 natnetwork --nictype1 82545EM --nat-network1 labNAT

This next command does an unattended installation on the machine using an OS image that you will need to download either from Red Hat or from CentOS.  Remember to download the 7.0 version since that is what the test is currently on.

VBoxManage unattended install control --iso=rhel-server-7.0-x86_64-dvd.iso --hostname=control.example.com --time-zone=us/central --user user --password password

—OR—

VBoxManage unattended install control --iso=CentOS-7-x86_64-Everything-1708.iso --hostname=control.example.com --time-zone=us/central --user user --password password

Next week, we will look at customizing the kickstart file.

About the Author

With over 18 years of advanced professional work experience in various Information Technology and Storage Platforms, David provides the ability to deliver enterprise solutions to Fortune 500 companies.

>