Copy OS in a VHD to another VHD

I have an VHD that contains the OS for an SQL server.
Something is wrong at the disk level that the VHD file sits on,as my backups have been failing and I can't do a simple file copy of the VHD (yes the server is stopped)
I have tried creating a new VHD and selecting to copy the contents of the physical disk - this failed.
I tried to "Export" the Guest this filed.

So clearly there is something in the file/disk that is preventing the basic copying of the file.

The OS in the VHD works, i.e. I can turn on the Guest and it runs, therefore what ever is causing the issue is not effecting the actual OS files within the VHD.

I would like to know if there is a way I can copy the contents of this OS (windows Server 2008-R2) OS to another VHD.
  Have seen articles using Robocopy, but get the impression it won't do OS drives completely.

Ideally I would like to do it with the OS shutdown - i.e. open the VHD, copy contents to another VHD including boot records etc, clsoe the VHD.
Then I can jsut attached the new VHD to the guest and it should boot.

Any idea would be appreciated.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use Clonezilla. Boot Clonezilla from a .iso. Have the boot VHD and a fresh VHD attached. You can then do a clone.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David Johnson, CD, MVPOwnerCommented:
run a chkdsk on the volume that the vhdx resides this is host file system error
bmcollisAuthor Commented:
Hi David,
I have run chkdsk on it, and it found an issue, which I believe killed a VHD that was sitting on the the bad part of the disk.  Once I get the data off I will try again.

I have see reference to Clonezilla in other posts, but never used it.
So I would create a new Guest VM and attached the OS and an empty vhd.  Then for the boot source I would point to the iso - Please confirm because I thing that is very do able.

Thanks guys for your input.  Appreciate it on a Friday evening.

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

To use Clonezilla you can create a new VM or just use the existing one.

I have never encountered a corrupted VHD.
David Johnson, CD, MVPOwnerCommented:
So I would create a new Guest VM and attached the OS and an empty vhd.  Then for the boot source I would point to the iso - Please confirm because I thing that is very do able.

Create a new VM, no need to install an OS with 2 virtual disks, the one you want to copy and an empty disk and boot the vm from the clonezilla iso. Then follow the copy disk (ensure you don't get the disks mixed up)
Shaun VermaakTechnical Specialist/DeveloperCommented:
If it is a file lock issue use Hobocopy instead of Robocopy. It can copy files that are in use
bmcollisAuthor Commented:
Thanks guys for the suggestion of clonezilla and he best way to do it.

David, I like your idea, unfortunately did not see it until I had tried just attaching the blank VHD to the actual  VM.

End result - it did not work for me - although the OS would run, it was to corrupt to actually clone off.

Luckily I did find a backup from Feb, which I used as a basis to get things running again.

Very much appreciated the ideas and help.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.