Tutorial to clone disk/partition directly into a VDI virtual disk file

This is for discussing general topics about how to use VirtualBox.
Post Reply
Marinbox
Posts: 15
Joined: 11. Dec 2018, 20:52

Tutorial to clone disk/partition directly into a VDI virtual disk file

Post by Marinbox »

Hi, these days I was looking for information to clone one of my discs to a VDI virtual disk and as in most cases they recommended me to make a copy with some backup tool and restore the copy inside VirtualBox. I kept looking for information, because in some cases where the disk has a lot of storage capacity it can be a task that demands a lot of time and space.

Finally after so much searching, I have managed to create this article where I explain the whole process to follow to get a successful cloning to a VDI image file and I share it with you.

To start cloning your disk/partition into a new VDI virtual disk file, you must have the latest version of VirtualBox installed. You can download it from here: https://www.virtualbox.org/wiki/Downloads
NOTE: The whole process has been tested and I can confirm that it works correctly.
IMPORTANT:
  • Before proceeding, you must unmount the partition to be copied to the VDI virtual disk file.
  • In case of being a disk, you must create a LiveCD or LiveUSB with ubuntu to follow the procedures.
  • In the steps to follow, I will only talk about partition but they can be applied to convert a partition or disk.
  • You must replace sdx1 with the letter corresponding to your unit.
  • In case you want to clone a bootable disk, in origin you must enter the location of the disk (this includes the MBR and all the partitions)..
Procedure:
  1. Determine the size of the partition in bytes:

    Code: Select all

    sudo parted /dev/sdx1 unit B p
    Take note of the number that appears in the size column, for example: 138412032B
  2. Clone the partition to VDI virtual disk file:

    Code: Select all

    sudo dd if=/dev/sdx1 | VBoxManage convertfromraw stdin /Path_to_destination/NameImage.vdi BYTES --format VDI
    Consider replacing the word BYTES with the number you noted in the previous step.
  3. Done.
Post Reply