KVM: using a single partition [not ready]

The original howto can be found here: http://tips.at.gg3.net/2008/07/17/kvm-virtualize-a-single-partition/ .
Actually it did not work for me out of the box.

The main goal of this howto is the ability of using a single real partition as a single partition in the VM (like with Xen). I’ve just realized, it’s not possible on an easy way….

1. Create a partition table

$ dd if=/dev/zero of=disk.pt count=63
$ fdisk disk.pt

2. Prepare loop device

$ sudo losetup -f -s disk.pt
/dev/loop0

$ ls -l /dev/loop0
brw-rw—- 1 root disk 7, 0 2010-03-23 09:51 /dev/loop0

3. Create device mapper device

$ fdisk -lu /dev/mapper/vg-test|head -3

Disk /dev/mapper/vg-test: 21.5 GB, 21474836480 bytes
16 heads, 63 sectors/track, 41610 cylinders, total 41943040sectors

$ ls -l /dev/vg/vg-test
brw-rw—- 1 root root 251, 5 2010-03-23 10:32 /dev/vg/test

$ cat dm-table.txt

0 63 linear 7:0 0
63 41943040 linear 251:5 0

$ dmsetup create full_disk dm-table.txt
$ fdisk -lu /dev/mapper/full_disk|head -3

4. Check the result

Disk /dev/mapper/full_disk: 21.5 GB, 21474868736 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943103 sectors

avatar

About tompos

Hungary, Budapest
This entry was posted in IT, Linux, Uncategorized. Bookmark the permalink.

Leave a Reply