Важно!
При загрузке русской версии винды, невозможно переключить язык ввода в окне входа в консоли web-интерфейса proxmox, поэтому нужно перед переездом в русской версии вин заводить админа с русским именем и паролем из пробелов и цифр или русских букв

Переключение работает, при подключени с помощью tigerVNC

ЧТо нужно сделать для переезда:
1. Загрузить переезжающую виртуальную машину с Linux Rescue CD
2. Оживить сеть в загруженном Linux Rescue CD

ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up 

или DHCP

dhcpcd eth0

3. Теперь можно копировать данные с диска переносимой машины непосредственно на хост proxmox:

dd if=/dev/sda | ssh root@proxmox dd of=/var/lib/vz/images/vmid/diskname.raw

4. Файл /var/lib/vz/images/vmid/diskname.raw - это файл диска виртуалки в формате raw. Теперь создаем виртуалку с диском минимального размера (1гб) и заменем её диск только что скопированным файлом.

Ниже приведен англоязычный оригинал и некоторые дополнения. Приведенный метод подходит и для WIndows и для Linux. Я так переносил, например, Kerio Control 7.

How to migrate directly from a Windows physical machine to a VM raw file using SSH
assumptions:
* you have a physical machine in which you imported the mergeide.reg, as shown on top of this page
* the physical machine has disk device /dev/sda (read this with “fdisk -l”, and look for “hda” or “sda” or similar, NOT dm- or other…)
* you have already created a virtual machine with a raw type, file-based disk and not running.
* the VM has VMid 101 (read this from the VM list in the web interface)

