Welcomes you to the session

Virtualization for Developers Speaker Michael Fischer

Copyright ©2008 Fischer & Consultants GmbH (F&C) Martinstrasse 1 44137 Dortmund Germany www.appfact.de [email protected]

1 for Developers Inhalt

1. Creating a New Virtual Machine 6. Virtual Disks 2. More Machines 7. Virtual Networks 3. Basics 8. P2V and V2V 4. Market Overview 5. Scenarios for Developers

Slide 2

Abstract: Virtualization for Developers Every good session starts with a sample. In part one of this this series about virtualization, Michael Fischer builds a virtual machine from scratch. Based on this example Michael covers the basics of virtualization: . What’s the difference between virtualization and emulation . What’s the difference between a virtualization layer and hyper visor . How do virtual disks and virtual networks work? And he answers probably the most important question: What do I need this for? Part II is dedicated to real world scenarios for developers: . Converting existing physical machines into virtual machines . Building test machines for developers and QA staff The session will conclude by building a complete team of virtualmachines which emulate a high availability SQL database cluster.

2 Virtualization for Developers 1. Creating a New Virtual Machine

Steps:

n Get the VMware Eval from www.VMware.com and install it

n Create a root C:\VirtualMachines

n Create a subdirectory \Images

n Convert a Windows CD into an ISO image in the \Images directory

n Define the virtual machine

n Install Windows from the ISO image

n Install VMware Tools

n Make your first snapshot

Slide 3

We will use VMware Workstation 6 for all examples in this presentation.

Working with ISO images •Most pre-installed CD can convert a physical CD into an ISO image •Freeware: LC ISO Creator (www.lucersoft.com/freeware.php) •UltraISO (www.ezbsystems.com/ultraiso/main.htm) •WinISO (www.winiso.com) •WinImage (www.winimage.com) This tool can also Virtual PC Harddisks (.VHD) like VMwares feature

3 Virtualization for Developers 1. Creating a New Virtual Machine

Start the Assistant

Slide 4

Start the New, Virtual Machine assistant from the File menu. We will use the Custom option to see our options.

4 Virtualization for Developers 1. Creating a New Virtual Machine

Choose the Hardware Compatibility and the Designated Guest OS

Slide 5

OS Version 64bit Clients are only supported if you have a suited processor and chip set on your host’s mainboard.

From a Steve Herrod’s blog on VMware.com: „For AMD-based systems, the processors must be Athlon64 or Opteron Rev E or later. For Intel-based systems, the processors must include support for Intel’s Virtualization Technology (EM64T). …If you‘re interested in a lightish version of the details, Wikipedia has some pretty good articles on AMD64 and EM64T.”

In addition, the BIOS must support a 64 bit hardware virtualization option that you probably need to switch on in the bios settings. It is disabled by default on all notebooks and desktop machines I have seen.

The host OS does not have to be a 64bit version in order to run a 64bit guest OS!

5 Virtualization for Developers 1. Creating a New Virtual Machine

Specify Name, Location and Number of Processors

Slide 6

You can have a maximum of two processors (cores) available in the virtual machine. This processors (cores) must be provided by the host.

6 Virtualization for Developers 1. Creating a New Virtual Machine

Set Memory Requirements and Network Type

Slide 7

Memory The VMs are consuming physical memory of the host systems. This leads to a simple rule: you cannot have to much memory in your physical machine, when you work with VMs. This is especially true when working with production mode VMs on a server. VMware supports swapping of currently unused memory between VMs,which helps you to squeeze in more concurrent VMs on you host –at the cost of a performance penalty. See Edit, Preferences, Memory.

Network Type We will get to the network types and what they mean later on.

7 Virtualization for Developers 1. Creating a New Virtual Machine

Let’s Talk About the Virtual Disk

Slide 8

Follow the recommendations for the I/O adapter and disk type (next slide) unless you know what you are doing and have read about your options in the manual. VMware will recommend different settings depending on the guest OS you have chosen before.

There are more slides about virtual disks later on.

8 Virtualization for Developers 1. Creating a New Virtual Machine

Let’s Talk About the Virtual Disk

Slide 9

Disk Capacity Start your VMware tests with growing disks. That will save you alot of space on your host. And don’t be to shy with their initial size. Although there are ways to grow a fixed size disk later on, it involves partition managers and is a tedious task. There is no practical reason to start them to small.

9 Virtualization for Developers 1. Creating a New Virtual Machine

Let’s Talk About the Virtual Disk

Slide 10

