1

I think my hard disk contains bad sectors and those bad sectors locate on the place where VM instance is, is there a tool that will allow me to fix those errors, or at least shift all the bad sectors from crucial point to the no so crucial place, so that I can do still boot up my VM machine?

Edit: One thing I am concerned is,since a VM file is typically very big, (a few GBs), that if a bad sector is located on a VM file ( no matter how small the bad sector is) , then the VM file is as good as dead? Is there anyway to save that poor VM instance?

3
  • why you think you have bad-sectors ?
    – user8228
    Sep 7, 2009 at 16:18
  • Because when I tried to copy the VM file to my another hard disk, I got a cannot copy error: Cyclic redundancy check error.
    – Graviton
    Sep 7, 2009 at 16:27
  • 1
    You must also be aware that some vital parts of the VM may be corrupt depending on which sectors have been corrupted. The MBR or filesystem could very well be destroyed. While it is unlikely, just be aware that it is possible. Sep 7, 2009 at 19:48

5 Answers 5

2

SpinRite might be able to help you out.

0

If the bad sectors correspond to unallocated sectors in your VM's virtual disk, you may be able to use a disk imaging program (e.g. Ghost, etc.) to clone the virtual disk into a second virtual disk. Locate the second virtual disk on a separate hard drive, so that you can replace the original drive.

A slightly more risky approach: "shrinking" the virtual disk and then making a "full clone" from within the VM software may have the same effect.

0

First, why would you want to entrust your VM to a disk that has developed bad sectors? Even if you could recover the bad sectors (I have heard of programs that supposedly do this), would you really feel confident they wouldn't go bad again - soon? New hard drvies are dirt cheap. 1TB for $80. Maybe less. Go get a new hard drive and use something that hasn't proven suspect. That said, if this is critical, why are you not using RAID? A RAID 1 mirror would help ensure you don't lose anything - and it costs an extra $80 (for that 1 TB drive and MAYBE an extra $50 for a controller, if your motherboard doesn't support it).

0

Run chkdsk c: /f /r

This will fix the filesystem, check for bad sectors and mark them as bad so that they are no longer used.

If these happen to be within the VM file then it will be corrupt. You may be able to fix the corruption by running the same command inside the VM. Otherwise you will need to recreate it/restore from backup.

If the VM no longer boots you may be able to attach the drive to another one that does boot and run chkdsk or some other recovery tools on it.

4
  • Are you saying that if a bad sector is located on a VM file ( it can be possible since a VM file is typically very big, a few GB), then the VM file is as good as dead?
    – Graviton
    Sep 7, 2009 at 14:46
  • @Ngu Soon Hui: It depends which sectors have been corrupted, and the actual VM hard-disk image format. Try it and see. Sep 7, 2009 at 19:49
  • FYI, the /f is redundant. chkdsk c: /r should be sufficient to check for bad blocks and fix filesystem errors.
    – rob
    Nov 9, 2009 at 18:48
  • while you are correct that /r implies /f in the current version, putting both is the official command and works in versions where /f was not implied. Also it makes it clearer to someone new to the command that both tasks will run.
    – JamesRyan
    Nov 10, 2009 at 10:47
0

You should probably assume the virtual hard disk is corrupt, and should not implicitly trust any data from it, even if you can make it bootable or recover your files.

Your best bet is to create a new virtual machine and restore your data from backups, assuming you were a good sysadmin. :)

If you don't have a known good backup, I'd suggest using dd_rescue to image the entire hard disk to at least one more hard drive, then trying some of the other recovery methods (such as chkdsk /r on the host machine). Once the virtual disk file can be copied, you can try to boot the copy and recover files. If it's not bootable, you can try attaching the virtual disk file to a different VM to recover your files. Again, you should treat any recovered files as possibly corrupt, and should verify any recovered data before putting it back into production.

There are two lessons to be learned here: First, you should always try to store your virtual machines on a RAID1 at the very least, or ZFS if you want to protect against silent data corruption. And, of course, make frequent backups.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .