SSW Rules/Infrastructure and Networking/Rules to Better Hyper-V

 Rules to Better Hyper-V

Hold on a second! How would you like to view this content?
Just the title! | A brief blurb! | Gimme everything!
  1. Do you use Fixed Disks?

    When SysAdmins first get going with Hyper-V, they often choose to use dynamically expanding VHD’s. They often do this to increate VHD creation time and reduce hard disk usage.

    The problem with dynamically expanding VHD’s is that they reduce the performance of the Virtual Machine. It is much better to use a fixed VHD when the Virtual Machine is used in a production environment.
  2. Do you use Basic Volumes inside VHD's?

    When formatting a new virtual disk you have attached to a Hyper-V Virtual Machine, you can choose to to format the disk as a Basic disk or Dynamic disk.

    A Dynamic disk might be useful in situations where you want to create a software RAID array, but when using Hyper-V this not a good idea because it prevents Microsoft Data Protection Manager (DPM) from doing Child State Backups (backups while the machine is running).

    For this reason, never use Dynamic disks inside Hyper-V Virtual Machines.

    Bad Example - DPM cannot backup this Virtual Machine's child state as it has a Dynamic Disk
    Figure: Bad Example - DPM cannot backup this Virtual Machine's child state as it has a Dynamic Disk

    Good example – Using Basic Volumes allows DPM to backup the Virtual Machine’s child state
    Good example – Using Basic Volumes allows DPM to backup the Virtual Machine’s child state
  3. Do you know how to expand your VHD's when you are low on space?

    Occasionally when you estimate the size of a VHD that you will be using in a server, you can get it wrong and you will need to give the Virtual Machine some more space. Instead of adding a bigger data disk in the Virtual Machine and migrating data, you can expand the existing disk.
    1. Open the Hyper-V Manager on the server hosting the Virtual Machine
    2. Shutdown the virtual machine
    3. Click Edit Disk... in the Actions pane of the Hyper-V Manager
      You expand a VHD from the Actions Menu | Edit Disk
      Figure: You expand a VHD from the Actions Menu | Edit Disk
    4. In the Edit Virtual Hard Disk Wizard window, choose the VHD you want to edit and choose Next.
    5. Select Expand and click Next
    6. Enter the new size of the VHD and click Next

    You will now have a resized VHD. Next step is to boot up into the virtual machine and tell disk manager to resize the partition on the VHD to use the free space which has been added at the end of the VHD. Windows Server 2008 makes this very simple:

    1. Boot into the virtual machine
    2. Open Computer Management and choose Disk Management
    3. Right click on the partition sitting at the front of the newly resized disk and click on Extend Volume...
      The first partition on the disk needs to be expanded to use up the unallocated space created when expanding the VHD
      Figure: The first partition on the disk needs to be expanded to use up the unallocated space created when expanding the VHD
    4. You will have to use all the available space when you extend the volume as it is a Simple Volume. (See Rule: Do you use Basic Volumes inside VHD’s? ) When you are asked to select your disks just click Next
    5. Click Finish
      The disk is now using all the available space inside the VHD
      Figure: The disk is now using all the available space inside the VHD
  4. Do you name your Virtual Machines with a standadized naming convention?

    When your Hyper-V environment is spread across multiple hosts and contains many Virtual Servers, it can get very confusing to find the one you are looking for amongst them all. This is why you should use a standard naming convention for all your Virtual machines.
    How do you know what machine is what?
    Bad Example - How do you know what machine is what?The standard we use for Production Virtual Machine naming is as follows:

        NetBIOSName-ServiceName

        
    For example: Falcon-SCVMM

    The standard we use for Development Virtual Machine naming is as follows:

        DEV-NetBIOSName-ServiceName-DeveloperInitials

        For example: DEV-demo2010a-SP2010MSInfoWorker-JL

    It is easy to tell which VM is which when they are named to a standard
    Good Example - It is easy to tell which VM is which when they are named to a standard
  5. Do you export a Virtual Machine if you need to move it?

    If you need to move a virtual machine from one Hyper-V server to another, you should using the Hyper-V Managers export option rather than just moving the VHD files.

    If your machine has snapshots and you copy them rather than export them, it can cause issues with the VHD’s and AVHD’s (Snapshot VHD’s) because Hyper-V does not know there has been a snapshot when you load it onto the new Hyper-V Host. You also lose the settings for your Network Adapter, like its static IP address.

    To export a Virtual Machine from the Hyper-V Manager:
    1. Right click on it when it is shut down and clicking Export...
    2. Choose the location you wish to export the Virtual Machine to and click on Export
  6. Do you shut down a Virtual Machine before running a snapshot?

    Snapshots are a very convent way to back up a system before a big change is made. It is important to note that Microsoft does not support snapshots of running systems. This is because a snapshot is taken of the system exactly as is, with open connections and interrupt requests. For more information on this you can read Brian Harry’s blog post here: http://blogs.msdn.com/bharry/archive/2010/02/10/a-tfs-2010-upgrade-success-story.aspx

    This is why you MUST shut down your server before taking a snapshot.

    1. Shutdown the virtual server
    2. In the Hyper-V Manager, ensure the Virtual Machine has the state of Off
    3. Right click on the virtual machine you wish to snapshot and click Snapshot
    4. The snapshot should run very quickly and you will notice the snapshot in the Snapshots area of the Hyper-V Manager

      You will see the snapshots associated with a Virtual Machine when you click on them
    5. You will see the snapshots associated with a Virtual Machine when you click on them

    6. You can start your server back up again
  7. Do you delete old snapshots before making a new one?

    Snapshots are a very handy tool for a System Administrator, but they can quickly turn into a nightmare if they are not managed properly. Snapshots take far more hard drive space than a virtual machine without, and if you don’t clean up your snapshots you may run out of drive space.
    Snapshots are useful, but they can take up a lot of space
    Figure: Snapshots are useful, but they can take up a lot of space

    When you delete a snapshot you can no longer restore the virtual machine to the point in time the snapshot was taken. Deleting a snapshot does not affect any other snapshots, nor will it affect the current state of the virtual machine.

    Set yourself a calendar reminder 3 weeks after you make a snapshot so you remember to apply the snapshot to the Virtual Machine (assuming you are happy with the virtual machine after the snapshot).

    1. In the Hyper-V Manager, click on the virtual machine you want to apply the snapshot to
    2. In the Snapshots window, right click on the snapshot you wish to apply and click Delete Snapshot…
    3. Confirm the snapshot deletion.
    4. Wait for the merge process to complete (this may take a while if you have had the snapshot running for a long time and it has grown large in size).
  8. Do you know how to decommission a Virtual Machine?

    It is important to properly decommission a Virtual Machine rather than just delete it. Developers have a knack for leaving important files everywhere, and inside a Virtual Machine is no exception.
    1. Let the people that may have been using the Virtual Machine that it is going to be decommissioned. This might be difficult if it was being used for testing or staging.
    2. Make a text file that matches the name of the Virtual Machine.
    3. Note down the Virtual Machines static IP address in the text file.
    4. Check the DNS Manager on a domain controller and note down any DNS names that pointed to the IP Address of the Virtual Machine.
    5. Copy the Virtual Machines folder to a file server or backup drive.
    6. Copy the text file into the same location.
    7. Set a calendar reminder for yourself to delete the Virtual Machine if it hasn’t been requested in 3 months.
......