Clone physical disk to VDI virtual disk (VirtualBox)

clonehard drivevirtualbox

I'm looking for a way to clone sector by sector of my physical disk to my VDI virtual disk. As I was reading, some do not recommend the use of dd for this.

If I can not use dd to copy sector by sector and restore the image inside virtualbox, what else is there to do this?

Keep in mind: The image must include the information of each sector (even if it is not assigned) as I want to do information retrieval and forensic tests within VirtualBox.

Operating system: Ubuntu

Best Answer

You are trying to do Physical-to-Virtual, where dd is a possible tool but not the best.

As it isn't recommended to copy the running system from within itself. The process below comes from the article Physical To Virtual (P2V) using VirtualBox and requires:

Here is the procedure. The author describes how to copy one partition, so you will need to modify this slightly to virtualize the whole disk. This is required for including the boot code.

  1. Boot the system with Clonezilla
  2. At the menu, select “Clonezilla Live”
  3. Choose your language when prompted
  4. Select your desired keymap as needed
  5. At the menu, select “Start_Clonezilla”
  6. Specify “device-image” 7 Select “local_dev” to save the image to a local device (NOTE: if you need to save it somewhere else, make the proper selection)
  7. When asked to connect USB devices, do so and then press “Enter”
  8. Choose the desired drive or partition to save the image
  9. A directory structure will be shown for the selected drive or partition. Select the appropriate folder in which to place the backup image
  10. A listing of disk space usage for the selected location will be displayed. Press “Enter”
  11. Choose “Expert” for the backup mode
  12. Select savedisk (when backing up a whole disk), or savepart (when backing up a single partition) - for my example, I am using savepart so some prompts may be a little different
  13. A prompt for the name of the backup is required. Remove the existing information and give it a simple name like “LinuxBack”. The name given is the folder name in which the backup files are placed. Remember the name so you know the location of the backup files
  14. A listing of existing drives and/or partitions will be listed. Highlight the one to backup, press “spacebar” and then “enter”
  15. At the next menu, select -q1 for a dd backup
  16. The next menu shows various parameter options to select. By default, the -c and -j2 are checked. The defaults are fine unless you require others
  17. When prompted for the compression type, select -z0
  18. At the next menu when prompted about splitting the file, make sure the size is larger than the drive or partition being backed up
  19. Select the option to “Skip checking/repairing source file system”, unless you believe it is necessary
  20. At the next menu select to skip checking the saved image file
  21. For the action to perform when the backup is completed, select what you prefer
  22. At this point, the options are set and the command-line should be listed which is being executed to perform the backup. Press “enter”
  23. You are prompted if you want to continue and perform the backup, so press “y” and then “enter”
  24. The backup should begin
  25. Exit Clonezilla when the backup is completed and copy the directory specified in option 14 to the system with VirtualBox, if the virtual system will be run on another system, and be sure to include the directory itself (in my example it would be called LinuxBack)

Once the backup folder and files are moved to the system with VirtualBox installed, perform the following command:

VboxManage convertfromraw --format VDI source.img target.vdi

I have not performed the above procedure myself, and some steps might have changed in some small detail since the above was published, but the general steps should still be the same.

Related Question