Creating a Virtual Machine from an Existing one Manually
Assuming an LVM setup, this is the command for allocating the required disk space (in this example 20Gb) for the main disk of the virtual machine. Another amount is required for the swap space.
where machine-name and volumegroup-name are specific to the specific setup.
The virtual units are formatted
At this point the base filesystem should be copied. First mount the partition:
You must copy the existing machine filesystem except for the directories /proc and /dev. Sometimes you must skip /home or other diretories. First create a file with the list of the directories to skip:
Then use rsync to copy the whole filesystem. Note the --exclude-from clausule, and its parameter which is the last file.
After the file copy, it is necessary to edit some configuration files (All of them in the etc directory on the mounted partition, for example /mnt/some-directory): securetty, inittab and fstab. First edit securetty
A line containing hvc0 should be in the file.
Then search inittab for a line with tty like the one below:
and edit it to:
Next, edit fstab to reflect the virtual drive configuration
It is important that in the moment the files were copied, the directories /proc and /sys had been left out. Now it is important to create those directories. With the partition mounted create the directories:
And then create the devices for the virtual machines