Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers 3

up vote 0 down vote accepted

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

share|improve this answer
add comment

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.

share|improve this answer
    
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. –  Potatoswatter Jan 27 '11 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? –  jm666 Apr 28 '12 at 15:02
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.