User Tools

Site Tools


converting_a_partition_image_to_a_disk_image

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

converting_a_partition_image_to_a_disk_image [2009/12/13 19:12]
127.0.0.1 external edit
converting_a_partition_image_to_a_disk_image [2011/09/10 17:37]
Line 1: Line 1:
-This will document the steps necessary to convert a singe-partition image (a la Xen) to a full disk image suitable for use with KVM. 
  
-Essentially,​ we need to make a disk with the partitions laid out in such a way that the QEMU virtual device can find them.  For this first iteration, we are only going to try to create a device with a root and swap partition. 
- 
-First, create an empty disk (raw format) 
-<code bash> 
-qemu-img create -f raw 10G starworker.img 
-</​code>​ 
- 
-Next, perform a fresh install of the OS (in a VM) that you wish to migrate, taking care to make the root partition at least as big as the partition image. 
- 
-Next we will need to mount the root partition of the VM offline. ​ To do this, we will need to use fdisk on the disk image to find the start of the root partition.  ​ 
-<code bash> 
-fdisk -lu starworker.img 
-</​code>​ 
-The start column contains the offset, but the units are **not** bytes. ​ The fdisk output will contain the units. 
- 
-Now mount the both the new and old filesystems and copy the files. 
-<code bash> 
-mount -o loop starworker_partimg /​mnt/​looppart/​ 
-mount -o loop,​offset=$(( $START * $UNITS )) starworker.img /​mnt/​loopdisk/​ 
-cp -a /​mnt/​looppart/​* /​mnt/​loopdisk 
-</​code>​ 
-When copying the files, make sure that you don't overwrite the /boot/ directory on this disk image. ​ This probably won't be an issue, because the partition image probably doesn'​t contain a /boot/ or if it does, it would be empty. (That'​s why we're going through this process in the first place!) 
- 
-Now, you should be ready to boot the new image. ​ It should be the same as the old image, only now we have a disk image with a bootloader, kernel, and initrd. 
converting_a_partition_image_to_a_disk_image.txt ยท Last modified: 2011/09/10 17:37 (external edit)