download SystemRescueCD ( http://www.sysresccd.org ), burn it and reboot the physical machine with it in the cd tray.
At its bash prompt, give eth0 an ip, or use dhcp:
To assign ip:

ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up (use ip on same subnet as proxmox server)

To use DHCP:

dhcpcd eth0

To start the image process on the physical machine:

dd if=/dev/sda | ssh root@proxmox dd of=/var/lib/vz/images/vmid/diskname.raw

Change the root@proxmox to root@yourproxmoxip and change the vmid/diskname to the VMid number and the name you want to call the disk. I.E. VMid 101 and disk called vm-101-disk-1.raw would be:
dd if=/dev/sda | ssh root@proxmox dd of=/var/lib/vz/images/101/vm-101-disk-1.raw
Once this completes you can assign this disk file to your VM on the Proxmox interface.
Tested a 8GB physical server over gigabit network and was running in about 10 minutes.
How to migrate directly from a Windows physical machine to a VM logical volume using NETCAT
assumptions:

you have a physical machine in which you imported the mergeide.reg, as shown on top of this page
the physical machine has disk device /dev/sda (read this with “fdisk -l”, and look for “hda” or “sda” or similar, NOT dm- or other…)
you have already created a virtual machine with a disk on LVM, larger in size than the physical machine one (at least 1Gb more), STOPPED, do NOT start it during this procedure!
the VM has VMid 103 (read this from the VM list in the web interface)
the LVM VG is named SHARED-VG (read this with: “vgdisplay -s”)
so the LV partition is /dev/SHARED-VG/vm-103-disk-1 (read this with: “lvdisplay |grep LV|grep 103”)

download SystemRescueCD ( http://www.sysresccd.org ), burn it and reboot the physical machine with it in the cd tray.
At its bash prompt, give eth0 an ip, coherent with the network of one proxmox server (in the following example: 10.0.0.27):
ifconfig eth0 10.0.0.17 netmask 255.255.255.0 up
then assign root user a password, so you can log in via ssh:
passwd
log in via ssh on both the physical machine and the proxmox server, then on the proxmox server, give the command:
date; netcat -w30 -vvnlp 3333 | gzip -dc > /dev/SHARED-VG/vm-103-disk-1; date
and on the physical machine give the command:
dd if=/dev/sda | gzip -c | nc -w30 -vvn 10.0.0.27 3333
You have to start the second command WITHIN 30 seconds from the first one (the -w30…)!
This way, the proxmox machine is waiting for a stream of bytes on tcp port 3333, then gunzip it and redirects on the vm virtual disk.
The physical machine outputs its ENTIRE hd as a stream of bytes, gzip it and pass it via netcat to the proxmox server.
The 2 date commands are useful to have a trace of when this process starts and ends.
Tested migrating a 75gb hd in about 90 minutes on a 100mbit lan. VM started and worked as expected, after recognizing at first boot the new ide controllers.
How to migrate from a physical machine to a VM, on a smaller partition
While it's quite easy to “clone” a partition to another (real or virtual) of the same or bigger size, it's not so simple to do the same if the destination partition is smaller than the original one. This is possible, fortunately, and at least a proved method follows, but you have to take care of some preconditions:

since you want to clone to a smaller partition, we will operate at the filesystem level, copying all the files from the source filesystem to the destination one.
so, we have to make sure that the destination partition has enough room to get all the files, at least, with better some free space left there.
the cloning is not possible directly, i.e disk-to-disk, but we have to “save” the source partition, and then “restore” it on the destination one.
we have to be sure that the tools used know very well how to copy files on the filesystems involved, including symlinks, hardlinks, filesystem specific attributes, and so on.

main tool: fsarchiver
One free tool you can use for this is fsarchiver, which «is a system tool that allows you to save the contents of a file-system to a compressed archive file. The file-system can be restored on a partition which has a different size and it can be restored on a different file-system. Unlike tar/dar, FSArchiver also creates the file-system when it extracts the data to partitions. Everything is checksummed in the archive in order to protect the data. If the archive is corrupt, you just loose the current file, not the whole archive. Fsarchiver is released under the GPL-v2 license. It's still under heavy development so it must not be used on critical data.», So, you've been warned. Latest fsarchiver should be in the latest SystemRescueCD, although you can obtain it on your favourite recent distribution.
Cloning NTFS, be sure to use either version 0.6.10 or a patched previous version, because there was a bug that caused errors with NTFS junctions (something like linux symlinks).
mergeide
As other said, install mergeide.reg on the physical Windows machine (see Microsoft KB article for details) to provide support for the natively supported IDE controllers in Windows. Without this, cloned XP booting failed for me.
running fsarchiver from ubuntu livecd
I used a Ubuntu 10.04 LiveCD, where I installed the package 0.6.8-1ubuntu0.1 from the universe repository: this repository is disabled by default, you have to enable it before, doing:
#sudo nano /etc/apt/sources.lst

then, after uncommenting universe lines, installing it:
#sudo apt-get update
#sudo apt-get install fsarchiver

once installed, confirm the version is right typing
# sudo aptitude show fsarchiver

it shoud be at least “0.6.10”, or “0.6.8-1ubuntu0.1” (pathced from 0.6.9 and 0.6.10), particularly if you are cloning NTFS filesystems.
then run
#sudo fsarchiver probe simple

that will report your disks/partitions current layout in a simple, understandable way, like:
ubuntu@ubuntu:~$ sudo fsarchiver probe simple
======DISK====== =============NAME============== ====SIZE==== MAJ MIN
vda RED HAT VIRTIO SCSI DEVICE 15.00 GB 8 0

=====DEVICE===== ==FILESYS== ======LABEL====== ====SIZE==== MAJ MIN
loop0 squashfs <unknown> 671.85 MB 7 0
vda1 ntfs System 15.00 GB 8 1
ramzswap0 swap <unknown> 248.47 MB 251 0

then, you have to provide a folder to save the partition “backup”, which will be quite large (fsarchiver has several compression level, but just to be sure have enough free space there to accomodate all the uncompressed file…) if you need to reach a “tmpfolder” windows share, you have to install the smbfs package before (standard repositories), so that then you can
#sudo mkdir /mnt/tmpfolder
#sudo mount -t smbfs //windows/tmpfolder /mnt/tmpfolder -o user=username

giving a suitable password when asked.
backup the partition
then,you have to perform the “backup”, BE CAREFUL the first path is the backup file to save, the second the source partition, do not invert
I used:
#sudo fsarchiver savefs -v -o /mnt/tmpfolder/physical.fsa /dev/sda1

then (if no errors reported) mounted the same LiveCD in a kvm vm with a 15GB virtual empty disk (virtio), so /dev/vda. After installing smbfs and fsarchiver in the same way, i've run Gparted (installed on the LiveCD) and created a empty ntfs partition there, /dev/vda1.
restore the partition
Then, I run
Note: i use here /dev/vda1 while the original was /dev/sda1, and id=0 because i restore the first partition in the physical.fsa (yes, it may store more than one) as /dev/vda1
#sudo fsarchiver restfs -v /mnt/tmpfolder/physical.fsa id=0,dest=/dev/vda1

check if there are no restore errors. It was quite quick and just worked. Well, no, the first times i tried a few and in the end it worked :-^
successful cases

I successfully cloned an Windows XP professional machine from a physical 40GB (used 12GB) partition to a virtual (kvm) 15GB one, stored on pve LVM. The archive file was around 7GB. (i had just 2 hardlink restore errors, but in the log were reported on non critical files, although i would prefer 0 errors…)
I successfully cloned an Windows 2003 AD controller machine from a physical 250GB (used 5GB) partition to a virtual (kvm) 15GB one, stored on pve LVM. The archive file was around 3,4GB. (i had just 0 restore errors of any kind)
Cloned a physical ubuntu 9.04 desktop from a 32 raid5 disk to a virtual kvm 12 disk. Just had to reinstall grub to make it boot inside kvm. No errors.

Enter your comment. Wiki syntax is allowed:
 
  • proxmox/переещд-виртуальнои-машины-с-физического-хоста-или-из-другого-гипервизора.txt
  • Last modified: 2019/02/11 09:13
  • by 127.0.0.1