So, how does it work? Say someone shippet you a DVD image with a xen instance on. You would like to extract a small file from the image but you don't want to go through the pain of installing xen and booting.
Lets see how it works. The image is contained in test7disk1.
root@nice:/media/cdrom# sfdisk -l test7disk1 Disk test7disk1: cannot get geometry Disk test7disk1: Warning: The partition table looks like it was made for C/H/S=*/255/63 (instead of 0/0/0). For this listing I'll assume that geometry. Units = cylinders of 8225280 bytes, blocks of 1024 bytes. Device Boot Start End #cyls #blocks Id test7disk1p1 * 0+ 12 13- 104391 83 test7disk1p2 13 508 496 3984120 8e test7disk1p3 0 - 0 0 0 test7disk1p4 0 - 0 0 0
Okey. Theres a bit of whining because sfdisk can't figure out the geometry. Lets ignore that.
Now lets add the maps:
root@nice:/media/cdrom# kpartx -a test7disk1
Thats it! kpartx has set up a loopback device and created /dev/mapper/loop0p1 and /dev/mapper/loop0p2. These can be mounted, used av PVs in LVM or dealt with in other ways. Nice, eh?