{"id":1285,"date":"2023-10-07T23:53:09","date_gmt":"2023-10-07T18:23:09","guid":{"rendered":"https:\/\/www.veeble.org\/kb\/?p=1285"},"modified":"2025-03-20T11:07:13","modified_gmt":"2025-03-20T05:37:13","slug":"migrating-linux-xen-vps-to-kvm","status":"publish","type":"post","link":"https:\/\/www.veeble.com\/kb\/migrating-linux-xen-vps-to-kvm\/","title":{"rendered":"Migrating Linux Xen VPS to KVM: Step-by-Step Guide"},"content":{"rendered":"\n<p>Considering the evolving landscape of virtualization technologies, many users are opting to migrate their Xen VPS instances to KVM servers. This shift is driven by the desire for a more cost-effective and efficient hosting solution, as KVM servers have gained popularity for their lower maintenance costs and enhanced performance.  I&#8217;ve personally managed the migration of VPS from Xen to KVM in my organization and can provide clear steps to achieve it. Please note that while these instructions are tailored to the SolusVM control panel, they can be adapted for other control panels too with minor variations.<\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-1-connect-to-the-xen-node-via-ssh\">Step 1: Connect to the Xen Node via SSH<\/h4>\n\n\n<p>Begin by establishing an SSH connection to your Xen node. Access to the Xen server hosting your VPS is essential.<\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-2-find-the-vps-root-image\">Step 2: Find the VPS Root Image<\/h4>\n\n\n<p>Locate the path to your VPS root image configuration:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cat \/home\/xen\/vmID\/vmID.cfg | grep ^disk | awk -F '= ' {'print $2'} | awk -F ',sda1' {'print $1'} | awk -F ':' {'print $2'}<\/pre>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cat \/home\/xen\/vm15251\/vm15251.cfg | grep ^disk | awk -F '= ' {'print $2'} | awk -F ',sda1' {'print $1'} | awk -F ':' {'print $2'}<br>\/dev\/vps\/vm15251_img<\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-3-create-a-vps-backup-and-transfer\">Step 3: Create a VPS Backup and Transfer<\/h4>\n\n\n<p>Generate a backup of your VPS and transfer it to the destination KVM node using tools like dd or rsync. Replace path-to-image with the image path from step 2 and DESTINATION_IP with the IP address of the destination KVM node. You&#8217;ll need to enter the root password for the destination KVM node.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dd if=path-to-image of=\/image.img bs=4096k<br>rsync \/image.img DESTINATION_IP:\/root<\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-4-create-an-empty-vps-on-the-kvm-node\">Step 4: Create an Empty VPS on the KVM Node<\/h4>\n\n\n<p>On the destination KVM node, create an empty VPS, and ensure you assign an additional 2GB of storage to the new VM. This extra storage allocation helps prevent potential issues during the migration.<\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-5-connect-to-the-kvm-node-via-ssh\">Step 5: Connect to the KVM Node via SSH<\/h4>\n\n\n<p>Connect to the KVM node using SSH.<\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-6-find-the-image-path-on-the-kvm-node\">Step 6: Find the Image Path on the KVM Node<\/h4>\n\n\n<p>Identify the image path of the newly created VPS on the KVM node:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">virsh domblklist kvmID<\/pre>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">virsh domblklist kvm101<\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-7-prepare-the-kvm-vps-lvm-image\">Step 7: Prepare the KVM VPS LVM Image<\/h4>\n\n\n<p>Open the KVM VPS LVM image with the fdisk utility to create a partition matching the size of the Xen VPS disk:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">fdisk \/dev\/vps\/kvm101_img<\/pre>\n\n\n\n<p>Refer to this guide for partition creation instructions: <a href=\"https:\/\/phoenixnap.com\/kb\/linux-create-partition\" target=\"_blank\" rel=\"noopener\">Linux Create Partition<\/a><\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-8-map-and-mount-the-kvm-lvm-image\">Step 8: Map and Mount the KVM LVM Image<\/h4>\n\n\n<p>Map the KVM LVM image and mount the partition at \/mnt:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">kpartx -a \/dev\/vps\/kvm101_img<br>mount \/dev\/mapper\/vps-kvm101_img1 \/mnt<\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-9-mount-the-xen-image\">Step 9: Mount the Xen Image<\/h4>\n\n\n<p>Create a directory \/media\/source and mount the <a href=\"https:\/\/www.kumari.net\/blog\/creating-a-xen-image\" target=\"_blank\" rel=\"noopener\">Xen image<\/a> from step 3:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mkdir \/media\/source<br>mount \/root\/image.img \/media\/source<\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-10-copy-the-files-to-kvm\">Step 10: Copy the Files to KVM<\/h4>\n\n\n<pre class=\"wp-block-preformatted\">cd \/media\/source<br>rsync -alr .\/* \/mnt<\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-11-enable-rescue-mode-for-the-kvm-vps-and-access-it\">Step 11: Enable Rescue Mode for the KVM VPS and Access it<\/h4>\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2023\/10\/res.gif\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"790\" height=\"480\" data-id=\"1296\" src=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2023\/10\/res.gif\" alt=\"enabling rescue mode in solusvm\" class=\"wp-image-1296\"\/><\/a><\/figure>\n<\/figure>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-12-mount-necessary-file-systems\">Step 12: Mount Necessary File Systems<\/h4>\n\n\n<p>Mount essential file systems within the rescue environment:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mount \/dev\/vda1 \/mnt<br>mount -o bind \/dev \/mnt\/dev<br>mount -o bind \/dev\/pts \/mnt\/dev\/pts<br>mount -o bind \/proc \/mnt\/proc<br>mount -o bind \/run \/mnt\/run<br>mount -o bind \/sys \/mnt\/sys<\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-13-chroot-into-the-rescue-environment\">Step 13: Chroot into the Rescue Environment<\/h4>\n\n\n<p>Chroot into the mounted rescue environment:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">chroot \/mnt<\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-14-update-the-system\">Step 14: Update the System<\/h4>\n\n\n<p>Update the system based on your distribution:<\/p>\n\n\n\n<p>For CentOS\/RHEL:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">yum update -y<\/pre>\n\n\n\n<p>For Debian\/Ubuntu:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt update -y &amp;&amp; apt upgrade -y<\/pre>\n\n\n\n<p>Ensure that the OS vendor&#8217;s kernel is installed.<\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-15-adjust-configuration\">Step 15: Adjust Configuration<\/h4>\n\n\n<p>Change \/dev\/xvdaX references to \/dev\/vdaX and remove lines related to the swap partition in \/etc\/fstab.<\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-16-reinstall-grub\">Step 16: Reinstall Grub<\/h4>\n\n\n<p>Reinstall the Grub bootloader:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">grub-install --force \/dev\/vda<\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-17-update-grub-configuration\">Step 17: Update Grub Configuration<\/h4>\n\n\n<p>Depending on the Grub version installed, run the appropriate command:<\/p>\n\n\n\n<p>For Grub:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">grub-mkconfig -o \/boot\/grub\/grub.cfg<\/pre>\n\n\n\n<p>For Grub2:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">grub2-mkconfig -o \/boot\/grub2\/grub.cfg<\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-18-exit-chroot-environment\">Step 18: Exit Chroot Environment<\/h4>\n\n\n<p>Exit the chroot environment by pressing CTRL + D.<\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-19-unmount-everything\">Step 19: Unmount Everything<\/h4>\n\n\n<p>Unmount all mounted directories:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">umount \/mnt\/dev\/pts<br>umount \/mnt\/dev<br>umount \/mnt\/proc<br>umount \/mnt\/run<br>umount \/mnt\/sys<br>umount \/mnt<\/pre>\n\n\n\n<p>With these steps completed, you can now start your KVM VPS on the destination node, successfully migrating from Xen to KVM.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-uagb-call-to-action uagb-block-d662bb49 wp-block-button\"><div class=\"uagb-cta__wrap\"><h3 class=\"uagb-cta__title\">Unleash the Power of KVM VPS<\/h3><p class=\"uagb-cta__desc\">Experience lightning-fast performance and complete control with our cutting-edge KVM Virtual Private Servers. Built for speed and reliability.<\/p><\/div><div class=\"uagb-cta__buttons\"><a href=\"https:\/\/www.veeble.com\/in\/kvm-vps\/\" class=\"uagb-cta__button-link-wrapper wp-block-button__link\" target=\"_blank\" rel=\"noopener noreferrer\">Get Your VPS Now<svg xmlns=\"https:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\"><path d=\"M504.3 273.6l-112.1 104c-6.992 6.484-17.18 8.218-25.94 4.406c-8.758-3.812-14.42-12.45-14.42-21.1L351.9 288H32C14.33 288 .0002 273.7 .0002 255.1S14.33 224 32 224h319.9l0-72c0-9.547 5.66-18.19 14.42-22c8.754-3.809 18.95-2.075 25.94 4.41l112.1 104C514.6 247.9 514.6 264.1 504.3 273.6z\"><\/path><\/svg><\/a><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Considering the evolving landscape of virtualization technologies, many users are opting to migrate their Xen VPS instances to KVM servers. This shift is driven [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":7787,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[7],"tags":[],"class_list":["post-1285","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-migration"],"uagb_featured_image_src":{"full":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/Migrating-Linux-Xen-VPS-to-KVM-Step-by-Step-Guide.jpg",1366,768,false],"thumbnail":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/Migrating-Linux-Xen-VPS-to-KVM-Step-by-Step-Guide-150x150.jpg",150,150,true],"medium":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/Migrating-Linux-Xen-VPS-to-KVM-Step-by-Step-Guide-300x169.jpg",300,169,true],"medium_large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/Migrating-Linux-Xen-VPS-to-KVM-Step-by-Step-Guide-768x432.jpg",768,432,true],"large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/Migrating-Linux-Xen-VPS-to-KVM-Step-by-Step-Guide-1024x576.jpg",1024,576,true],"1536x1536":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/Migrating-Linux-Xen-VPS-to-KVM-Step-by-Step-Guide.jpg",1366,768,false],"2048x2048":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/Migrating-Linux-Xen-VPS-to-KVM-Step-by-Step-Guide.jpg",1366,768,false]},"uagb_author_info":{"display_name":"Adrian Antony","author_link":"https:\/\/www.veeble.com\/kb\/author\/adrian\/"},"uagb_comment_info":0,"uagb_excerpt":"Considering the evolving landscape of virtualization technologies, many users are opting to migrate their Xen VPS instances to KVM servers. This shift is driven [&hellip;]","_links":{"self":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/1285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/comments?post=1285"}],"version-history":[{"count":14,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/1285\/revisions"}],"predecessor-version":[{"id":8236,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/1285\/revisions\/8236"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media\/7787"}],"wp:attachment":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media?parent=1285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/categories?post=1285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/tags?post=1285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}