Ron Peterson

Getting Debian Etch to play nice with partitioned drives on a fiber channel setup requires making some modifications to the supplied udev scripts which handle multipath setups.

My first naive attempt to write the udev rules to handle creating device nodes for our fiber channel disk partitions looked like this:

KERNEL!="dm-*", GOTO="kpartx_end"
ACTION=="remove", GOTO="kpartx_end"
ACTION=="modify", GOTO="kpartx_end"
ACTION=="add", \
    SUBSYSTEM=="block", \
    KERNEL=="dm-*", \
    PROGRAM="/sbin/devmap_name %M %m", \
    RUN+="/sbin/kpartx -a /dev/mapper/%c"

This doesn't work.  Hannes Reinecke kindly explained the problem to me on the dm-devel list:

Problem being the 'interesting' device-mapper design.  Whenever a 'table create' operation is triggered from user-space, it's actually being broken down by the device-mapper library into 4 distinct operations:

1. create device dm-X
2. suspend device
3. load table definition
4. resume device

and you'll be getting an 'add' event for the first operation, and a 'change' event for the second and the forth operation. But clearly the 'add' event is pretty much pointless, as there is not table loaded at that time, so you wouldn't know what to do with it. And the device is locked between the second and the fourth operation, so kpartx would refuse to touch it.

So, in essence: 'add' is evil for device-mapper devices. Use the 'change' event and check if the dm-device is not suspended when you get the event.

The easiest way to accomplish this is to obtain a good kpartx.rules udev script from a recent distribution.  IIRC, I got mine from Debian unstable.  It won't work out of the box on Etch, though, because it calls scripts and functions that don't exist on Etch, so you have to get those too.  I downloaded and installed the latest device-mapper source, and also retrieved the required /lib/udev/kpartx_id and /lib/udev/dmsetup_env scripts.  Now kpartx reliably creates disk partition device nodes when udev receives kernel notifications about disk change events.

Hopefully google will help someone else find this note, and save them the trouble I went through.


Post a Comment:
Comments are closed for this entry.