You can put the new virtual disk in a separate folder on the host . There is a scenario for this: Using a virtual disk for data thatis shared by several virtual machines (which cannot concurrently use the disk). It isa good practice to store these shared disks in a separate folder structure. Most likely, you will create this virtual disks with the Add Hardware Wizzard from the Virtual Machine Settings.

10 Virtualization for Developers 1. Creating a New Virtual Machine

Add more Virtual Hardware

n Add Hardware Wizzard from VM Settings if you need more virtual hardware from the start

n You need to connect the virtual CD-ROM with the ISO image of the guest OS installation

Slide 11

After the machine has been created, you can immediately start it. Even without a CD-ROM. It will behave like a new computer without an OS installed and with no CD-ROM inserted. Take a look at the settings of the virtual BIOS. To enter the virtual BIOS, click into the starting machine and press . You need to be quick.

The screen shot shows a new virtual CD-ROM drive which is connected to an ISO image. The image contains CD1 of the Windows 2003 Server installation set which is used in the following screens.

11 Virtualization for Developers 1. Creating a New Virtual Machine

Install the Guest OS

Slide 12

The virtual machine boots from the ISO image on the hosts file system!

12 Virtualization for Developers 1. Creating a New Virtual Machine

Install the Guest OS

Slide 13

The virtual machine reboots during the installation process justlike a physical machine.

13 Virtualization for Developers 1. Creating a New Virtual Machine

Install the Guest OS

Slide 14

During installation you might need to insert a new CD. To do so,switch to Summary View, double-click on the CD-ROM device and change the ISO image.

14 Virtualization for Developers 1. Creating a New Virtual Machine

Install the Guest OS

Slide 15

With a bridged network of the virtual machine, it will be able to share your network resources (DHCP, internet access) from the start. So your installation may include the initial Windows update.

15 Virtualization for Developers 1. Creating a New Virtual Machine

Install the VMware Tools in the Virtual Machine

Slide 16

Select VM, Install VMware Tools … from the menu. It will provide a virtual CD-ROM drive to the virtual machine with the VMware Tools setup programon it and automatically start the installation process.

16 Virtualization for Developers 1. Creating a New Virtual Machine

VMware Tools

n Optimized display driver à faster, enables guest screen autofit to VMware window

n Optimized network driver à up to 1Gbit depending on the host adapter

n Automatic date & time sync with the host

n Shared folders support

n Scripting support for VM events e.g. retrieve new IP address from DHCP after being suspended and resumed

n Shrinking of virtual hard disks

Slide 17

17 Virtualization for Developers 1. Creating a New Virtual Machine

Create the First Snapshot to Secure Your Work

Slide 18

18 Virtualization for Developers 1. Creating a New Virtual Machine

Windows Activation

Slide 19

19 Virtualization for Developers 1. Creating a New Virtual Machine

Windows Activation n Retail keys from MSDN subscriptions allow a limited number of activations n Volume license keys VA 1.0 from MSDN subscriptions allow unlimited activations for Windows XP n Volume license keys VA 2.0 MAK allow for a limited number of activations n Must read paper available on MSDN: Microsoft’s Software Protection Platform: Planning Activation in Software Development Environments n The full story (47 pages!) on MSDN: Volume Activation 2.0 Step-By-Step Guide n Retail and volume license versions have different installation images! n Rumor has it that there are MAK killers on the internet

Slide 20

20 Virtualization for Developers 1. Creating a New Virtual Machine

Windows Activation

n You will have to reactivate your Windows each time you make significant changes to the hardware of the virtual machine

n VMware warns you about this fact and recommends to postpone Windows activation until you have finalized your machine configuration

n The warning appears whenever you start the new machine until you suppress the tip

Slide 21

21 Virtualization for Developers 1. Creating a New Virtual Machine

Sharing Files with the Rest of the World

n Internet, FTP etc.

n NET USE (network shares)

n Shared Folders

n Mount virtual disks from the host (only when the virtual machine is down)

Slide 22

To mount a virtual disk on the host, select File, Map or Disconnect Virtual Disks…

22 Virtualization for Developers 1. Creating a New Virtual Machine

Shared Folders Definition in VMware

Slide 23

You enable Shared Folders from the Options tab of the Virtual Machine Settings. Shared Folders are folders on the file system of the host OS that are accessible from within the virtual machine. They can either be read only orread/write from the virtual machines perspective.

23 Virtualization for Developers 1. Creating a New Virtual Machine

Shared Folders Access in the Virtual Machine

Slide 24

You find the shared folders on the virtual machine in the Windows Explorer under My Network Places, VMware Shared Folders, .host, Shared Folders. You might want to assign a permanent drive letter to this share.

