New on : Clone ESXi VM disk the easy way
Yesterday I wanted to prepare a mini lab with 6 Windows 2008 R2 virtual servers. Installing those machines one by one would be a tedious task, so I looked into a few options. ESXi is VMware’s free hypervisor product and as such doesn’t bring you nicer features like vMotion, templates or cloning. However, there is a workaround to clone a machine even with ESXi. It’s more of a logical solution than revelation. So here’s a step by step guide to clone ESXi VM:
- Create your “reference” VM named “Reference”. We’ll use this one to prepare the virtual disk for the rest of machines.
- Install Windows Server OS and customize it the way you want. There are excellent suggestions over at Jason Samuel’s (2008 R2) and Jeremy Waldrop’s (2008 and Win7) websites. Don’t install roles or features, just basic stuff like RD access, Windows updates, etc. Look into BgInfo, SysInternals excellent piece of software that displays system information as wallpaper. Useful when remoting into several servers at once. Also, you might want to turn off Event Shutdown Tracker (gpedit.msc -> Computer Configuration -> Administrative Templates -> System).
- Sysprep the machine using suggestions from Technet’s KB 973289. The important thing to note here is the /generalize option and CopyProfile option in unattend.xml. You must shut down the machine after sysprep.
- SSH into your ESXi host. Create a new folder (Server) for your new virtual machine:
mkdir /vmfs/volumes/Datastore/Server
Replace “Datastore” with your datastore name. Copy Reference.vmdk to that folder:
vmkfstools -i /vmfs/volumes/Datastore/Reference/Reference.vmdk /vmfs/volumes/Datastore/Server/
Warning: ESXi is based on Linux, so letters are case-sensitive.
- Create a new virtual machine and attach existing disk from /Server/ folder.
That’s it. Settings that didn’t get copied from Jason’s tutorial:
- Network adapter settings (because we created a new machine with new NIC)
- VMware Tools (don’t install it at all – you have to uninstall it, then install again in the new machine)
- Pinning and unpinning shortcuts
- Taskbar settings