All of lore.kernel.org
 help / color / mirror / Atom feed
* lvm+dmsetup device mapper rules
@ 2008-09-17 12:35 Michal Soltys
  0 siblings, 0 replies; only message in thread
From: Michal Soltys @ 2008-09-17 12:35 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

This is an attempt at generic device mapper rules file. Both lvm and
manually (dmsetup) created devices are supported. The rules file depends
only on lvm and dmsetup binaries.

Standard /dev/disk/* symlinks are created at the end, with additional
/dev/disk/by-id/dm-uuid-* symlinks (by device's uuid, not filesystem's one).


[-- Attachment #2: 63-device-mapper.rules --]
[-- Type: text/plain, Size: 1364 bytes --]

KERNEL=="device-mapper", NAME="mapper/control", GOTO="dm_end"

ACTION!="add|change", GOTO="dm_end"
SUBSYSTEM!="block", GOTO="dm_end"
KERNEL!="dm*", GOTO="dm_end"

# First get the name from dmsetup - it can be fed to lvs for parsing

PROGRAM="/sbin/dmsetup info -c --noheadings -o name -j%M -m%m", ENV{DM_NAME}="%c"
ENV{DM_NAME}!="?*", GOTO="dm_end"

ENV{DM_NAME}=="?*", NAME="mapper/$env{DM_NAME}"

# Try to get volume group name
# - lvs always indents first field with 2 spaces (thus %c{2})
# - note, that node doesn't have to exist, and it would fail if $tempnode was used

PROGRAM="/sbin/lvm lvs --ignorelockingfailure --noheadings -o vg_name /dev/mapper/$env{DM_NAME}", ENV{LVM_VGN}="%c{2}"
ENV{LVM_VGN}!="?*", GOTO="dm_finalize"
PROGRAM="/sbin/lvm lvs --ignorelockingfailure --noheadings -o lv_name /dev/mapper/$env{DM_NAME}", ENV{LVM_LVN}="%c{2}"
ENV{LVM_LVN}!="?*", GOTO="dm_finalize"

SYMLINK+="$env{LVM_VGN}/$env{LVM_LVN}"

LABEL="dm_finalize"

# /disk/* symlinks

PROGRAM="/sbin/dmsetup info -c --noheadings -o uuid -j%M -m%m", SYMLINK+="disk/by-id/dm-uuid-%c"
IMPORT{program}="vol_id --export $tempnode"
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"

LABEL="dm_end"




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-09-17 12:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-17 12:35 lvm+dmsetup device mapper rules Michal Soltys

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.