From 204ed754621fef9d47640c671fc1f6ed53d8ad58 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 16 Aug 2010 20:58:43 -0700 Subject: [PATCH] Cleanly handle partitions in zpool_layout I knew I'd forget something in the first version of this script. It turns out what I forgot was partition handling, this commit ensures duplicate entries are not created in the zdev.conf file. This previously could occur due to partition entires in the by-path directory. This is not needed the existing udev rules will ensure the partitions are created in /dev/disk/zpool/. --- cmd/zpool_layout/zpool_layout | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cmd/zpool_layout/zpool_layout b/cmd/zpool_layout/zpool_layout index e88cbe3c02..19cd128079 100755 --- a/cmd/zpool_layout/zpool_layout +++ b/cmd/zpool_layout/zpool_layout @@ -5,6 +5,13 @@ # current script enumerates each port on a bus before moving on to # enumerate the next bus. # +# Every distribution, version of udev, and type of attached storage +# seems to result in slightly different formatting of the by-path +# name. For this reason you may need to adjust the parsing below +# to suit your needs. This is one of the reasons to use a custom +# /etc/zfs/zdev.conf file, it allows the by-path naming convertion +# to change and still keep the simple naming. +# CONFIG=${CONFIG:-/etc/zfs/zdev.conf} BUSES=( 01 02 03 ) PORTS=( 4 0 ) @@ -84,7 +91,7 @@ for (( i=0, k=0; i<${#BUSES[*]}; i++ )); do for (( j=0; j<${#PORTS[*]}; j++, k++ )); do printf "# %-9s" ${CHANNELS[$k]} ls *:${BUSES[$i]}:*:${PORTS[$j]}* 2>/dev/null | \ - cut -f7 -d'-' | sort -n | tr '\n' ',' + cut -f7 -d'-' | sort -u -n | tr '\n' ',' echo done done @@ -96,8 +103,8 @@ AWK=${AWK:-/bin/awk} for (( i=0, k=0; i<${#BUSES[*]}; i++ )); do for (( j=0; j<${#PORTS[*]}; j++, k++ )); do - ls *:${BUSES[$i]}:*:${PORTS[$j]}* 2>/dev/null | \ - sort -n -k7 -t'-'>${TMP_FILE} + ls *:${BUSES[$i]}:*:${PORTS[$j]}* 2>/dev/null | \ + grep -v part | sort -n -k7 -t'-'>${TMP_FILE} echo echo -n "# Channel ${CHANNELS[$k]}, "