24 Virtualization for Developers 1. Creating a New Virtual Machine

The Files of the Virtual Machine on the Host Filesystem

Slide 25

File Types

•log Keeps a log of key VMware Workstation activity. This file is useful in troubleshooting. •nvram State for the virtual machine’s BIOS. • Virtual disk file, which stores the contents of the virtual machine’s . In case the virtual HD is connected to a partition, it points to this partition. There may be several hard disk files when snapshots are used in the virtual machine. •vmsd and vmsn Snapshot mangagement •vmx The primary configuration file, which stores settings chosen in the New Virtual Machine wizard or virtual machine settings editor. It’s an XML file.

25 Virtualization for Developers 1. Creating a New Virtual Machine

Take Some Notes and Suspend your Machine

Slide 26

26 Virtualization for Developers 2. More Machines

Download Appliances

n Source: www.vwmare.com

n Example: Ubuntu Linux Appliance

n More appliances available

Slide 27

27 Virtualization for Developers 2. More Machines

Copy a Machine

n Copy the files of a newly created machine à create new internal id (I copied it)

Slide 28

With MS Virtual PC, this is the only way to copy a machine.

28 Virtualization for Developers 2. More Machines

Clone a Machine

n Use VM, Clone…to clone an existing machine

n Full or linked clone

n Make sure the base machine is available when you copy or move linked clones

n Use linked clones to distribute machines to other team members

Slide 29

29 Virtualization for Developers 2. More Machines

Clone a Machine à Example of a linked clone

Slide 30

30 Virtualization for Developers 2. More Machines

The “2”s

n P2V Convert a physical machine to a virtual

n V2V Convert an existing virtual machine to a new one (including disk images like Norton , Acronis et. al.)

Slide 31

31 Virtualization for Developers 2. More Machines

Be organized from the start

Slide 32

Use a folder structure which clearly separates ISO images, machines in production mode, test machines, template machines (to be cloned) and the root folder for Shared Folders.

32 Virtualization for Developers 3. Basics

Virtual Machines on the Desktop

Slide 33

33 Virtualization for Developers 3. Basics

Virtualization Emulation à real hardware is dedicated (at a time) à Hardware is emulated by the to the VMs virtualization layer

n CPU n Disks

n Memory n Network

n CDs and USB devices n Grafics

n Sound à Virtual machines show the very à Virtual machines always show processor of the host standard hardware

Slide 34

CPU Note that the CPU is virtualized, not emulated. This means that you cannot emulate a slow, older PC. With the emulated hardware, you can dothis kind of test. VMware 6 teams, for example, have a feature to emulate slow networks with high error rates.

USB Most USB devices attached to the host are detected by the VM when the VM has focus at the time the device is connected! In our tests, even anHBCI banking card in an USB card reader worked.

Check out the hardware manager in your virtual machine.

34 Virtualization for Developers 3. Basics

Virtual Machines in the Datacenter

Does anyone remember VM/sp on IBM 3270 ?

Slide 35

35 Virtualization for Developers 3. Basics

Transparent Paravirtualization à Virtual Machine Interface (VMI) àOS knows it is running in a virtual machine àTechnology in development Currently only a modified Linux kernel available

Slide 36

One of the goals of transparent paravirtualization is to allow asingle binary version of the to run either on native hardwareor on a in paravirtualized mode. This means that support for paravirtualization interfaces is compiled into the kernel, and is present even whenthe kernel is running on native hardware.

36 Virtualization for Developers 4. Market Overview

Leading Players

n VMware à Market leader à Belongs to EMC (storage systems) à Most comprehensive suite of products on the market à Attacks Citrix with his VMware Virtual Desktop Infrastructure (VDI)

n Microsoft à Royalty-free products Virtual PC 2007 und Virtual Server 2005 R2 SP1 à System Center Virtual Machine Manager à lags behind for at least one generation

n XEN à Linux based Open Source solution à Acquired by Citrix

Slide 37

37 Virtualization for Developers 4. Market Overview

VMware Products

n VMware Workstation 6.0 à Best product for developers à $189,00 per licence

n VMware Player à Freeware player for VMs with very limited capabilities (no creation of machines, no snapshots etc.)

n VMware Server à Free entry product for server virtualization

n VMware Converter à Free P2V, V2V tool

Slide 38

38 Virtualization for Developers 4. Market Overview

