none
Hyper-V Backup, Defrag, Checkdisk

    Question

  •  Ok,  my company provides regular maintenance for our customers and we are starting to roll out windows 2008 with Hyper-V and 2008 virtual machines.  In doing this support we have come up with several questions regarding Backup options Defragmentation and Checkdisk...

    1.  Checkdisk and Defragmentation:  Should either of these be run in the virtual machine? Is it Ok to run these on the Windows 2008 Hyper-V server that hosts the virtual machine (will it corrupt the virtual machine)?

    2.  Backup of Virtual Machines:  This can be very confusing, but I understand that the best way to get a full backup of the Virtual machine is to stop the machine and do an export.  Is a snapshot essentially the same as the system state backup in 2003?  If so In the case of a restore of a virtual machine would I import the exported machine and then restore the latest snapshot?

    I know this a loaded request for information, but the searches I've done haven't asked, nor answered these questions concisely.  Thank you in advance for input you might be able to offer

    Tuesday, January 27, 2009 5:25 PM

Answers

  • duperdogme said:

    1.  Checkdisk and Defragmentation:  Should either of these be run in the virtual machine? Is it Ok to run these on the Windows 2008 Hyper-V server that hosts the virtual machine (will it corrupt the virtual machine)?

    I don't run chkdsk on virtual machines. It's a best practice for quick format drives inside a virtual machine. Quick format skips the chkdsk of a full format. If there's no need for chkdsk then, I don't see the need for it later. chkdsk is looking for bad sectors on the physical disk. The virtualization product should abstract away those problems.

    Defragment in the virtual machine if you aren't using differencing disks.

    Differencing disks are an interesting case. Any and all changes you make in the vm are reflected in the vhd. That's why you should defragment inside the running vm before creating a differencing disk. Defragment after creating the differencing disk and you'll bloat the differencing disk.

    Defragment the physical machine. It won't harm the virtual machines. It is particularly helpful if you have dynamically expanding or differencing vhds because they tend to fragment quite a bit.

    2.  Backup of Virtual Machines:  This can be very confusing, but I understand that the best way to get a full backup of the Virtual machine is to stop the machine and do an export.  Is a snapshot essentially the same as the system state backup in 2003?  If so In the case of a restore of a virtual machine would I import the exported machine and then restore the latest snapshot?

    Never, ever rely on snapshots as a backup mechanism. Don't even think of them that way. What they are particularly well suited for is trying out a change and either making it permanent or rolling it back. While that may sound like a backup, it's for a different purpose.

    You don't have to stop the virtual machine to get a complete and valid backup. Hyper-V is VSS aware. This is copied from the Community Content section of TechNet (http://technet.microsoft.com/en-us/library/cc794762.aspx):

     

    Taylor Brown's blog post explains away some of the confusion around backup/snapshot in Hyper-V: http://blogs.msdn.com/taylorb/archive/2008/08/20/backing-up-hyper-v-virtual-machines-using-windows-server-backup.aspx

    See also:

    How to enable Windows Server Backup support for the Hyper-V VSS Writer : http://blogs.technet.com/askcore/archive/2008/08/20/how-to-enable-windows-server-backup-support-for-the-hyper-v-vss-writer.aspx

    Windows Serever 2008 Backup and Recovery Overview : http://technet.microsoft.com/library/cc770593.aspx

    Windows Server Backup Step-by-Step Guide for Windows Server 2008 : http://technet.microsoft.com/en-us/library/cc770266.aspx

    Microsoft Data Protection Manager trial: http://technet.microsoft.com/dpm/bb727240.aspx

     

     

     

     

     

     

    Wednesday, January 28, 2009 4:21 AM
    Moderator
  • In regards to running checkdisk - ther are two reasons (generally speaking) for doing this.  One is to detect structural corruption to the file system that might be resultant from unexpected power outages / etc...  The other reason is to detect corruption that is a result of hardware failure.

    Now - if you have suffered unplanned power outages (or other environmental activity that might effect the software) you are best to run chkdsk in both the virtual machine and the parent partition - as neither can attest to the reliability of the file structures in the other.  I.E. You could run checkdisk in the parent partition and have it say that every thing is "hunky dory" but the contents of the VHD have been completely scrambled.

    On the other hand - if you are worried about hardware failure you only need to run check disk in one environment.  Here it is preferable to run check disk in the parent environment - but in the case where you are not admin on the physical box you can still run check disk in the virtual machine - which will let you know if there are hardware problems for the extent of the physical disk that the virtual disk maps to.


    Cheers,
    Benjamin Armstrong
    ============================
    Windows Virtualization
    Senior Lead Program Manager

    This posting is provided AS IS with no warranties, and confers no rights. You assume all risk for your use.
    Wednesday, January 28, 2009 11:10 PM
    Owner

