forked from pool/multipath-tools
123 lines
4.0 KiB
Plaintext
123 lines
4.0 KiB
Plaintext
tree 9a91aba3efd7bd5d7cda9856b64aafb67ebed4d4
|
|
parent 3cba05dca8ad0b09db7b738f7c3151047baccbc1
|
|
author Hannes Reinecke <hare@suse.de> 1186757218 +0200
|
|
committer Hannes Reinecke <hare@suse.de> 1186757218 +0200
|
|
|
|
Implement dm_linear
|
|
|
|
dm_linear can be used to activate kpartx-generated partitions
|
|
instead of the 'normal' block-based partitions.
|
|
|
|
Signed-off-by: Hannes Reinecke <hare@suse.de>
|
|
c595834d093c7d2f5a5c93d976ea18b8c271b490
|
|
kpartx/Makefile | 2 ++
|
|
kpartx/dm_linear | 6 ++++++
|
|
kpartx/dm_linear.rules | 1 +
|
|
kpartx/kpartx.rules | 6 ++++++
|
|
kpartx/kpartx_id | 13 ++++++++++---
|
|
5 files changed, 25 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/kpartx/Makefile b/kpartx/Makefile
|
|
index d970d29..c2b9c50 100644
|
|
--- a/kpartx/Makefile
|
|
+++ b/kpartx/Makefile
|
|
@@ -39,8 +39,10 @@ install: $(EXEC) kpartx_id $(EXEC).8
|
|
$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)
|
|
install -d $(DESTDIR)$(libudevdir)
|
|
install -m 755 kpartx_id $(DESTDIR)$(libudevdir)
|
|
+ install -m 755 dm_linear $(DESTDIR)$(libudevdir)
|
|
install -d $(DESTDIR)/etc/udev/rules.d
|
|
install -m 644 kpartx.rules $(DESTDIR)/etc/udev/rules.d/70-kpartx.rules
|
|
+ install -m 644 dm_linear.rules $(DESTDIR)/etc/udev/rules.d/62-dm_linear.rules
|
|
install -d $(DESTDIR)$(mandir)
|
|
install -m 644 $(EXEC).8 $(DESTDIR)$(mandir)
|
|
|
|
diff --git a/kpartx/dm_linear b/kpartx/dm_linear
|
|
new file mode 100755
|
|
index 0000000..1584019
|
|
--- /dev/null
|
|
+++ b/kpartx/dm_linear
|
|
@@ -0,0 +1,6 @@
|
|
+#!/bin/sh
|
|
+
|
|
+. /etc/sysconfig/kernel
|
|
+if [ "DM_BLOCK" ]; then
|
|
+ echo 0 $(/sbin/blockdev --getsize /dev/$1) linear /dev/$1 0 | /sbin/dmsetup create "linear-$ID_BUS-$ID_SERIAL" -u "linear-$ID_BUS-$ID_SERIAL"
|
|
+fi
|
|
diff --git a/kpartx/dm_linear.rules b/kpartx/dm_linear.rules
|
|
new file mode 100644
|
|
index 0000000..7bfcc50
|
|
--- /dev/null
|
|
+++ b/kpartx/dm_linear.rules
|
|
@@ -0,0 +1 @@
|
|
+ACTION=="add", KERNEL=="sd*[!0-9]", RUN+="/lib/udev/dm_linear $kernel"
|
|
diff --git a/kpartx/kpartx.rules b/kpartx/kpartx.rules
|
|
index 9ab9a49..2746eff 100644
|
|
--- a/kpartx/kpartx.rules
|
|
+++ b/kpartx/kpartx.rules
|
|
@@ -21,6 +21,10 @@ ENV{DM_UUID}=="mpath-*", \
|
|
ENV{DM_UUID}=="dmraid-*", \
|
|
SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_NAME}"
|
|
|
|
+# Create persistent links for linear tables
|
|
+ENV{DM_UUID}=="linear-*", \
|
|
+ SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_NAME}"
|
|
+
|
|
# Create persistent links for partitions
|
|
ENV{DM_PART}=="?*", \
|
|
SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_NAME}-part$env{DM_PART}"
|
|
@@ -30,6 +34,8 @@ ENV{DM_STATE}=="ACTIVE", ENV{DM_UUID}=="mpath-*", \
|
|
RUN+="/sbin/kpartx -a -p _part /dev/$kernel"
|
|
ENV{DM_STATE}=="ACTIVE", ENV{DM_UUID}=="dmraid-*", \
|
|
RUN+="/sbin/kpartx -a -p _part /dev/$kernel"
|
|
+ENV{DM_STATE}=="ACTIVE", ENV{DM_UUID}=="linear-*", \
|
|
+ RUN+="/sbin/kpartx -a -p _part /dev/$kernel"
|
|
|
|
LABEL="kpartx_end"
|
|
|
|
diff --git a/kpartx/kpartx_id b/kpartx/kpartx_id
|
|
index 81f32bf..c402e98 100644
|
|
--- a/kpartx/kpartx_id
|
|
+++ b/kpartx/kpartx_id
|
|
@@ -50,7 +50,7 @@ else
|
|
fi
|
|
|
|
# Set the name of the table. We're only interested in dmraid,
|
|
-# multipath, and kpartx tables; everything else is ignored.
|
|
+# multipath, linear, and kpartx tables; everything else is ignored.
|
|
if [ "$dmtbl" = "part" ] ; then
|
|
# The name of the kpartx table is the name of the parent table
|
|
dmname=$($DMSETUP info -c --noheadings -o name -u $dmuuid)
|
|
@@ -61,6 +61,10 @@ if [ "$dmtbl" = "part" ] ; then
|
|
mpath-*)
|
|
dmdeps=$($DMSETUP deps -u $dmuuid)
|
|
;;
|
|
+ linear-*)
|
|
+ dmtbl=linear
|
|
+ dmuuid=${dmuuid#*-}
|
|
+ ;;
|
|
esac
|
|
elif [ "$dmtbl" = "mpath" ] ; then
|
|
dmname=$tblname
|
|
@@ -72,8 +76,8 @@ fi
|
|
|
|
[ -n "$dmpart" ] && echo "DM_PART=$dmpart"
|
|
|
|
-# Figure out the type of the map. For non-multipath maps it's
|
|
-# always 'raid'.
|
|
+# Figure out the type of the map. For non-multipath non-linear
|
|
+# maps it's always 'raid'.
|
|
if [ -n "$dmdeps" ] ; then
|
|
case "$dmdeps" in
|
|
*\(94,*)
|
|
@@ -86,6 +90,9 @@ if [ -n "$dmdeps" ] ; then
|
|
echo "DM_TYPE=scsi"
|
|
;;
|
|
esac
|
|
+elif [ "$dmtbl" = linear ]; then
|
|
+ echo "DM_TYPE=${dmuuid%%-*}"
|
|
+ echo "DM_NAME=${dmuuid#*-}"
|
|
else
|
|
echo "DM_TYPE=raid"
|
|
fi
|