Continuing with the articles that are part of the VCP5-DCV blueprint, it’s time for us to talk about virtual machines. In this article we will be learning:
- * What is a virtual machine?
- * Different resources that can be assigned to a virtual machine
- * What are the VMware Tools and the importance of them?
- * How to convert a physical server into a virtual machine
- * Design best practices/guidelines
What is a virtual machine?
A virtual machine is a set of virtual hardware and files. The virtual hardware gives us the possibility to install a Guest OS on top. This Operating system must be “supported” by the Hypervisor, although many times you can install unsupported Guest OSes.
- Virtual machine files:
So, lets take a look at some of the most important files that constitute a VMware virtual machine:
- .VMX file – This is the configuration file for a VM.I In this file all the properties like number of vCPUs, RAM, Virtual Nic interfaces, Guest OS, etc. are contained.
- .VMDK file – This file is also known as the virtual disk descriptor.Here the geometry of the virtual disk is described.
- –flat.vmdk – This is the data disk file where all the information of the VM is stored.
- .nvram – This file contains the “Bios” of the virtual machine (settings, etc.)
- .vswp – This file is the VM swap file. It is created once the VM is started and is used by the hypervisor to guarantee the assigned memory to the VM. This file is equal in size of the vRAM (RAM assigned to the VM). The only situation when it can be different is when you have a memory reservation configured to vm. In that case the .vswp file will be the same size as the defined reservation.
- .vmtx – this file is only present when you mark the VM as a template, when you set a VM as a template the only thing that happens is that the .vmx file is converted into a .vmtx file
- .vmsd – this file is a snapshot descriptor. You can find the different snapshots that you have for that VM, the files of those snaps, etc.
- vmss – this file is known as the “snapshot state.” Here the configuration state (.vmx information) of the VM at the time when the snapshot was taken is stored. So for example, if I took a snapshot when the VM was configured with just one vCPU and then I take a snapshot with 2 vCPUs the change in number of vCPUs will be known by the hypervisor using this .vmss file.
- -delta.vmdk – this file contains the changes of the VM after a snapshot was taken, so we essentially have the “base” disk and the delta files that store all further changes on disk.
As we can see, a virtual machine is easy to migrate and manage because it is a set of file, instead of a physical server. There are other VM files like .log files and .lck lock files.
Resources that can be assigned to a virtual machine:
- Virtual machine hardware:
A virtual machine requires a set of “virtual devices.” These devices or virtual hardware provides access to the underlying physical resources. It is important to note that the access to hardware is controlled by the hypervisor. Currently VMware presents the following hardware devices to the virtual machines:
- SCSI adapter – This virtual SCSI adapter allows the use of “virtual disks, with a maximum of 4 SCSI adapters per VM and 15 targets (disks) in each adapter (60 disks). There are different types of adapters: LSI Logic Parallel, LSI Logic SAS, BusLogic Parallel and VMware Paravirtual SCSI (PVSCSI). PVSCSI adapter is a Paravirtualized virtual adapter that can give us greater performance.I If you want to know more about it take a look here.
- USB controller – A vSphere VM can have three types of USB controllers: UHCI (USB 1.0), EHCI (USB 2.0) and xHCI (USB 3.0), with a maximum of one controller of each type (3 controllers) per VM (3 controllers different version of USB). Each controller can have up to 20 different devices.
- Floppy controller – This floppy controller can have up to two devices. Usually this virtual floppy is used to insert drivers in a floppy image (.flp).
- Network cards – Also known as “vNics,” vSphere supports up to 10 network cards per VM. There are different types of vNics that can be available to a VM depending on the virtual hardware or “VM compatibility,” vlance (emulated 10 Mbps nic), E1000, Flexible (can change between vlance or VMXNET), VMXNET2 and VMXNET3.The VMXNET adapters are “paravirtualized” adapters, that allows better performance. If you want to know more about the different types of virtual nics take a look at this great blog post. Also we can have SR–IOV compatible devices (virtual interfaces of a physical nic/PCIe device) that can be presented to a VM reducing the overhead and increasing the performance.
- AHCI controller (SATA) – This type of controller is only available in vSphere 5.5. A VM can have up to 4 SATA controllers with a maximum of 30 disks per controller.
- Video card – provides video for the VM. We can also add 3D hardware rendering and software rendering to this “vGPU.”
- Other – a VM can have up to three parallel ports and up to four serial/com ports.
- RAM – the maximum amount of RAM that can be assigned to a VM in vSphere 5.5 is 1TB.
- CPU – the maximum number of vCPUs that can be assigned to a VM is 64. This is true for vSphere 5.5.
It’s very important to know that the CPU is not virtualized by the vmkernel. The hypervisor only assigns the different vCPUs to different cores on the physical system leveraging the CPU scheduler.
- Virtual Disks
As we already know, a virtual machine can have virtual disks that are attached to a vSCSI adapter or a SATA controller, but we can add different types of virtual disks that will reflect directly in the physical storage.
Let’s start by explaining what is Thin Provisioning at vSphere. Thin Provisioning enables the hypervisor to assign disk space to the VMs on demand. This allows over allocation of the physical storage. With Thin Provisioning the Guest OS (the Operating system installed in the VM) sees the full allocated space but in reality only the consumed space is allocated on the physical storage.
John creates a VM with a thin provisioned virtual disk. He assigns 80GB of space to that disk. John installs an Ubuntu guest OS and several applications that consumes a total of 40GB from the 80GB allocated so it’s only 50 percent. Only 40GB of space is consumed at the physical disk/storage as we can see in the following image:
Basically the hypervisor “tricks” the gOS and reports the total size of the disk without really occupying all the space in the physical storage.
Now that we know what is Thin Provisioning lets take a look at the current supported types of virtual disks or VMDKs:
- Thick provision lazy zeroed – this type of disk allocates the total space assigned to it on the physical disk/layer (datastore). If there was previous data on the disk it does not get over written due to the fact that with this type of disk there is no writing of zeroes to the blocks that constitute the virtual disk. In this case the “erasing” or writing of zeroes is performed on demand on first write.
- Thick provision eagered zeroed – in this type of disk all the space is allocated on creation and a write of zeroes is performed on all blocks that are part of this virtual disk. Because of this the time to create an eagered zeroed vmdk is longer.
- Thin provision – with this type of disk space is allocated on demand.
Now it’s time to talk about the different disk modes on vSphere. This “modes” define how a vmdk (virtual disk) will behave when we want to take a snapshot of the VM. The following modes can be configured:
- Dependent – With this mode the virtual disk (vmdk) is included in the snapshot, so if you delete the snapshot the changes are gone.
In this mode if we power off the VM the snapshot and changes are persistent.
- Independent persistent mode – In this mode the virtual disk is not affected by snapshots, so no delta file is created and every change is written directly to disk.
- Independent Non persistent – in this mode the virtual disk is affected by snapshots, a redo log is created (delta file) and any write or change is captured there.If you delete the snapshot or power off the changes are gone.
Stay tuned for my next article for the VCP–DCV 5 where we are going to learn what the VMware tools are, convert a physical server with VMware Converter and some design tips.