1
1
I need to convert this HDD containing a Windows installation to a *.vdi in order to create a bootable *.img WITHOUT the unallocated space.
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 2048 718847 716800 350M 7 HPFS/NTFS/exFAT
/dev/sdb2 718848 105582591 104863744 50G 7 HPFS/NTFS/exFAT
However using VBoxManage convertfromraw /dev/sdb2
creates a vdi of dynamic size but with an unchangeable maximum of 223 GB. VBoxManage modifyhd --resize
can't reduce size at all, VBoxManage modifymedium --compact
also doesn't change it. Writing zeroes with sdelete as suggested frequently is not applicable since it's unallocated space.
Using dd
as suggested in this thread on Server Fault, by creating two images and combining them later, results in a non-bootable image.
So how to exclude that unallocated space of the source HDD?
1Do you have space to store a ~50.35 GiB image? If so, you could use
dd
to image the first ~50.35 GiB of the disk, and create a VDI from that. You need to take all data from the beginning of the disk to the end of partition 2... i.e: 105,582,591 sectors or (typically x512) 54,058,286,592 bytes -dd if=/dev/sdb of=image.dd bs=4M count=54058286592 iflag=count_bytes
– Attie – 2018-09-30T21:12:17.0232Thank you attie for your help! I didn't think of going down the dd road. As to your suggestion the only flag I used was count=10582591 since setting the blocksize parameter to 4M doubled the resulting image's size. Feel free to paste your post as answer and I'll mark it as solved. Cheers. – maxwhere – 2018-10-02T00:28:56.153