Install CentOS 7 in vSphere

Learn how to install Linux CentOS 7 in a virtual environment.

Prerequisites:

  • Download CentOS ISO (preferably 64 bit)
    • 1 vCPU
    • 2 GB vRAM
    • 20 GB storage
  • PuTTY
  • Internet connection for YUM updates


Upload the ISO

Once your CentOS ISO is downloaded, we’ll want to upload it to your datastore or Content Library on your ESXi host.

  1. Once logged into vCenter, go to your “Storage” tab.

    Storage Tab
  2. Select the datastore you want to store the ISO on.
  3. Click the “Upload” icon.
  4. Select the location of the ISO file you downloaded. Typically, browsers default to save your downloads in the “Downloads” folder. Select OK.

Once the file transfer is complete, we will be ready to begin installing CentOS 7.


Create the VM

Our next step will be to create the VM that will host our CentOS environment.

  1. Click “VMs & Templates”.

    VMs & Templates
  2. On the left-hand side, click the datacenter or folder you want to place the VM and select “New Virtual Machine > New Virtual Machine…” in the drop down.
  3. Highlight “Create a new virtual machine”.

    Create a new virtual machine
  4. Enter a name for your VM. If this is going to be a template, use a generic name.

    Enter the name of the VM
  5. Select the compute resource (host) or resource pool you’d like to run your VM on.

    Select Compute
  6. Select the datastore to store the VM files.

    Select Storage
  7. Select VM compatibility level. This level should be determined by the minimum version of ESXi that the VM will run on. If you have a mix of ESXi 5.5, 6.0 and 6.5, you’ll want to set your compatibility level to 5.5 until you upgrade your ESXi hosts. (My host is currently 6.0 even though my vCenter server is 6.5.)
  8. In “Guest OS Family”, select “Linux”. In “Guest OS Version”, select “CentOS 4/5 or later” for CentOS 7. For RedHat 7, select “RedHat Enterprise Linux 7 (x64)”. Keep in mind the processor architecture of your ISO. For x86, use 32bit; for x64, use 64bit. (RHEL 7 is x64 only).

    Choose Guest OS
  9. In the “Customize Hardware” section, there are several other steps that can be taken to get the best experience in planning your VM template.
    • CPU: Select the number of CPUs and/or cores per CPU you’d like to default. I typically stick to 1/1 and add/hot add vCPU resources as needed when spinning up new VMs. You can check the box “Enable CPU Hot Add” to allow yourself to add vCPUs while the system is running to prevent downtime. (Note: Hot add only supports adding processors, not cores. However many cores you have set per socket is the increment each new processor added will increase.)

      Configure vCPU
    • Memory: Select the amount of RAM you’d like to default. 2GB is enough to run just CentOS 7. If you have plenty of physical RAM, you can default it to a higher amount. You can hot add by checking the box “Memory Hot Plug”. (Keep in mind, it’s easier to add more resources later than to reduce it if it’s over-provisioned.)

      Select vRAM
    • New Hard Disk: Select the size of your OS drive. It defaults to 16GB but I tend to increase it to 50GB but thin provision the drive. Thin provisioning allows me to create a larger drive but will only use what is needed for the OS. Initially, this can slow down disk performance as it has to write zeros to the disk before adding new content, but once the blocks are formatted, it will operate as normal. (This is not a requirement but a practice I follow. These options are up to you how you want to set your storage.)
      • Note: Thin provisioned disks can be inflated later if needed.

        Select Storage Options
    • (Optional) Add Hard Disk: If you’re running an application with a large dataset, it may be a good idea to add another HDD or RDM to your VM. This isn’t recommended for a template.
      • Select the dropdown for “New device:”
      • Select the device you want to add and click “Add”.
    • New Network: Select the port group/network you want your VM to communicate on. Linux typically defaults to VMXNET3, which is recommended. Select “Connect At Power On” if you want your VM to connect when started. Deselect if you want to isolate from the network.

      Network Settings
    • (Optional) New Floppy drive: I feel this is obsolete so I typically delete this from my template. You can keep it or add it later if you choose.
    • New CD/DVD drive: Depending on whether you saved your ISO to a datastore or Content Library, select the dropdown and select the location of your ISO.
      • Check the “Connect At Power On” checkbox.

        Mount CentOS ISO to CD/DVD drive
  10. Click Next to continue.
  11. Click Finish to finish creating the VM.

    Click Finish

We are now ready to install CentOS on our VM.


Install CentOS 7

  1. Open the console by right-clicking on the VM and select “Open Console” or select the Console Icon on the top bar. 
  2. Power On the VM. 
  3. Click inside the VMRC client and press the up button to select “Install CentOS 7”

    Install CentOS 7
  4. Once the Anaconda installer loads, you will be presented with the Welcome screen. Select your language and press “Continue”.

    Select Language
  5. The next screen will allow you to set your time zone, keyboard settings, language, security policy (if necessary).
  6. Under “Software”, the Installation source should automatically select “Local Media”. 
  7. Under “System”, the Installation destination is not set by default even though we have only one disk. Select “Installation Destination” and it will automatically select the disk if it’s the only one available. After the disk is selected, select “Done”.
  8. Next, under System, select “Network & Host Name”
  9. Set the hostname for your server at the bottom and switch the ethernet port to “ON”. If you have a DHCP server, the IP settings should set automatically.
    • If you need to set a static IP, select the “Configure…” button and go to the “IPv4 Settings” tab.
    • Change “Method:” to “Manual”. Select “Add” and enter your IP address, subnet mask and default gateway. If you have the address to your DNS servers, enter them in the “DNS servers:” field. If you don’t have a DNS server or it only needs to resolve the internet, you can use Google’s DNS servers at “8.8.8.8”. If you have a DNS server and need to add the domain suffix, enter your domain name under “Search Domains”.
    • Select Save to keep these settings.
  10. Select “Done” to continue.
  11. Select “Begin Installation” to start your install.
  12. While installing, it will offer “User Settings” to set the root password and to optionally create a user account. You must set the root password to continue.
  13. Click “Root Password” to set the root password.
  14. Try to set a strong password. If your password is weak, it will require you to press “Done” twice.
  15. Once the installation is complete and root password set, click “Finish Configuration” to reboot and load CentOS.

CentOS 7 is now installed on your VM. But we still need to update the server and prepare it for converting to a template.

Update & Template

Now that we have a fresh install of CentOS 7, we can prepare to make it a template.

  1. Using the VMRC, we can connect to our VM and login.
  2. First, we will update our installation by running the following command:
    • yum update -y

  3. After the update completes, we will need to install VM tools:
    • yum install -y open-vm-tools

  4. If you have any other software you want to include in your template, now is a good time to install it.
  5. Now that we have our preferred image ready, shut down the VM.
  6. Once the VM is shut down, right click the VM in the left navigation pane and go down to “Template>Convert to template”

You now have a ready-to-deploy CentOS 7 template.


Our next lesson will be to create a Linux-based Custom Specification Template to quickly deploy your new image. (Coming Soon)

Comments

comments

Leave a Reply