Difference between revisions of "Migration of servers to Proxmox VE"

From Proxmox VE
Jump to navigation Jump to search
(added SCSI for windows)
m (Redirected page to Migrate to Proxmox VE)
Tag: New redirect
 
(152 intermediate revisions by 18 users not shown)
Line 1: Line 1:
=Introduction=
+
#REDIRECT [[Migrate to Proxmox VE]]
You can migrate existing servers to Proxmox VE.
 
 
 
=Physical server to Proxmox VE (KVM)=
 
There are free tools (like [http://www.vmware.com/products/converter/ VMware Converter]) available to migrate a physical host to VMware. So the first step is to migrate the physical server to a VMware image. The second step is to follow the howto "VMware to Proxmox VE (KVM)".
 
Another option to migrate a Windows machine is to use the tool SelfImage. This way you don't have to struggle with VMware Converter and VMware, so it should be easier and faster.
 
 
 
=How to migrate directly from a Windows physical machine to a VM logical volume 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 disk and not running.
 
    * the VM has VMid 100 (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: 
 
<pre>ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up  (use ip on same subnet as proxmox server) </pre>
 
 
 
To use DHCP:
 
<pre>dhcpcd eth0</pre>
 
 
 
To start the image process on the physical machine: 
 
<pre>dd if=/dev/sda | ssh root@proxmox dd of=/var/lib/vz/images/vmid/diskname.raw</pre>
 
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 100 and disk called test would be:
 
<pre> dd if=/dev/sda | ssh root@proxmox dd of=/var/lib/vz/images/100/test.raw</pre>
 
 
 
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):
 
<pre>ifconfig eth0 10.0.0.17 netmask 255.255.255.0 up</pre>
 
then assign root user a password, so you can log in via ssh:
 
<pre>passwd</pre>
 
 
 
log in via ssh on both the physical machine and the proxmox server, then on the proxmox server, give the command:
 
<pre>date; netcat -w30 -vvnlp 3333 | gzip -dc > /dev/SHARED-VG/vm-103-disk-1; date</pre>
 
and on the physical machine give the command:
 
<pre>dd if=/dev/sda | gzip -c | nc -w30 -vvn 10.0.0.27 3333</pre>
 
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.
 
 
 
=Physical (running) server to Proxmox VE (KVM) using SelfImage=
 
 
 
==Prepare the Windows operating system==
 
 
 
Install [http://selfimage.excelcia.org SelfImage] on the physical Windows machine. Execute the [http://www.proxmox.com/cms_proxmox/cms/upload/misc/mergeide.reg mergeide.reg] (see [http://support.microsoft.com/kb/314082/en-us Microsoft KB article] for details) to provide support for the natively supported IDE controllers in Windows.
 
 
 
==Prepare the Proxmox VE VM==
 
 
 
Create an new KVM container with a suitable disk size. It is recommended that you choose the size 1 GB bigger than the size of the physical disk that you want to migrate to make sure all your data fits to the virtual disk.
 
 
 
Use VNC or SSH to connect to console on the Proxmox VE host. Export the qcow2 disk in the container directory with NBD
 
 
 
<pre>qemu-nbd -t /var/lib/vz/images/xxx/vm-xxx-disk.qcow2</pre>
 
 
 
where xxx is the VM ID.
 
 
 
If you use LVM as storage model, you can also export the logical volume created by Proxmox via the web interface
 
 
 
<pre>qemu-nbd -t /dev/VolumeGroup/vm-xxx-disk-1</pre>
 
 
 
==Do the migration==
 
 
 
Start SelfImage on the physical machine, choose to image entire hard disk, not partition. On ouput file select NBD with your '''PVE host IP''' and '''port 1024''' as parameters. Click Start.
 
 
 
When imaging is complete press CTRL+C on the PVE console to stop the export of your virtual disk file.
 
 
 
Start the virtual machine and have fun.
 
 
 
=VMware to Proxmox VE (KVM)=
 
This howto describes the migration of a Windows 2003 Server (or Windows XP) from VMware to Proxmox VE (KVM).
 
 
 
==Prepare the Windows operating system==
 
Before you begin make a copy of the VMware image.
 
===Remove VMware tools===
 
Start the Windows virtual machine on VMware and remove the VMware tools via the Windows control panel. Reboot.
 
===Enable IDE===
 
* Start the Windows virtual machine on VMware and execute the [http://www.proxmox.com/cms_proxmox/cms/upload/misc/mergeide.reg mergeide.reg]. Now the registry is changed that your Windows can boot from IDE, necessary for KVM.
 
* Make sure Atapi.sys, Intelide.sys, Pciide.sys, and Pciidex.sys are in the %SystemRoot%\System32\Drivers folder. If any are missing they can be extracted from %SystemRoot%\Driver Cache\I386\Driver.cab
 
* see [http://support.microsoft.com/kb/314082/en-us Microsoft KB article] for details.
 
* Shutdown Windows.
 
 
 
==Prepare the disk file==
 
My disk file used for this howto: win2003.vmdk
 
* Change your VMDK disk file with vmware-vdiskmanager.exe to a single growable file (vmware-vdiskmanager.exe is located in your VMware installation path, e.g. "C:\Program Files\VMware\VMware Server") - open a cmd and go to the directory where your vmdk disk files are.
 
<pre>"C:\Program Files\VMware\VMware Server\vmware-vdiskmanager" -r win2003.vmdk -t 0 win2003-pve.vmdk</pre>
 
* Create a new KVM VM on Proxmox VE web interface and - do not start - take a look on the VMID (e.g. 102)
 
* Copy the win2003-pve.vmdk to your Proxmox VE server into the following dir: /var/lib/vz/images/VMID (I used [http://winscp.net WinSCP] as I worked on a Windows desktop)
 
* Change the win2003-pve.vmdk file to qemu format:
 
<pre>qemu-img convert -f vmdk win2003-pve.vmdk -O qcow2 win2003-pve.qcow2</pre>
 
* Or, copy the vmdk to an LVM based disk of the same size or larger
 
<pre>dd if=win2003-pve.vmdk of=/dev/VG_iscsi/vm-102-disk-1</pre>
 
 
 
==Adapt the new KVM Virtual Machine==
 
* Go to the hardware tab on the web interface and remove the default harddisk file
 
* Add the migrated harddisk as IDE for windows (only IDE works for windows) or SCSI for Linux
 
* Start the new Virtual Machine via the management interface
 
* First boot takes some time as some drives has to be loaded
 
* Do not forget to install [[Paravirtualized_Network_Drivers_for_Windows]]
 
* Finished!
 
 
 
For comments or problems please post to the [http://www.proxmox.com/forum/forumdisplay.php?f=12 Proxmox VE forum] or to the [http://pve.proxmox.com/wiki/Mailing_Lists mailing list]
 
 
 
=XEN to Proxmox VE (KVM)=
 
XEN also uses qemu disk format, so it should work in the same manner as described under "VMware to Proxmox VE (KVM)".
 
 
 
=Move OpenVZ containers to Proxmox VE=
 
You can move existing OpenVZ containers (container=VE=VPS) with vzmigrate or vzdump:
 
* Use vzmigrate offline migration to move your container to Proxmox VE
 
* Use vzdump to restore from a backup
 
 
 
After you moved your container you need to add the following line to the corresponding config file (see /etc/vz/conf/xyz.conf):
 
<pre>nano /etc/vz/conf/xyz.conf</pre>
 
 
 
Add/edit the following line:
 
<pre>ORIGIN_SAMPLE="pve.auto"</pre>
 
 
 
Now you can manage resource settings on the Proxmox VE management interface.
 
 
 
=Physical server (or KVM, VMware, XEN or other) to Proxmox VE OpenVZ Container=
 
External links:
 
*[http://howtoforge.com/how-to-convert-physical-systems-and-xen-vms-into-openvz-containers-debian-etch How To Convert Physical Systems And Xen VMs Into OpenVZ Containers]
 
*[http://wiki.openvz.org/Physical_to_container Physical_to_container]
 
 
 
=Convert Windows to use SCSI (KVM)=
 
This requires a 2.6.24 or 2.6.32 kernel.  SCSI will not work on 2.6.18.  This procedure is needed to get Windows to load and active the SCSI drivers, once active you can switch the disk and it shoudl Just Works.  Tested with Windows 2003 SP1 on Proxmox VE 1.5 with the 2.6.32 kernel installed.  I have not yet tested it for performance or reliability but it theoretically will be better, use at your own risk.
 
* With the Virtual Machine powered off, add a new temporary SCSI virtual disk
 
* Boot the Virtual Machine and make sure the drivers load for the new disk,  You do not need to format it, just make sure you can see it in Device Manager
 
* Shut down the Virtual Machine, then remove the new disk and any IDE disks, do not delete the LVM or disk image file.
 
* Add the disks you just removed back as SCSI disks and boot the Virtual Machine.
 
 
 
[[Category: HOWTO]]
 

Latest revision as of 15:47, 13 February 2024