VMware Products n VMware Infrastructure 3.5 à Comprehensive suite of products for data center virtualization à Formerly known as VMware ESX Server n VMware Lab Manager à Build on top of VMware Infrastructure à Management of related machine teams for complex testing scenarios and training classes n VMware Virtual Desktop Infrastructure (VDI) à Management of virtual desktops from a server à Clients only need a thin client n VMware ACE à Management of secured virtual machines in the field

Slide 39

There is a growing market of 3rd-party add-ons for VMware infrastructure including tools that allow an easy full backup of running VMs or even replicating running VMs to a different location.

39 Virtualization for Developers 5. Scenarios for Developers

Development n Multiple OS versions for testing purposes (Windows 2000, XP, Vista etc.) n Multiple OS language versions for testing purposes (and for non-English developers: lookup of English termini tecnici) n Snapshots for multiple environments and fast re-setup of an environment n Smooth transition to a new development machine (P2V: take old developer machines with you as a virtual machine) n Compile into a virtual machine and debug there directly from Visual Studio

Slide 40

40 Virtualization for Developers 5. Scenarios for Developers

Support & QA n Multiple OS versions for testing purposes (Windows 2000, XP, Vista etc.) n Multiple OS language versions for testing purposes n Complex test scenarios in virtual networks n Receive an image from a machine which causes problems (P2V) n Debug in a virtual machine from Visual Studio n Separated VPN clients in virtual machines

Slide 41

41 Virtualization for Developers 5. Scenarios for Developers

Example: VPN Client in a Virtual Machine

Slide 42

42 Virtualization for Developers 6. Virtual Disks

Types

n Virtual Growing

n Virtual Fixed

n Partition

n Persistent

Slide 43

43 Virtualization for Developers 7. Virtual Networks

Based on Virtual Network Adapters àPart of the virtual machine à Emulated by the Virtualization Layer or Hypervisor

Network Types

n Host-Only Private Network between guest and host

n Bridged VM is connected to the host’s network adapter and gets its own IP-address in the host’s network (fixed or DHCP)

n NAT (Network Address Translation) VM uses the same IP-address as the host

Slide 44

The full functionality of virtual networks in VMware Workstation6 is beyond the scope of this presentation. Please see the manual for an overview of all the options.

44 Virtualization for Developers 7. Virtual Networks

Database Mirroring Example, Network Overview

SWBack Client2 192.168.202.130 192.168.202.129

192.168.202.0/24 VMNet5

NIC1 192.168.202.132 Default GW

SWRouter

NIC2 192.168.201.132 Default GW

192.168.201.0/24 VMNet4

Client1 SWMain SWSQLArbiter 192.168.201.129 192.168.201.128 192.168.201.130

Schoeller Werk GmbH & CO. KG Projekt : VMWare Konstrukt 1 Im Kirschseiffen Stand : 18.12.2007 Guido Schmitz Schematische Darstellung 53940 Hellenthal

Slide 45

The sample shows a pretty advanced usage of VMware Workstation in a database test scenario.

What you see on the overview is a scenario with 6 virtual machines used to test database mirroring. SWMain is the main database server, SWBack is the backup server. SWMain sends all database changes to SWBackup immediately. If SWMain should go down, SWArbiter will detect the problem and tell SWBack to jump in and become the primary server. The client machines Client1 and Client 2 are used to test the database connections. To make things a little bit more interesting, SWBack is in another building and therefore on a different network segment. SWRouter is an XP machine that emulates a router.

You do not need a full Windows Server machine to test routing. Any Windows XP machine can be told to act as a router by setting this registry key: HKEY_LOCAL_MACHINE \SYSTEM\CurrentControlSet\Services\Tcpip \Parameters\IPEnableRouter = 1

45 Virtualization for Developers 7. Virtual Networks

Database Mirroring Example, Team Setup

Slide 46

In VMware Workstation, you can define “teams”of virtual machines and virtual network segments. The screenshot shows a simple team consisting of three virtual machines SWMain, SWRouter and Client 2 and two network segments.The machines and the segments correspond to the previous slide. Notethat SWRouter has two network adapters and is connected to both segments.

46 Virtualization for Developers 7. Virtual Networks

Database Mirroring Example, Ping of SWMain from Client 2

Slide 47

The screenshot shows the team dashboard of VMware Workstation. From the thumbnail display of the team members, the screen of Client 2 isselected. Client 2 in segment Net5 just successfully pinged SWMain in segment Net4!

47 Virtualization for Developers 8. P2V and V2V

P2V Physical to Virtual àConverts a (maybe even running) phyiscal machine into a virtual machine V2V àConverts one virtual machine into another Scenarios

n Take a copy of a customer machine with you to investigate problems (P2V)

n Convert a Norton Ghost image backup into a virtual machine

