the codingmerc llc

application programming expert for hire

Clone a hard drive or usb disk to virtual box disk image (VDI)

It is possible to convert a hard disk or USB stick to a Virtual Box disk image including all partitions. After installing Virtual Box execute the following command in a Terminal window:

$ diskutil list

Take note of the disks listed. Now insert the disk you want to convert and run the above command again. It should show one more disk device. You can be sure that the added disk is the one you just inserted. You can skip this step if you already know which disk to convert.

Make sure the disk is unmounted but not ejected by executing the following command:

$ diskutil unmountDisk /dev/disk2

in this example I want to convert the USB stick listed as disk 2 to a VDI file.

Finally we need to convert the disk by using the following command:

$ sudo VBoxManage convertfromraw /dev/disk2 usb.vdi --format VDI

Converting from raw image file="/dev/disk2" to file="usb.vdi"...
Creating dynamic image with size 61872793600 bytes (59007MB)...

My USB stick has a size of 64GB. Make sure that you have enough disk space available for where you are going to save your virtual box disk image. 

© 2023 the codingmerc llc