VMWare Workstation: Concepts
在 Windows 主机中，如果未使用增强型虚拟键盘功能，那么主机操作系统和虚拟机都会接收到此命令（即使 Workstation 对输入进行着控制）。取消结束主机操作系统会话的操作，并返回到虚拟机，以执行注销、关机或其他管理任务。
Ctrl+Alt+空格键 将任何命令发送到虚拟机，使 Workstation 不对其进行处理。要使用此功能，请按住 Ctrl+Alt 并释放空格键，然后在继续按住 Ctrl+Alt 键状态下按组合键的下一个键。
Ctrl+Shift+Tab （仅限 Windows 主机）在选项卡之间切换。
Ctrl+Shift+U 在 Unity 模式中，访问虚拟机的[开始]或[应用程序]菜单。
通过修改 Unity 首选项设置可以更改 Unity 热键组合。
Independent Persistent/Non-persistent Mode
In a nutshell, this all related to how the VMDK behaves when a virtual machine snapshot is taken. VMDKs, by default, are said to be dependent. In other words, when the virtual machine is snapshot’ed, this disk is included in the snapshot.
You can think of Independent as meaning ‘Independent of snapshots’.
Independent Persistent Mode
No delta file is associated with this disk during a snapshot operation. In another words, snapshot has no effect on disks in Independent Persistent Mode.
All changes to the disk are preserved when the snapshot is deleted.
Independent Non-persistent Mode
A redo log is created to capture all subsequent writes to that disk. However, if the snapshot is deleted, or the virtual machine is powered off, the changes captured in that redo log are discarded for that Independent Non-persistent VMDK.
Let’s take a virtual machine which hosts a web service, but it is primarily a read-only web site with content that rarely changes. This VM has three disks. Disk 1 contains the Guest OS and web application (e.g. Apache). Disk 2 contains the web pages for the web site. Disk 3 contains all the logging activity.
Virtual disk in single or multiple files
A monolithic disk: a virtual machine disk contained in a single file.
A split disk: a virtual machine disk split into 2GB files.
Disadvantages of monolithic disks:
If you delete snapshots and need to consolidate unused .vmdk files, if you need to defragment .vmdk files, etc., then your host needs as much free space as the entire .vmdk file. In contrast, if you use split disks, then your host needs only as much free space as one of the individual .vmdk extents.
If you want to copy or back up a VM, you might be copying it to a file system that doesn't support such large files.
If you're in the middle of copying or backing up a VM but need to cancel the operation and to resume it later, using split disks is much less painful.
Advantages of monolithic disks:
Less file system clutter (and in that sense it's easier to manage).
The VM will require fewer open file handles. Some host operating systems have a somewhat low limit on the maximum number of open file handles, and this can matter if you take a lot of snapshots.
kb.vmware.com: convert a monolithic disk to sparse disks. To change from a monolithic disk to a split disk, you must copy the virtual disk data from the monolithic disk to a new split disk. After copying the data, you must then associate the virtual machine with the new split disk. You may then delete the old monolithic disk.
vmwareBlogs: thin provisioning.
- Thin. VMDKs only consume blocks when data is written to disk from within the VM/Guest OS. The amount of actual space consumed by the VMDK starts out small, but grows in size as the Guest OS commits more I/O to disk, up to a maximum size set at VMDK creation time.
- Thick (aka LazyZeroedThick). These disks reserve space on the VMFS filesystem but there is an interesting caveat. Although they are called thick disks, they behave similar to thinly provisioned disks. Disk blocks are only used on the back-end (array) when they get written to inside in the VM/Guest OS.
- EagerZeroedThick. These virtual disks reserve space on the VMFS filesystem and zero out the disk blocks at creation time.
Size: 4294967296 Blocks: 3502080 IO Block: 131072 regular file
Device: c2b73def5e83e851h/14030751262388250705d Inode: 163613572 Links: 1
Access: (0600/-rw——-) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2012-02-29 13:04:53.000000000
Modify: 2012-03-01 15:29:11.000000000
Change: 2012-02-22 00:12:40.000000000
# This is a thinly provisioned 200GB VMDK (4294967296 * 512) but only ~ 1.8 GB (3502080 * 512) used.
vmwareSupport: how to defrag disks.:
- Run a disk defragmentation utility inside the virtual machine (guest OS).
- Power off the virtual machine, then defragment its virtual disks from the virtual machine settings editor (VM - Settings). Select the virtual disk you want to defragment, then click Defragment. Note: This capability works only with virtual disks, not physical or plain disks.
- Run a disk defragmentation utility on the host computer.
Large single virtual disk file has a problem in defragmentation. The defragmentation process requires free working space on the host computer's disk. If your virtual disk is contained in a single file, for example, you need free space equal to the size of the virtual disk file.
Host disks, virtual disks and guest disks all affect the performance of VMware Workstation.
It is strongly recommended that you defragment using a guest operating system mechanism before taking the first snapshot (or linked clone):
- Workstation makes all its changes to the redo log, not to the original disk, when you run a defragmenting program on the guest after a snapshot. You lose the ability to defragment inside the original disk forever.
- Every sector that moves is copied to the redo log, making the virtual machine redo log extremely large when the disk is heavily fragmented and you run defragmentation after a snapshot.
Performance Impact of Defragmenting Snapshots and Linked Clones
There may be a performance impact when you defragment a linked clone or a virtual machine with a snapshot. Exact performance degradation depends on:
- The fragmentation of the parent virtual machine disk when you created the snapshot or linked clone.
- The nature of the subsequent updates to the parent virtual machine disk.
Defragmentation tends to make the redo file grow. The redo file itself can become defragmented with respect to the host file system. If your use of virtual machines is strongly performance oriented, you should avoid defragmenting - or using - linked clones and snapshots.
vmware pubs: VM files.
- vmname.vmx: The primary configuration file.
- vmname.nvram: stores the state of the virtual machine BIOS.
- vmname-s###.vmdk: the Virtual disk files can increase. E.g. As data is added to a virtual disk, the files increase to a maximum of 2GB each.
- vmname-f###.vmdk: all disk space was allocated.
- vmname.vmsd: A centralized file for storing information and metadata about snapshots. It is stored in the working directory.
- vmname.Snapshot.vmsn: The snapshot state file, which stores the running state of a virtual machine at the time you take that snapshot. It is stored in the working directory.
- vmname.Snapshot###.vmsn: The file that stores the state of a snapshot.
- vmname.vmss: The suspended state file, which stores the state of a suspended virtual machine. It is stored in the working directory.
FAQ for VMWare
Shared VMDK for two VMs
Is is possible to create shared VMDK for two VMs? Simply put, yes it is but not recommended (even dangerous to data!).
Now what you have to consider is that there is no magic here, it literally is the same as a physical environment. The same as attaching a single SCSI disk to two hosts. We used to do this decades ago, but it comes with risks.
Just like any shared block storage, you need a clustered file system to handle the access. So you can't just take NTFS and attach it to two hosts at once. And even if you have a clustered filesystem, you can't share a SQL database between two systems just by attaching it to them.
What's dangerous? shared disk in general or to use it with SQL? Both. NTFS can't be shared. It is not a clustered file system. SQL on a clustered file system can't just be shared either. Just because a filesystem is clustered doesn't mean that a database file is. You need both a clustered file system and then you need your application (SQL Server in this case) to be clustered too.
Turn off guest time sync with host
VMWareKB: Disabling Time Synchronization.
The time synchronization checkbox controls only whether time is periodically resynchronized while the virtual machine is running. Even if this box is unselected, by default VMware Tools synchronizes the virtual machine's time after a few specific events that are likely to leave the time incorrect.
For VM ESXI, edit /vmfs/volumes/datastore_name/vm_name/vm_name.vmx. Set these options to zero. If the entries do not exist, add them.
Note: 0 = disabled, 1 = enabled.
tools.syncTime = "0"
time.synchronize.continue = "0"
time.synchronize.restore = "0"
time.synchronize.resume.disk = "0"
time.synchronize.shrink = "0"
time.synchronize.tools.startup = "0"
time.synchronize.tools.enable = "0"
time.synchronize.resume.host = "0"
Note: In GSX, VMware Fusion, VMware Player and VMware Workstation, you must use "FALSE" instead of "0".
VMWare workstation: operation
Taking a snapshot saves the current state of the virtual machine, so you can return to it at any time. Snapshots are useful when you need to revert a virtual machine repeatedly to the same state, but you don't want to create multiple virtual machines.
If you simply want to save the current state of your virtual machine temporarily, so you can continue work later from the same state, use Suspend and Resume.
To take snapshots of multiple virtual machines — for example, taking snapshots for all members of a team — requires that you take a separate a snapshot of each team member.
当我们为虚拟机创建的快照时，当前可写的VMDK文件变成为只读状态，并且创建一个新文件（称之为快照文件，*-delta.vmdk文件，也可以理解为redo-log文件。在每创建一个快照时就会产生一个这样的文件。而在删除快照或回复到快照时间点状态时该文件会被删除）来保存变化的内容（使用in-file delta technology)。在初始状态下，快照文件的大小为16MB，并随着虚拟机对磁盘文件的写操作而增长。快照文件按照16MB的大小进行增长以减少SCSI reservation冲突。当虚拟机需要修改原来的磁盘文件的数据块时，这些修改会被保存到快照文件中。当在快照文件中的已经修改过的数据块需要被再次修改时，这些修改将覆盖快照文件中的数据块，此时，快照文件大小不会改变。因此，快照文件的大小永远不会超过原来的VMDK文件的大小。多个快照的情况下，在创建新的快照时，之前的快照文件变成只读的状态。
netappKB: SCSI reservation. SCSI reservations are used to control access to a shared SCSI device such as a disk or tape drive. An initiator sets a reservation on a Logical Unit Number (LUN) in order to prevent another initiator from making changes to the LUN. This is similar to the file-locking concept.
When a snapshot is created, it is comprised of these files:
- "vm"-"number".vmdk and "vm"-"number"-delta.vmdk
A collection of .vmdk and -delta.vmdk files for each virtual disk is connected to the virtual machine at the time of the snapshot. These files can be referred to as child disks, redo logs, or delta links. These child disks can later be considered parent disks for future child disks. From the original parent disk, each child constitutes a redo log pointing back from the present state of the virtual disk, one step at a time, to the original.
Note: The "number" value may not be consistent across all child disks from the same snapshot. The file names are chosen based on filename availability. If the virtual disk is larger than 2TB in size, the redo log file is of "vm"-"number"-sesparse.vmdk format.
The .vmsd file is a database of the virtual machine's snapshot information and the primary source of information for the Snapshot Manager. The file contains line entries which define the relationships between snapshots as well as the child disks for each snapshot.
The .vmsn file includes the current configuration and optionally the active state of the virtual machine. Capturing the memory state of the virtual machine lets you revert to a turned on virtual machine state. With nonmemory snapshots, you can only revert to a turned off virtual machine state. Memory snapshots take longer to create than nonmemory snapshots.
Disabling Snapshots for Better Performance
VMware Workstation operates more efficiently with snapshots disabled. If you do not need snapshot functionality, disable it for better performance.
A clone is a copy of an existing virtual machine. The existing virtual machine is called the parent of the clone. When the cloning operation is complete, the clone is a separate virtual machine.
Why Make a Clone?
Installing a guest operating system and applications can be time consuming. With clones, you can make many copies of a virtual machine from a single installation and configuration process.
Clones are useful when you must deploy many identical virtual machines to a group.
Full clones vs Linked clones
A full clone is an independent virtual machine, with no need to access the parent. Because a full clone does not share virtual disks with the parent virtual machine, full clones generally perform better than linked clones. However, full clones take longer to create than linked clones.
A linked clone is made from a snapshot of the parent. Ongoing changes to the virtual disk of the parent do not affect the linked clone, and changes to the disk of the linked clone do not affect the parent.
A linked clone must have access to the parent. Without access to the parent, a linked clone is disabled.
Linked clones are created swiftly, so you can easily create a unique virtual machine for each task you have.
You can also easily share a virtual machine with other users by storing the virtual machine on your local network, where other users can quickly make a linked clone. This facilitates collaboration: for example, a support team can reproduce a bug in a virtual machine, and an engineer can quickly make a linked clone of that virtual machine to work on the bug.
Un-cloning linked cloned VM
wcfNote: my method, in linked cloned VM, make a full clone, then remove the linked clone.
In short, you would have to manually copy the virtual hard disk from the parent to the clone's folder and edit the parentFileNameHint in the Disk DescriptorFile of the clones base virtual hard disk.
Suspend and Resume
VMWare Support: suspend and resume.
The suspend and resume feature is useful when you want to save the current state of your virtual machine, and continue work later from the same state.
The speed of the suspend and resume operations depends on how much data has changed while the virtual machine has been running.
When you suspend a virtual machine, a file with a .vmss extension is created. This file contains the entire state of the virtual machine.