All replies

  • duperdogme said:

    1.  Checkdisk and Defragmentation:  Should either of these be run in the virtual machine? Is it Ok to run these on the Windows 2008 Hyper-V server that hosts the virtual machine (will it corrupt the virtual machine)?

    I don't run chkdsk on virtual machines. It's a best practice for quick format drives inside a virtual machine. Quick format skips the chkdsk of a full format. If there's no need for chkdsk then, I don't see the need for it later. chkdsk is looking for bad sectors on the physical disk. The virtualization product should abstract away those problems.

    Defragment in the virtual machine if you aren't using differencing disks.

    Differencing disks are an interesting case. Any and all changes you make in the vm are reflected in the vhd. That's why you should defragment inside the running vm before creating a differencing disk. Defragment after creating the differencing disk and you'll bloat the differencing disk.

    Defragment the physical machine. It won't harm the virtual machines. It is particularly helpful if you have dynamically expanding or differencing vhds because they tend to fragment quite a bit.

    2.  Backup of Virtual Machines:  This can be very confusing, but I understand that the best way to get a full backup of the Virtual machine is to stop the machine and do an export.  Is a snapshot essentially the same as the system state backup in 2003?  If so In the case of a restore of a virtual machine would I import the exported machine and then restore the latest snapshot?

    Never, ever rely on snapshots as a backup mechanism. Don't even think of them that way. What they are particularly well suited for is trying out a change and either making it permanent or rolling it back. While that may sound like a backup, it's for a different purpose.

    You don't have to stop the virtual machine to get a complete and valid backup. Hyper-V is VSS aware. This is copied from the Community Content section of TechNet (http://technet.microsoft.com/en-us/library/cc794762.aspx):

     

    Taylor Brown's blog post explains away some of the confusion around backup/snapshot in Hyper-V: http://blogs.msdn.com/taylorb/archive/2008/08/20/backing-up-hyper-v-virtual-machines-using-windows-server-backup.aspx

    See also:

    How to enable Windows Server Backup support for the Hyper-V VSS Writer : http://blogs.technet.com/askcore/archive/2008/08/20/how-to-enable-windows-server-backup-support-for-the-hyper-v-vss-writer.aspx

    Windows Serever 2008 Backup and Recovery Overview : http://technet.microsoft.com/library/cc770593.aspx

    Windows Server Backup Step-by-Step Guide for Windows Server 2008 : http://technet.microsoft.com/en-us/library/cc770266.aspx

    Microsoft Data Protection Manager trial: http://technet.microsoft.com/dpm/bb727240.aspx

     

     

     

     

     

     

    Wednesday, January 28, 2009 4:21 AM
    Moderator
  • John Paul Cook said:

    I don't run chkdsk on virtual machines. It's a best practice for quick format drives inside a virtual machine. Quick format skips the chkdsk of a full format. If there's no need for chkdsk then, I don't see the need for it later. chkdsk is looking for bad sectors on the physical disk. The virtualization product should abstract away those problems


    Yesterday I created two differential vhd's and during the first boot Windows did a quick (not full surface) chkdsk of those vhd's. Not sure why but I let it run and both times there were messages that there were some inconsistensies that were fixed (Cleaning Up Index Entries and that kinda stuff).

    Wednesday, January 28, 2009 9:24 AM
  • Roel Janssens said:

    Yesterday I created two differential vhd's and during the first boot Windows did a quick (not full surface) chkdsk of those vhd's. Not sure why but I let it run and both times there were messages that there were some inconsistensies that were fixed (Cleaning Up Index Entries and that kinda stuff).



    Interesting. I didn't mean to imply that there can't be problems with vhds. Here's Ben's post on vhd errors: http://blogs.msdn.com/virtual_pc_guy/archive/2009/01/07/how-do-i-fix-a-corrupted-virtual-hard-disk.aspx

    Wednesday, January 28, 2009 12:45 PM
    Moderator
  • In regards to running checkdisk - ther are two reasons (generally speaking) for doing this.  One is to detect structural corruption to the file system that might be resultant from unexpected power outages / etc...  The other reason is to detect corruption that is a result of hardware failure.

    Now - if you have suffered unplanned power outages (or other environmental activity that might effect the software) you are best to run chkdsk in both the virtual machine and the parent partition - as neither can attest to the reliability of the file structures in the other.  I.E. You could run checkdisk in the parent partition and have it say that every thing is "hunky dory" but the contents of the VHD have been completely scrambled.

    On the other hand - if you are worried about hardware failure you only need to run check disk in one environment.  Here it is preferable to run check disk in the parent environment - but in the case where you are not admin on the physical box you can still run check disk in the virtual machine - which will let you know if there are hardware problems for the extent of the physical disk that the virtual disk maps to.


    Cheers,
    Benjamin Armstrong
    ============================
    Windows Virtualization
    Senior Lead Program Manager

    This posting is provided AS IS with no warranties, and confers no rights. You assume all risk for your use.
    Wednesday, January 28, 2009 11:10 PM
    Owner
  • Thank you.  That is about as concise as it could get :).  One further question on the Backup side.  Windows Server Backup (2008) does not do just system state backups from the GUI, but does from the command line using the instructions listed below (found in the online help).  Would a good way to backup and subsequently restore the OS be to do an Export of virtual machine, then system states on a regular basis.  If a restore was needed, I would import the "exported"  backup and then restore the most recent system state?

    To create a system state backup by using a command line

    1. To open a command prompt with elevated privileges, click Start, right-click Command Prompt, and then click Run as administrator.
    2. At the prompt, type: wbadmin start systemstatebackup -backupTarget:<VolumeName> [-quiet]

    For example, to create a system state backup and save it to volume F, type: wbadmin start systemstatebackup -backupTarget:F:

     

    Thursday, January 29, 2009 5:59 PM
  • Ben Armstrong [MSFT] said:

    In regards to running checkdisk - ther are two reasons (generally speaking) for doing this.  One is to detect structural corruption to the file system that might be resultant from unexpected power outages / etc...  The other reason is to detect corruption that is a result of hardware failure.

    Now - if you have suffered unplanned power outages (or other environmental activity that might effect the software) you are best to run chkdsk in both the virtual machine and the parent partition - as neither can attest to the reliability of the file structures in the other.  I.E. You could run checkdisk in the parent partition and have it say that every thing is "hunky dory" but the contents of the VHD have been completely scrambled.

    On the other hand - if you are worried about hardware failure you only need to run check disk in one environment.  Here it is preferable to run check disk in the parent environment - but in the case where you are not admin on the physical box you can still run check disk in the virtual machine - which will let you know if there are hardware problems for the extent of the physical disk that the virtual disk maps to.


    Our goal is primarily preventive maintenance and to detect issues before they become "real issues"  Given the checkdisk options.  It seems to me that on the parent environment I would want to choose the "automatically fix File system errors" and the "Scan for and Attempt recovery of Bad sectors" options.   On the Virtual machine it would seem that just the "automatically fix File system errors" would be appropriate.  Does this sound correct?
    Thursday, January 29, 2009 6:04 PM
  • Are we talking snapshots when we say "differencing disks"?  I'm confused.
    Monday, October 05, 2009 11:24 PM
  • I’m the Product Manager for Diskeeper Corporation, and take great interest in storage-related discussions as a result. I wanted to supplement a note from MVP John Paul Cook above in his post, where he states:

    Defragment the physical machine. It won't harm the virtual machines. It is particularly helpful if you have dynamically expanding or differencing vhds because they tend to fragment quite a bit.


    While I agree with this completely, there are some caveats. In Windows Server 2008R2 for Hyper-V we see the introduction of CSVs ( Cluster Shared Volumes ) for virtual disks. It is significant to this thread that a command to perform a snapshot or to defragment which is sent to a CSV volume will trigger a state switch on that CSV from Direct Access to Redirected Access; all I/O is now being funneled through a single coordinator node. This state can obviously cause bottlenecks on production resources. ( Additionally, CHKDSK will prompt a state switch to Maintenance Mode which poses an even greater potential handicap to production resources )

    Because Direct Access Mode is so beneficial, after-the-fact defragmentation ( manual or automatic, both prevalent in the market today ) could reduce optimization and effectively limit resources on CSVs. It’s important to bear that in mind when considering defragmentation / CHKDSK for this particular environment. We talk about this a bit more here: http://www.diskeeper.com/blog/post/2011/03/28/Best-Practices-for-CSV-defrag-in-Hyper-V-(Windows-Server-2008R2).aspx
    Wednesday, May 25, 2011 10:40 PM
  • I would recommend that you run a full fledged chkdsk /r on the disk in case corruption is found.

    We can find corruption by running chkdsk <drive_letter> or check id the dirty bit is set using the command fsutil dirty query <drive_letter>.

    In case corruption is detected, I would recommend running a chkdsk /r. Why i would recommend this is simple, if chkdsk finds some files in lost clusters, it would attempt to recover them and would put them in a folder titled found.xxx where xxx=001,002 etc.

     

    To backup the virtual machine, i would recommend that you use the normal Windows Server Backup utility and take a complete backup. If you have an older version of Server 2008 (SP1), you may need to register the Hyper-V VSS writer by the format described above.

     

    Regards

    Anirudh G

    Friday, May 27, 2011 5:09 PM