All notes
Vmwar

VMware ESX

A hypervisor or virtual machine monitor (VMM) is a piece of computer software, firmware or hardware that creates and runs virtual machines.
A computer on which a hypervisor is running one or more virtual machines is defined as a host machine. Each virtual machine is called a guest machine.

VMWare Workstation: Concepts

Shortcuts

Ctrl+G  抓取键盘和鼠标输入内容。
Ctrl+Alt 释放鼠标光标。

Ctrl+Alt+Insert 关闭客户机操作系统,或从客户机操作系统注销(取决于客户机操作系统)。此命令只会被虚拟机接收。
Ctrl+Alt+Delete 关闭客户机操作系统,或从客户机操作系统注销(取决于操作系统)。
	在 Windows 主机中,如果未使用增强型虚拟键盘功能,那么主机操作系统和虚拟机都会接收到此命令(即使 Workstation 对输入进行着控制)。取消结束主机操作系统会话的操作,并返回到虚拟机,以执行注销、关机或其他管理任务。

Ctrl+Alt+Enter 进入全屏模式。

Ctrl+Alt+空格键 将任何命令发送到虚拟机,使 Workstation 不对其进行处理。要使用此功能,请按住 Ctrl+Alt 并释放空格键,然后在继续按住 Ctrl+Alt 键状态下按组合键的下一个键。

Ctrl+Tab
Ctrl+Shift+Tab (仅限 Windows 主机)在选项卡之间切换。

Ctrl+Alt+Left/Right 在全屏模式下,切换到上/下一个处于开启状态的虚拟机。

Ctrl+Shift+U 在 Unity 模式中,访问虚拟机的[开始]或[应用程序]菜单。
	通过修改 Unity 首选项设置可以更改 Unity 热键组合。

Disks

Independent Persistent/Non-persistent Mode

cormachogan.com.

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.

Example:

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.

Thin/Thick Provisioning

vmwareBlogs: thin provisioning.


stat zzz-flat.vmdk
  File: "zzz-flat.vmdk"
  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.

Fragmentation

Recommended steps

vmwareSupport: how to defrag disks.:

  1. Run a disk defragmentation utility inside the virtual machine (guest OS).
  2. 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.
  3. Run a disk defragmentation utility on the host computer.

Best practices

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):

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:

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.

Files

vmware pubs: VM files.

FAQ for VMWare

Shared VMDK for two VMs

spiceWorks.com.

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

Snapshots

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文件的大小。多个快照的情况下,在创建新的快照时,之前的快照文件变成只读的状态。

在创建快照前,所有的写操作都写入磁盘文件。但是有了快照之后,磁盘文件保持不变,而写操作写入delta文件,同时,如果保存内存状态的话,vmsn文件还要占用比该虚拟机稍大一些的空间。

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.

Created Files

When a snapshot is created, it is comprised of these files:

Delete, Revert

删除快照或者回滚到快照点状态。如果选择回滚的快照不包含内存状态,那么该虚拟机将会被关机。

在只有一个快照时,在删除快照时不需要额外的空间。因为要么直接删除快照文件,要么把快照文件和VMDK磁盘文件相合并。但是在有多个快照的情况时,效果就不一样了。

假设要删除一个虚拟机的所有快照,该虚拟机有三个快照,snap1、snap2和snap3。首先,snap3的快照文件要被合并到snap2的快照文件中,导致snap2占用空间增加。然后,snap2被合并到snap1中,导致snap1占用的空间增加。最后,snap1合并到VMDK文件中,此时不会增加空间开销。在合并完成后,快照才会被删除。

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.

Clones

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.

vmware communities.

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.