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
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.
- 2,096
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
- 480,290
ddused that way will create an unpartitioned image, which will lead to an unbootablevdi. Also,bs=128Mwill 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