Tux

...making Linux just a little more fun!

Talkback:114/kapil.html

[ In reference to "Right To Your Own Devices" in LG#114 ]

René Pfeiffer [lynx at luchs.at]


Mon, 28 Jan 2008 21:41:04 +0100

Hello!

While getting in touch with some colleagues who had a slight misfortune with the dd command and image files, Google directed me to the "Right To Your Own Devices" article in LG #114. The device mapper is indeed very, very useful.

Image you have a big dump file created with dd from a whole disk.

dd if=3D/dev/hda of=3D/mnt/usb/big_dump.img

Now imagine your /dev/hda device was a disk with multiple partitions. How can you access the partitions individually? Try the device mapper. By using the dmsetup command directly you have to use offsets to get to the right partition(s). There's an easier way. The command kpartx can automatically create device mapper devices from a dumpfile. kpartx is part of the "multipath-tools" package (at least on Debian, Ubuntu and Gentoo). Create a loopback device backed by the image file and use kpartx:

losetup /dev/loop0 /mnt/usb/big_dump.img
kpartx -a /dev/loop0

After that you will find the mapped devices for every partition in /dev/mapper/. You can remove the devices by using the following command:

kpartx -d /dev/loop0

"kpartx -l /dev/loop0" gives you a list of the partitions with lines that can be used in a dmsetup description table.

Make sure that your kernel and your device mapper utils match. Best use recents versions or the ones from your distribution.

Best, René.


Top    Back


Kapil Hari Paranjape [kapil at imsc.res.in]


Tue, 29 Jan 2008 08:39:01 +0530

Hello,

On Mon, 28 Jan 2008, Ren? Pfeiffer wrote:

> By using the dmsetup command directly you have to use offsets to get
> to the right partition(s). There's an easier way. The command kpartx
> can automatically create device mapper devices from a dumpfile.

Great tip. I always worried what I might need on a rescue disk for LVM partitions. Clearly "kpartx" makes the cut.

Thanks,

Kapil. --


Top    Back