2

When converting an existing PC to a VM, whether using VMWare or VirtualBox, do either allow customization? For example, convert an existing PC, but don't include certain data folders (music, video, etc.), so that the resulting VM is smaller in size?

3 Answers 3

0

I believe that you can select volumes, but not folders.

See for example a very thorough walk-through for VMware with screenshots:
Step by Step instructions to do Physical to Virtual (P2V) Server Conversion Using Vmware Converter

4

As an answer was provided for windows+vmware, let's talk about linux+virtualbox.

I strongly advise working with partitions and not full disk when creating images.

First save the partition you want to virtualize using dd or partimage. For example, to save the first partition of the first sata disk execute this command in a writeable directory with enough free space (I consider the computer on which this is done as having more than 256 Mo of ram):

dd if=/dev/sda1 of=sda1_image.dd bs=128M

Once created you may mount sda1_image.dd in order to remove the files and directories you don't want in your VM (you need to be root to use mount and umount).

mkdir temporary_mount_point
mount -o loop -t auto sda1_image.dd ./temporary_mount_point/
rm -rf temporary_mount_point/path/to/a/directory/you/dont/want/in/your/VM
umount ./temporary_mount_point/

Then convert the dd image into a virtualbox disk image (vdi) using VBoxManage (a tool provided by VirtualBox):

VBoxManage convertfromraw -format VDI sda1_image.dd sda1_image.vdi

After this step you won't need sda1_image.dd anymore.

You can then use sda1_image.vdi to create a new VM within VirtualBox management interface. However it is always easier to explain how to do so from the command line (no necessary screenshot nor themed interface quirks, only copy-paste goodness):

VBoxManage createvm -name "VM_using_sda1_image" -register
VBoxManage openmedium disk /path/to/sda1_image.vdi
VBoxManage modifyvm "VM_using_sda1_image" -hda /path/to/sda1_image.vdi

You may want to adjust some more settings, but that would be dependent on the guest's OS nature.

Depending on the way the original OS was configured, you might need to reinstall a bootloader to the VM (or to restore the mbr) and/or manually flag the partition as bootable.

3
  • dd used that way will create an unpartitioned image, which will lead to an unbootable vdi. Also, bs=128M will cut performance in half as the machine will not be able to simultaneously read and write. Also if I recall correctly, up to 128M at the end will be skipped as that won't copy a partial record. Jan 27, 2011 at 10:28
  • @avelldiroll: Cool answer. qst> If I remove some data from the mounted "dd-image" the size of image will not shrunk. So after, when will use the "VBoxManage createvm" will create expandable drive or fixed allocated space? So when my dd-image is from 300GB drive but i have only 30GB data on it i will get small (e.g. 30GB) vdi image or the big 300GB one?
    – clt60
    Apr 28, 2012 at 15:02
  • For those that don't understand part 1 of @Potatoswatter's comment - Using /dev/sda1 instead of just /dev/sda, will exclude the MBR from the image, the first and essential part of the boot process. Unfortunately I am not aware of why bs=128M will halve the performance. Perhaps something to do with the at least 256Mb of RAM available?
    – user66001
    Nov 11, 2015 at 15:52
0

Live View is a java-based VMWare forensic tool to create VMWare images from dd-style images or a physical disk.

Check it out at sourceforge.

LiveView

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .