[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Converting installed windows (or ?) partition to virtual ma
From: |
orion |
Subject: |
[Qemu-devel] Converting installed windows (or ?) partition to virtual machine image |
Date: |
Thu, 9 Oct 2008 20:41:30 -0600 (MDT) |
User-agent: |
SquirrelMail/1.4.8-4.0.1.el5.centos.2 |
I'd like to try to convert the installed Windows partition of a dual boot
machine into a virtual machine image. It seems like qemu-img currently
only supports copying an entire disk (/dev/sda for example) to a disk
image. It would be nice if one could specify a single partition.
As a first hack/attempt to try this out, I'm trying the patch below
(against 0.9.1) to only copy a certain number of sectors. Since the
Windows partition is almost always the first partition on the disk,
hopefully this will work for most folks. I guess if you've already
installed grub you'll have issues unless you also include the /boot
partition.
It would be nice though to think about what it would take to do this
"right". Seems like you could source from a single partition and
generate the proper MBR and partition table in the virtual machine image
without too much trouble. A cursory glance seems to indicate that the
vvfat format does something like this.
Thoughts?
- Orion
--- qemu-0.9.1/qemu-img.c.part 2008-01-06 12:38:42.000000000 -0700
+++ qemu-0.9.1/qemu-img.c 2008-10-09 16:46:47.000000000 -0600
@@ -411,7 +411,7 @@
const char *fmt, *out_fmt, *out_filename;
BlockDriver *drv;
BlockDriverState **bs, *out_bs;
- int64_t total_sectors, nb_sectors, sector_num, bs_offset;
+ int64_t total_sectors, nb_sectors, sector_num, bs_offset,
requested_sectors = 0;
uint64_t bs_sectors;
uint8_t buf[IO_BUF_SIZE];
const uint8_t *buf1;
@@ -421,7 +421,7 @@
out_fmt = "raw";
flags = 0;
for(;;) {
- c = getopt(argc, argv, "f:O:hce6");
+ c = getopt(argc, argv, "f:O:s:hce6");
if (c == -1)
break;
switch(c) {
@@ -434,6 +434,9 @@
case 'O':
out_fmt = optarg;
break;
+ case 's':
+ requested_sectors = atoll(optarg);
+ break;
case 'c':
flags |= BLOCK_FLAG_COMPRESS;
break;
@@ -464,6 +467,9 @@
total_sectors += bs_sectors;
}
+ if (requested_sectors)
+ total_sectors = requested_sectors;
+
drv = bdrv_find_format(out_fmt);
if (!drv)
error("Unknown file format '%s'", out_fmt);
- [Qemu-devel] Converting installed windows (or ?) partition to virtual machine image,
orion <=
- Prev by Date:
[Qemu-devel] [5453] Update (thanks to Edgar, Thiemo, malc, Paul, Laurent and Andrzej)
- Next by Date:
Re: [Qemu-devel] [PATCH, RFC] Update qemu-tech.texi, needs verification
- Previous by thread:
[Qemu-devel] [5453] Update (thanks to Edgar, Thiemo, malc, Paul, Laurent and Andrzej)
- Next by thread:
Re: [Qemu-devel] Converting installed windows (or ?) partition to virtual machine image
- Index(es):