n Safe an old NT4 server running for years (with “singing”hard disks) into a virtual machine while it is running before you switch it off beause it might never start again

Slide 48

P2V P2V can either be Hot Cloning (running machine) or Cold Cloning (with a bootable CD). The free version of VMware Converter only offers Hot Cloning. Cold Cloning is included in the Enterprise version which is included in the VMware Infrastructure product.

There are a lot of other tools on the market for P2V and V2V: * Platespin PowerConvert * Ultimate P2V (www.rtfm-ed.co.uk) (kostenlos) * Invirtus * HP Server Migration Pack and others

48 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

Steps:

n Put your images on a local or network drive, preferably not on the same drive you will create your virtual machine on

n Run the Import Wizzard or use VMware Converter to repeatedly execute a P2V or V2V scenario

n Deal with Windows product reactivation issues and boot problems

Slide 49

VMware Converter is a free download from www.vmware.com

The screenshot shows the files of the Norton Ghost image. The file with the sv2i extension is the one to pick.

49 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

Select the Source

Slide 50

As you can see, the Import Wizzard can be used for both P2V and V2V tasks.

50 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

Select the Source

Slide 51

51 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

Select the Source

Slide 52

52 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

Select the Destination

Slide 53

53 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

Select the Destination

Slide 54

54 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

Set the Network Options of the New Machine

Slide 55

55 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

Customization of the New Machine with Sysprep

Slide 56

Sysprep You can customize the destination virtual machine with Sysprep. Sysprep is a tool from Microsoft that has been available for many years now. It ismainly used by hardware vendors and administrators that need to install Windowsoperating systems on a huge number of similar machines. Its functionality is beyond the scope of this presentation. Only choose the Customize the identity of the new machine option if you understand the mechanisms of Sysprep and have a set of Sysprep files prepared for your new virtual machine. You do not need this option to follow our scenario of converting a Ghost image of your old physical machine into a virtual machine.

56 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

Import Completed

n You can now power on the new virtual machine

Slide 57

57 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

SCSI Warning

n Appears the first time you power on the new machine

n Can be safely ignored if the old machine didn’t use a SCSI hard drive

n Disable unused SCSI adapters in the virtual machine later to suppress the warning

Slide 58

58 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

VMware Tools Warning

n Appears the first time you power on the new machine

n Just to remind you to not forget the VMware Tools installation in the new machine

Slide 59

59 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

Problem: Windows Activation

n Even before you log in to the virtual machine, the guest Windows will complain that it needs to be reactivated

n It’s because the Windows in the virtual machine is now running on a different hardware (the virtual one) than it had on the old machine

Slide 60

60 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

Problem: Windows Activation

n You can reactivate your copy of Windows

n The real Problem appears when your old machine had an OEM version of Windows installed à you will not be able to reactivate Windows –even not with the original product key – because the OEM version is bound to the old physical hardware

Slide 61

61 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

Tip: Bypass Windows Reactivation of an OEM Version

n Map the hard disk of the virtual machine to a host drive

n Copy a WPA killer to the virtual machine

n Press during the boot sequence of the virtual machine and boot Windows in safe mode

n Call the WPA killer in safe mode à the reactivation complaint of Windows is gone

Slide 62

Please respect copyright issues and only apply this procedure only if neither you nor anybody else is still using the original copy of windows.

62 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

Tip: Fix boot problems

n Machine might still be unusable because it crashed during the boot sequence or after log on

n Due to particular hardware in the old physical machine missing that cannot be emulated

n Again: boot Windows in safe mode and call MSCONFIG.EXE to disable all unnecessary services and autostart applications

Slide 63

The screenshot shows how I disabled all TOSHIBA notebook relatedapplications and drivers from the system start section of Windows. This applications communicate with special keys and the touchpad of my old notebook. This solved my boot problem. When the virtual machine properly starts afterwards, you can uninstall this applications.

63 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

The Reward: a Running Virtual Copy of my Old Notebook

Slide 64

The screenshot shows a table from a MS SQL Server 2000 instance on my old notebook.

64 Virtualization for Developers 8. V2V Example: Converting a Norton Ghost Image to a VM

Tip: Access the Disks of the Imported Machine from the Host

n File, Map or Disconnect Virtual Disks

n Map disks of the new virtual machine to drives of the host

n You then do not need Norton Ghost to be installed in order to access files from the old image

Slide 65

65 Virtualization for Developers Questions ?

Slide 66

66 Thank you for your time!

Consulting & Software Development

Martinstrasse 1 44137 Dortmund Germany

www.appfact.de [email protected]

67