Copy OS in a VHD to another VHD

bmcollis
bmcollis used Ask the Experts™
on
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.

Brian
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Network Engineer
Commented:
Use Clonezilla. Boot Clonezilla from a .iso. Have the boot VHD and a fresh VHD attached. You can then do a clone.
Top Expert 2016

Commented:
run a chkdsk on the volume that the vhdx resides this is host file system error

Author

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.

kevinhsieh
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.

Brian
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

kevinhsiehNetwork Engineer

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

I have never encountered a corrupted VHD.
Top Expert 2016
Commented:
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
Awarded 2017
Distinguished Expert 2018

Commented:
If it is a file lock issue use Hobocopy instead of Robocopy. It can copy files that are in use
https://github.com/candera/hobocopy

Author

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.

Brian

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial