A virtual machine is a set of virtual hardware whose characteristics are determined by a set of encapsulated files; it is this virtual hardware that a guest operating system is installed on. A virtual machine runs an operating system and a set of applications in a similar fashion to a physical server. Essentially, a virtual machine is comprised of configuration files and its physical resources are provided by an ESXi host.
Virtual machines are created within a virtualization layer, and this virtualization layer manages requests from the virtual machine for resources such as CPU or memory. It is this virtualization layer that is responsible for translating these requests to the underlying physical hardware.
Each virtual machine is granted a portion of the physical hardware. All VMs have their own virtual hardware (there are important ones to note, called the core 4: CPU, memory, disk, and network). Each VM is isolated from the other and each interacts with the underlying hardware through a thin software layer known as the hypervisor. This is different from a physical architecture in which the installed operating system interacts with the installed hardware directly.
With virtualization, there are many benefits in relation to portability, security, and manageability that aren't available in an environment that uses a traditional physical infrastructure. However, once provisioned, virtual machines use many of the same principles that are applied to physical servers.
In this chapter, we will learn:
A virtual machine needs four core resources: CPU, memory, network, and storage (disk). These resources are granted to the virtual machine through the configuration of the virtual hardware.
When a virtual machine is created, a default set of virtual hardware is assigned to it. VMware provides devices and resources that can be added and configured to the virtual machine. Not all virtual hardware devices will be available to every single virtual machine; both the physical hardware of the ESXi host and the VM's guest OS must support these configurations. For example, a virtual machine will not be capable of being configured with more vCPUs than the ESXi host has CPU sockets.
The virtual hardware available includes:
.iso
file located on a datastore. DVD/CD-ROM devices can be added to or removed from a virtual machine..flp
) located on a datastore. Floppy devices can be added to or removed from a virtual machine.Keep in mind that snapshots are not supported with DirectPath I/O pass-through device configuration. For more information on virtual machine snapshots, see http://vmware.com/kb/1015180.
Virtualization decouples physical hardware from an operating system. Each virtual machine contains a set of its own virtual hardware and there are four primary resources that a virtual machine needs in order to correctly function. These are CPU, memory, network, and hard disk. These four resources look like physical hardware to the guest operating systems and applications. The virtual machine is granted access to a portion of the resources at creation and can be reconfigured at any time thereafter. If a virtual machine experiences constraint, one of the four core resources is where a bottleneck will generally occur.
The virtualization layer runs CPU instructions to make sure that the virtual machines run as though accessing the physical processor on the ESXi host. Performance is paramount for CPU virtualization, and therefore will use the ESXi host physical resources whenever possible.
A virtual machine can be configured with up to 128 virtual CPUs (vCPUs) as of vSphere 6.0. The maximum vCPUs able to be allocated depends on the underlying logical cores that the physical hardware has. Another factor in the maximum vCPUs is the tier of vSphere licensing; only Enterprise Plus licensing allows for 128 vCPUs. The VMkernel includes a CPU scheduler that dynamically schedules vCPUs on the ESXi host's physical processors.
The VMkernel scheduler, when making scheduling decisions, considers socket-core-thread topology. A socket is a single, integrated circuit package that has one or more physical processor cores. Each core has one or more logical processors, also known as threads. If hyperthreading is enabled on the host, then ESXi is capable of executing two threads, or sets of instruction, simultaneously. Effectively, hyperthreading provides more logical CPUs to ESXi on which vCPUs can be scheduled, providing more scheduler throughput. However, keep in mind that hyperthreading does not double the core's power. During times of CPU contention, when VMs are competing for resources, the VMkernel time-slices the physical processor across all virtual machines to ensure that the VMs run as if having a specified number of vCPUs.
VMware Virtual Symmetric Multiprocessing (SMP) is what allows the virtual machines to be configured with up to 128 virtual CPUs, which allows a larger CPU workload to run on an ESXi host. Though most supported guest operating systems are multiprocessor aware, many guest OSs and applications do not need and are not enhanced by having multiple vCPUs. Check vendor documentation for operating system and application requirements before configuring SMP virtual machines.
In a physical architecture, an operating system assumes that it owns all physical memory in the server, which is a correct assumption. A guest operating system in a virtual architecture also makes this assumption but it does not, in fact, own all of the physical memory. A guest operating system in a virtual machine uses a contiguous virtual address space that is created by ESXi as its configured memory.
Virtual memory is a well-known technique that creates this contiguous virtual address space, allowing the hardware and operating system to handle the address translation between the physical and virtual address spaces. Since each virtual machine has its own contiguous virtual address space, this allows ESXi to run more than one virtual machine at the same time. The virtual machine's memory is protected against access from other virtual machines.
This effectively results in three layers of virtual memory in ESXi: physical memory, guest operating system physical memory, and guest operating system virtual memory. The VMkernel presents a portion of physical host memory to the virtual machine as its guest operating system physical memory. The guest operating system presents the virtual memory to the applications:
The virtual machine is configured with a set of memory; this is the sum that the guest OS is told it has available to it. A virtual machine will not necessarily use the entire memory size, it only uses what is needed at the time by the guest OS and applications. However, a VM cannot access more memory than the configured memory size. A default memory size is provided by vSphere when creating the virtual machine. It is important to know the memory needs of the application and guest operating system being virtualized so that the virtual machine's memory can be sized accordingly.
There are two key components with virtual networking: the virtual switch and virtual Ethernet adapters. A virtual machine can be configured with up to 10 virtual Ethernet adapters called vNICs. A vNIC is the virtual machine's network adapter that connects it to the port group on a virtual switch, whereas a vmnic is the physical NIC acting as an uplink on an ESXi host.
Virtual network switching is software interfacing between virtual machines at the vSwitch level until the frames hit an uplink or a physical adapter, exiting the ESXi host and entering the physical network. Virtual networks exist for virtual devices; all communication between the virtual machines and the external world (physical network) goes through vSphere standard switches or vSphere distributed switches.
Virtual networks operate on layer 2, data link, of the OSI model. A virtual switch is similar to a physical Ethernet switch in many ways. For example, virtual switches support the standard VLAN (802.1Q) implementation and have a forwarding table, like a physical switch. An ESXi host may contain more than one virtual switch. Each virtual switch is capable of binding multiple vmnics together in a Network Interface Card (NIC) team, which offers greater availability to the virtual machines using the virtual switch.
There are two connection types available on a virtual switch: a port group and a VMkernel port. Virtual machines are connected to port groups on a virtual switch, allowing access to network resources. VMkernel ports provide a network service to the ESXi host to include IP storage, management, vMotion, and so on. Each VMkernel port must be configured with its own IP address and network mask. The port groups and VMkernel ports reside on a virtual switch and connect to the physical network through the physical Ethernet adapters known as vmnics. If uplinks (vmnics) are associated with a virtual switch, then the virtual machines connected to a port group on this virtual switch will be able to access the physical network.
In a non-virtualized environment, physical servers connect directly to storage, either to an external storage array or to their internal hard disk arrays to the server chassis. The issue with this configuration is that a single server expects total ownership of the physical device, tying an entire disk drive to one server. Sharing storage resources in non-virtualized environments can require complex filesystems and migration to file-based Network Attached Storage (NAS) or Storage Area Networks (SAN), or with vSphere 6.0, Virtual SAN (VSAN) or Virtual Volumes (VVOLs).
Shared storage is a foundational technology that allows many things to happen in a virtual environment (High Availability, Distributed Resource Scheduler, and so on). Virtual machines are encapsulated in a set of discrete files stored on a datastore. This encapsulation makes the VMs portable and easy to be cloned or backed up. For each virtual machine, there is a directory on the datastore that contains all of the VM's files. A datastore is a generic term for a container that holds files as well as .iso
images and floppy images. It can be formatted with VMware's Virtual Machine File System (VMFS) or can use NFS. Both datastore types can be accessed across multiple ESXi hosts.
VMFS is a high-performance, clustered filesystem devised for virtual machines, which allows a virtualization-based architecture of multiple physical servers to read and write to the same storage simultaneously. VMFS is designed, constructed, and optimized for virtualization. The newest version, VMFS-5, exclusively uses 1 MB block size, which is good for large files, while also having an 8 KB subblock allocation for writing small files such as logs. VMFS-5 can have datastores as large as 64 TB. The ESXi hosts use a locking mechanism to prevent the other ESXi hosts accessing the same storage from writing to the VMs' files. This helps prevent corruption.
Several storage protocols can be used to access and interface with VMFS datastores. These include Fibre Channel, Fibre Channel over Ethernet, iSCSI, and direct attached storage. The NFS protocol can also be used to create an NFS datastore. The VMFS datastore can be dynamically expanded, allowing the growth of the shared storage pool with no downtime.
vSphere significantly simplifies accessing storage from the guest OS of the VM. The virtual hardware presented to the guest operating system includes a set of familiar SCSI and IDE controllers; this way the guest OS sees a simple physical disk attached via a common controller. Presenting a virtualized storage view to the virtual machine's guest OS has advantages such as expanded support and access, improved efficiency, and easier storage management.
vSphere administrators should know the components of virtual machines. There are multiple VMware file types that are associated with and make up a virtual machine. These files are located in the VM's directory on a datastore. The following table will summarize and provide a quick reference and short description of all the files that make up a virtual machine:
Depending on the state and configuration of the virtual machine, not all files will be present in the virtual machine directory.
Let's explore these virtual machine files in more detail.
The .vmx
file describes the current configuration information and hardware settings for the VM. This can contain a large variety of information regarding the virtual machine, to include its specific virtual hardware configuration (amount of RAM, NIC settings, CD-ROM information, parallel/serial port information, and so on), as well as its advanced resource and power settings, VMware tools options, and so forth. It is possible to make changes and directly edit this file; however, you should only do this at your own risk.
The .vmx
file is a plain-text file that functions as the structural definition of the VM. The .vmx
file can be copied from the datastore and opened using a program that supports the creation and saving of files using UTF-8 encoding, such as WordPad. The following excerpt shows an example of a .vmx
file for a virtual machine named ExampleVM
:
.encoding = "UTF-8" config.version = "8" virtualHW.version = "11" nvram = "ExampleVM.nvram" pciBridge0.present = "TRUE" svga.present = "TRUE" pciBridge4.present = "TRUE" pciBridge4.virtualDev = "pcieRootPort" pciBridge4.functions = "8" pciBridge5.present = "TRUE" pciBridge5.virtualDev = "pcieRootPort" pciBridge5.functions = "8" pciBridge6.present = "TRUE" pciBridge6.virtualDev = "pcieRootPort" pciBridge6.functions = "8" pciBridge7.present = "TRUE" pciBridge7.virtualDev = "pcieRootPort" pciBridge7.functions = "8" vmci0.present = "TRUE" hpet0.present = "TRUE" svga.vramSize = "8388608" memSize = "4096" sched.cpu.units = "mhz" sched.cpu.affinity = "all" sched.mem.affinity = "all" powerType.powerOff = "default" powerType.suspend = "default" powerType.reset = "default" scsi0.virtualDev = "lsisas1068" scsi0.present = "TRUE" sata0.present = "TRUE" scsi0:0.deviceType = "scsi-hardDisk" scsi0:0.fileName = "ExampleVM.vmdk" sched.scsi0:0.shares = "normal" sched.scsi0:0.throughputCap = "off" scsi0:0.present = "TRUE" ethernet0.virtualDev = "e1000e" ethernet0.networkName = "VM Network" ethernet0.addressType = "vpx" ethernet0.generatedAddress = "00:50:56:ac:e1:a8" ethernet0.present = "TRUE" sata0:0.startConnected = "FALSE" sata0:0.deviceType = "cdrom-raw" sata0:0.clientDevice = "TRUE" sata0:0.fileName = "emptyBackingString" sata0:0.present = "TRUE" floppy0.startConnected = "FALSE" floppy0.clientDevice = "TRUE" floppy0.fileName = "vmware-null-remote-floppy" displayName = "ExampleVM" guestOS = "windows8srv-64" disk.EnableUUID = "TRUE" toolScripts.afterPowerOn = "TRUE" toolScripts.afterResume = "TRUE" toolScripts.beforeSuspend = "TRUE" toolScripts.beforePowerOff = "TRUE" uuid.bios = "42 2c 9e f6 48 47 8f 8c-60 2f 5a 66 37 0a 6e 3c" vc.uuid = "50 2c 81 6b 04 4c 47 19-77 c9 16 97 d0 1b 33 43" sched.cpu.min = "0" sched.cpu.shares = "normal" sched.mem.min = "0" sched.mem.minSize = "0" sched.mem.shares = "normal"
Reading through this file gives us important information regarding the configuration of the virtual machine. Here are a few examples:
guestOS
linememsize
line, it is known that the VM was configured for 4 GB of memoryethernet0
lines00:50:56:ac:e1:a8
, specified by the ethernet0.generatedAddress
lineA virtual machine's .vmx
file is most commonly edited to modify the MAC address so that it matches the effective MAC address set within the guest operating system. However, this practice is becoming less and less common due to this configuration change being done more easily in the vSphere Web Client.
The .vmx
file is extremely important to the virtual machine. However, keep in mind that it only structurally defines the VM's virtual hardware composition. It does not hold any actual data from the guest OS running within the VM. The virtual machine's data is stored in its virtual disk file. Here's an overview of the configuration and BIOS files:
.vmtx
: When a virtual machine is converted to a template, the virtual machine configuration file (.vmx
) is replaced by the template configuration file (.vmtx
)..nvram
: This is generally a fairly small file which contains the BIOS settings that the VM uses upon boot. This is similar to how a physical server that has a BIOS chip allows hardware configuration options. The virtual BIOS settings, contained in the .nvram
file, can be accessed by pressing F2 when the virtual machine is powered on.The .vswp
file is created when the virtual machine is powered on. The size of the .vswp
file is equal to that of a configured memory, unless there is a reservation. When a memory reservation is configured for a VM, then the .vswp
file size would equal the configured memory size minus the memory reservation. This file is used as a last resort when the hypervisor is reclaiming physical memory from its virtual machines due to contention.
Looking at the previous table, you may have noticed the vmx-<vmname>.vswp
file. This file is for the overhead memory created for a VM, a new feature in vSphere 5.x. Historically, this memory overhead was not swappable. Though there was a memory reservation to back this, the entire address space did not actually have to reside in memory. This file helps to reduce the reservation requirements for virtual machines.
The following are some of the virtual disk files:
.vmdk
: This is the Virtual disk descriptor, which holds information such as the size and disk geometry of the virtual disk, information that makes the VM believe it has a real hard disk and not files on a datastore. Such information includes the virtual disk's adapter type, drive sectors, heads, and cylinders. This descriptor file also contains a pointer to the larger data file for the virtual disk or the -flat.vmdk
file.-flat.vmdk
: This file actually contains the virtual disk's data. This is created by default when a virtual hard drive is added to a virtual machine that is not using the Raw Device Mapping (RDM) option. When created as a thick provisioned disk, it will be sized approximately to what was specified in the creation wizard.-rdm.vmdk
: This is the mapping file for the RDM option, managing the RDM device's mapping data. The virtual machine isn't aware of this since the mapping file is presented to the ESXi host as a traditional disk file and is available for normal filesystem operations. The storage virtualization layer presents the mapped device as a virtual SCSI device to the VM. An -rdm.vmdk
file exists for each RDM configured for the virtual machine.The following are the snapshot files:
-delta.vmdk
: These files are only used when creating snapshots. When a snapshot is created, the original -flat.vmdk
file is no being longer written to; it becomes read only. All changes that are written to the virtual disk are now being written to the -delta.vmdk
files instead. The -delta.vmdk
file cannot exceed the size of the original -flat.vmdk
file due to the fact that these -delta.vmdk
files are bitmaps of changes made to a virtual disk. A -delta.vmdk
file is created for each snapshot taken. These -delta.vmdk
files are updated in 16 MB increments as changes are written to the virtual disk..vmsd
: This file is a snapshot descriptor that contains information regarding which files are used by each snapshot, description, display name, and any associated UIDs. There is only one .vmsd
file per virtual machine, regardless of how many snapshots the virtual machine has. This file is updated each time a new snapshot is created or a snapshot is deleted..vmsn
: This file stores the virtual machine's state at the time the snapshot was taken. The size of this file varies depending on whether the option to include the VM's memory state was selected during snapshot creation. A separate .vmsn
file will be created for each snapshot and will automatically be removed when the snapshot is deleted.Let's take a look at some other files:
.vmss
: This file is used when a virtual machine is suspended so as to preserve the VM's memory contents; it is only present when the VM is suspended. When the virtual machine is resumed from the suspended state, it can start again right from where it left off. The contents of this file are written back to the ESXi host's physical memory when the virtual machine is brought out of a suspended state; however, the file will not be automatically deleted until the VM is powered off. This file will be approximately the same size as the configured memory for the virtual machine, unless memory contention is present..log
: Log files are created in order to log information regarding the virtual machine, typically used during troubleshooting efforts. The current log file is always named vmware.log
, and by default up to six older log files will be retained. These older log files will have a number appended at the end of their names, which will be updated with each file (vmware-2.log
).18.222.137.240