|
|
5c2e41 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
5c2e41 |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
5c2e41 |
Date: Thu, 16 Oct 2014 15:49:01 -0500
|
|
|
5c2e41 |
Subject: [PATCH] RH: add mpathconf
|
|
|
5c2e41 |
|
|
|
5c2e41 |
mpathconf is a program (largely based on lvmcomf) to help users
|
|
|
5c2e41 |
configure /etc/multipath.conf and enable or disable multipathing. It
|
|
|
5c2e41 |
has a couple of built-in options that can be set directly from the
|
|
|
5c2e41 |
command line. But, mostly it is used to get a multipath.conf file
|
|
|
5c2e41 |
with the OS defaults, and to enable and disable multipathing via
|
|
|
5c2e41 |
a single command.
|
|
|
5c2e41 |
|
|
|
5c2e41 |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
5c2e41 |
---
|
|
|
5c2e41 |
libmultipath/config.c | 2 +
|
|
|
5c2e41 |
multipath/Makefile | 5 +
|
|
|
a1c519 |
multipath/mpathconf | 464 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
a1c519 |
multipath/mpathconf.8 | 119 +++++++++++
|
|
|
5c2e41 |
4 files changed, 590 insertions(+)
|
|
|
5c2e41 |
create mode 100644 multipath/mpathconf
|
|
|
5c2e41 |
create mode 100644 multipath/mpathconf.8
|
|
|
5c2e41 |
|
|
|
5c2e41 |
diff --git a/libmultipath/config.c b/libmultipath/config.c
|
|
|
a1c519 |
index 544d2fb..deb80c2 100644
|
|
|
5c2e41 |
--- a/libmultipath/config.c
|
|
|
5c2e41 |
+++ b/libmultipath/config.c
|
|
|
5c2e41 |
@@ -748,6 +748,8 @@ load_config (char * file)
|
|
|
5c2e41 |
factorize_hwtable(conf->hwtable, builtin_hwtable_size, file);
|
|
|
5c2e41 |
} else {
|
|
|
5c2e41 |
condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices.");
|
|
|
5c2e41 |
+ condlog(0, "You can run \"/sbin/mpathconf --enable\" to create");
|
|
|
5c2e41 |
+ condlog(0, "/etc/multipath.conf. See man mpathconf(8) for more details");
|
|
|
5c2e41 |
if (conf->blist_devnode == NULL) {
|
|
|
5c2e41 |
conf->blist_devnode = vector_alloc();
|
|
|
5c2e41 |
if (!conf->blist_devnode) {
|
|
|
5c2e41 |
diff --git a/multipath/Makefile b/multipath/Makefile
|
|
|
5c2e41 |
index b9bbb3c..e720c7f 100644
|
|
|
5c2e41 |
--- a/multipath/Makefile
|
|
|
5c2e41 |
+++ b/multipath/Makefile
|
|
|
5c2e41 |
@@ -18,10 +18,12 @@ $(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so
|
|
|
5c2e41 |
$(CC) $(CFLAGS) $(OBJS) -o $(EXEC) $(LDFLAGS) $(LIBDEPS)
|
|
|
5c2e41 |
$(GZIP) $(EXEC).8 > $(EXEC).8.gz
|
|
|
5c2e41 |
$(GZIP) $(EXEC).conf.5 > $(EXEC).conf.5.gz
|
|
|
5c2e41 |
+ $(GZIP) mpathconf.8 > mpathconf.8.gz
|
|
|
5c2e41 |
|
|
|
5c2e41 |
install:
|
|
|
5c2e41 |
$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
|
|
|
5c2e41 |
$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/
|
|
|
5c2e41 |
+ $(INSTALL_PROGRAM) -m 755 mpathconf $(DESTDIR)$(bindir)/
|
|
|
5c2e41 |
$(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir)
|
|
|
5c2e41 |
$(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir)
|
|
|
5c2e41 |
$(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(libudevdir)/rules.d/62-multipath.rules
|
|
|
5c2e41 |
@@ -29,13 +31,16 @@ install:
|
|
|
5c2e41 |
$(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(man8dir)
|
|
|
5c2e41 |
$(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir)
|
|
|
5c2e41 |
$(INSTALL_PROGRAM) -m 644 $(EXEC).conf.5.gz $(DESTDIR)$(man5dir)
|
|
|
5c2e41 |
+ $(INSTALL_PROGRAM) -m 644 mpathconf.8.gz $(DESTDIR)$(man8dir)
|
|
|
5c2e41 |
|
|
|
5c2e41 |
uninstall:
|
|
|
5c2e41 |
$(RM) $(DESTDIR)$(bindir)/$(EXEC)
|
|
|
5c2e41 |
$(RM) $(DESTDIR)$(udevrulesdir)/11-dm-mpath.rules
|
|
|
5c2e41 |
$(RM) $(DESTDIR)$(libudevdir)/rules.d/62-multipath.rules
|
|
|
5c2e41 |
+ $(RM) $(DESTDIR)$(bindir)/mpathconf
|
|
|
5c2e41 |
$(RM) $(DESTDIR)$(man8dir)/$(EXEC).8.gz
|
|
|
5c2e41 |
$(RM) $(DESTDIR)$(man5dir)/$(EXEC).conf.5.gz
|
|
|
5c2e41 |
+ $(RM) $(DESTDIR)$(man8dir)/mpathconf.8.gz
|
|
|
5c2e41 |
|
|
|
5c2e41 |
clean: dep_clean
|
|
|
5c2e41 |
$(RM) core *.o $(EXEC) *.gz
|
|
|
5c2e41 |
diff --git a/multipath/mpathconf b/multipath/mpathconf
|
|
|
5c2e41 |
new file mode 100644
|
|
|
5c2e41 |
index 0000000..e839134
|
|
|
5c2e41 |
--- /dev/null
|
|
|
5c2e41 |
+++ b/multipath/mpathconf
|
|
|
5c2e41 |
@@ -0,0 +1,464 @@
|
|
|
5c2e41 |
+#!/bin/bash
|
|
|
5c2e41 |
+#
|
|
|
5c2e41 |
+# Copyright (C) 2010 Red Hat, Inc. All rights reserved.
|
|
|
5c2e41 |
+#
|
|
|
5c2e41 |
+# This file is part of the device-mapper-multipath package.
|
|
|
5c2e41 |
+#
|
|
|
5c2e41 |
+# This copyrighted material is made available to anyone wishing to use,
|
|
|
5c2e41 |
+# modify, copy, or redistribute it subject to the terms and conditions
|
|
|
5c2e41 |
+# of the GNU General Public License v.2.
|
|
|
5c2e41 |
+#
|
|
|
5c2e41 |
+# You should have received a copy of the GNU General Public License
|
|
|
5c2e41 |
+# along with this program; if not, write to the Free Software Foundation,
|
|
|
5c2e41 |
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+#
|
|
|
5c2e41 |
+# Simple editting of /etc/multipath.conf
|
|
|
5c2e41 |
+# This program was largely ripped off from lvmconf
|
|
|
5c2e41 |
+#
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+unset ENABLE FIND FRIENDLY MODULE MULTIPATHD HAVE_DISABLE HAVE_WWID_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_EXCEPTIONS HAVE_DEFAULTS HAVE_FRIENDLY HAVE_MULTIPATHD HAVE_MODULE HAVE_OUTFILE SHOW_STATUS CHANGED_CONFIG WWID_LIST
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+DEFAULT_CONFIG="# device-mapper-multipath configuration file
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+# For a complete list of the default configuration values, run either:
|
|
|
5c2e41 |
+# # multipath -t
|
|
|
5c2e41 |
+# or
|
|
|
5c2e41 |
+# # multipathd show config
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+# For a list of configuration options with descriptions, see the
|
|
|
5c2e41 |
+# multipath.conf man page.
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+defaults {
|
|
|
5c2e41 |
+ user_friendly_names yes
|
|
|
5c2e41 |
+ find_multipaths yes
|
|
|
5c2e41 |
+}
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+blacklist_exceptions {
|
|
|
5c2e41 |
+ property \"(SCSI_IDENT_|ID_WWN)\"
|
|
|
5c2e41 |
+}"
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+CONFIGFILE="/etc/multipath.conf"
|
|
|
5c2e41 |
+OUTPUTFILE="/etc/multipath.conf"
|
|
|
5c2e41 |
+MULTIPATHDIR="/etc/multipath"
|
|
|
5c2e41 |
+TMPFILE="/etc/multipath/.multipath.conf.tmp"
|
|
|
5c2e41 |
+WWIDS=0
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+function usage
|
|
|
5c2e41 |
+{
|
|
|
5c2e41 |
+ echo "usage: $0 <command>"
|
|
|
5c2e41 |
+ echo ""
|
|
|
5c2e41 |
+ echo "Commands:"
|
|
|
5c2e41 |
+ echo "Enable: --enable "
|
|
|
5c2e41 |
+ echo "Disable: --disable"
|
|
|
5c2e41 |
+ echo "Only allow certain wwids (instead of enable): --allow <WWID>"
|
|
|
5c2e41 |
+ echo "Set user_friendly_names (Default y): --user_friendly_names <y|n>"
|
|
|
5c2e41 |
+ echo "Set find_multipaths (Default y): --find_multipaths <y|n>"
|
|
|
5c2e41 |
+ echo "Load the dm-multipath modules on enable (Default y): --with_module <y|n>"
|
|
|
5c2e41 |
+ echo "start/stop/reload multipathd (Default n): --with_multipathd <y|n>"
|
|
|
5c2e41 |
+ echo "select output file (Default /etc/multipath.conf): --outfile <FILE>"
|
|
|
5c2e41 |
+ echo ""
|
|
|
5c2e41 |
+}
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+function add_wwid
|
|
|
5c2e41 |
+{
|
|
|
5c2e41 |
+ INDEX=0
|
|
|
5c2e41 |
+ while [ "$INDEX" -lt "$WWIDS" ] ; do
|
|
|
5c2e41 |
+ if [ "$1" = "${WWID_LIST[$INDEX]}" ] ; then
|
|
|
5c2e41 |
+ return
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ ((INDEX++))
|
|
|
5c2e41 |
+ done
|
|
|
5c2e41 |
+ WWID_LIST[$WWIDS]="$1"
|
|
|
5c2e41 |
+ ((WWIDS++))
|
|
|
5c2e41 |
+}
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+function get_dm_deps
|
|
|
5c2e41 |
+{
|
|
|
5c2e41 |
+ shift 3
|
|
|
5c2e41 |
+ while [ -n "$1" -a -n "$2" ]; do
|
|
|
5c2e41 |
+ MAJOR=$(echo $1 | tr -d '(,')
|
|
|
5c2e41 |
+ MINOR=$(echo $2 | tr -d ')')
|
|
|
5c2e41 |
+ UUID=`dmsetup info -c --noheadings -o uuid -j $MAJOR -m $MINOR 2> /dev/null`
|
|
|
5c2e41 |
+ if [ -n "$UUID" ] ; then
|
|
|
5c2e41 |
+ set_dm_wwid $UUID
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ shift 2
|
|
|
5c2e41 |
+ done
|
|
|
5c2e41 |
+}
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+function set_dm_wwid
|
|
|
5c2e41 |
+{
|
|
|
5c2e41 |
+ if [[ "$1" =~ ^part[[:digit:]]+-mpath- ]] ; then
|
|
|
5c2e41 |
+ add_wwid "${1##part*-mpath-}"
|
|
|
5c2e41 |
+ elif [[ "$1" =~ ^mpath- ]] ; then
|
|
|
5c2e41 |
+ add_wwid "${1##mpath-}"
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ get_dm_deps `dmsetup deps -u $1`
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+}
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+function set_wwid
|
|
|
5c2e41 |
+{
|
|
|
5c2e41 |
+ UUID=""
|
|
|
5c2e41 |
+ if [[ "$1" =~ ^[[:digit:]]+:[[:digit:]]+$ ]] ; then
|
|
|
5c2e41 |
+ MAJOR=${1%%:*}
|
|
|
5c2e41 |
+ MINOR=${1##*:}
|
|
|
5c2e41 |
+ UUID=`dmsetup info -c --noheadings -o uuid -j $MAJOR -m $MINOR 2> /dev/null`
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ UUID=`dmsetup info -c --noheadings -o uuid $1 2> /dev/null`
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ -n "$UUID" ] ; then
|
|
|
5c2e41 |
+ set_dm_wwid $UUID
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ add_wwid "$1"
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+}
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+function parse_args
|
|
|
5c2e41 |
+{
|
|
|
5c2e41 |
+ while [ -n "$1" ]; do
|
|
|
5c2e41 |
+ case $1 in
|
|
|
5c2e41 |
+ --enable)
|
|
|
5c2e41 |
+ ENABLE=1
|
|
|
5c2e41 |
+ shift
|
|
|
5c2e41 |
+ ;;
|
|
|
5c2e41 |
+ --disable)
|
|
|
5c2e41 |
+ ENABLE=0
|
|
|
5c2e41 |
+ shift
|
|
|
5c2e41 |
+ ;;
|
|
|
5c2e41 |
+ --allow)
|
|
|
5c2e41 |
+ ENABLE=2
|
|
|
5c2e41 |
+ if [ -n "$2" ]; then
|
|
|
5c2e41 |
+ set_wwid $2
|
|
|
5c2e41 |
+ shift 2
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ usage
|
|
|
5c2e41 |
+ exit 1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ ;;
|
|
|
5c2e41 |
+ --user_friendly_names)
|
|
|
5c2e41 |
+ if [ -n "$2" ]; then
|
|
|
5c2e41 |
+ FRIENDLY=$2
|
|
|
5c2e41 |
+ shift 2
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ usage
|
|
|
5c2e41 |
+ exit 1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ ;;
|
|
|
5c2e41 |
+ --find_multipaths)
|
|
|
5c2e41 |
+ if [ -n "$2" ]; then
|
|
|
5c2e41 |
+ FIND=$2
|
|
|
5c2e41 |
+ shift 2
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ usage
|
|
|
5c2e41 |
+ exit 1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ ;;
|
|
|
5c2e41 |
+ --with_module)
|
|
|
5c2e41 |
+ if [ -n "$2" ]; then
|
|
|
5c2e41 |
+ MODULE=$2
|
|
|
5c2e41 |
+ shift 2
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ usage
|
|
|
5c2e41 |
+ exit 1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ ;;
|
|
|
5c2e41 |
+ --with_multipathd)
|
|
|
5c2e41 |
+ if [ -n "$2" ]; then
|
|
|
5c2e41 |
+ MULTIPATHD=$2
|
|
|
5c2e41 |
+ shift 2
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ usage
|
|
|
5c2e41 |
+ exit 1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ ;;
|
|
|
5c2e41 |
+ --outfile)
|
|
|
5c2e41 |
+ if [ -n "$2" ]; then
|
|
|
5c2e41 |
+ OUTPUTFILE=$2
|
|
|
5c2e41 |
+ HAVE_OUTFILE=1
|
|
|
5c2e41 |
+ shift 2
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ usage
|
|
|
5c2e41 |
+ exit 1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ ;;
|
|
|
5c2e41 |
+ *)
|
|
|
5c2e41 |
+ usage
|
|
|
5c2e41 |
+ exit
|
|
|
5c2e41 |
+ esac
|
|
|
5c2e41 |
+ done
|
|
|
5c2e41 |
+}
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+function validate_args
|
|
|
5c2e41 |
+{
|
|
|
5c2e41 |
+ if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$MODULE" ]; then
|
|
|
5c2e41 |
+ echo "ignoring extra parameters on disable"
|
|
|
5c2e41 |
+ FRIENDLY=""
|
|
|
5c2e41 |
+ FIND=""
|
|
|
5c2e41 |
+ MODULE=""
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ -n "$FRIENDLY" ] && [ "$FRIENDLY" != "y" -a "$FRIENDLY" != "n" ]; then
|
|
|
5c2e41 |
+ echo "--user_friendly_names must be either 'y' or 'n'"
|
|
|
5c2e41 |
+ exit 1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ -n "$FIND" ] && [ "$FIND" != "y" -a "$FIND" != "n" ]; then
|
|
|
5c2e41 |
+ echo "--find_multipaths must be either 'y' or 'n'"
|
|
|
5c2e41 |
+ exit 1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" ]; then
|
|
|
5c2e41 |
+ SHOW_STATUS=1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ -n "$MODULE" ] && [ "$MODULE" != "y" -a "$MODULE" != "n" ]; then
|
|
|
5c2e41 |
+ echo "--with_module must be either 'y' or 'n'"
|
|
|
5c2e41 |
+ exit 1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ -n "$MULTIPATHD" ] && [ "$MULTIPATHD" != "y" -a "$MULTIPATHD" != "n" ]; then
|
|
|
5c2e41 |
+ echo "--with_multipathd must be either 'y' or 'n'"
|
|
|
5c2e41 |
+ exit 1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ "$ENABLE" = 2 -a -z "$HAVE_OUTFILE" ]; then
|
|
|
5c2e41 |
+ echo "Because --allow makes changes that cannot be automatically reversed,"
|
|
|
5c2e41 |
+ echo "you must set --outfile when you set --allow"
|
|
|
5c2e41 |
+ exit 1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+}
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+function add_blacklist_exceptions
|
|
|
5c2e41 |
+{
|
|
|
5c2e41 |
+ INDEX=0
|
|
|
5c2e41 |
+ while [ "$INDEX" -lt "$WWIDS" ] ; do
|
|
|
5c2e41 |
+ sed -i '/^blacklist_exceptions[[:space:]]*{/ a\
|
|
|
5c2e41 |
+ wwid '"\"${WWID_LIST[$INDEX]}\""'
|
|
|
5c2e41 |
+' $TMPFILE
|
|
|
5c2e41 |
+ ((INDEX++))
|
|
|
5c2e41 |
+ done
|
|
|
5c2e41 |
+}
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+umask 0077
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+parse_args "$@"
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+validate_args
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if [ ! -d "$MULTIPATHDIR" ]; then
|
|
|
5c2e41 |
+ echo "/etc/multipath/ does not exist. failing"
|
|
|
5c2e41 |
+ exit 1
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+rm $TMPFILE 2> /dev/null
|
|
|
5c2e41 |
+echo "$DEFAULT_CONFIG" > $TMPFILE
|
|
|
5c2e41 |
+if [ -f "$CONFIGFILE" ]; then
|
|
|
5c2e41 |
+ cp $CONFIGFILE $TMPFILE
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if grep -q "^blacklist[[:space:]]*{" $TMPFILE ; then
|
|
|
5c2e41 |
+ HAVE_BLACKLIST=1
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if grep -q "^blacklist_exceptions[[:space:]]*{" $TMPFILE ; then
|
|
|
5c2e41 |
+ HAVE_EXCEPTIONS=1
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if grep -q "^defaults[[:space:]]*{" $TMPFILE ; then
|
|
|
5c2e41 |
+ HAVE_DEFAULTS=1
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if [ -z "$MODULE" -o "$MODULE" = "y" ]; then
|
|
|
5c2e41 |
+ if lsmod | grep -q "dm_multipath" ; then
|
|
|
5c2e41 |
+ HAVE_MODULE=1
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ HAVE_MODULE=0
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if [ "$MULTIPATHD" = "y" ]; then
|
|
|
5c2e41 |
+ if /bin/systemctl status multipathd.service > /dev/null 2>&1 ; then
|
|
|
5c2e41 |
+ HAVE_MULTIPATHD=1
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ HAVE_MULTIPATHD=0
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if [ "$HAVE_BLACKLIST" = "1" ]; then
|
|
|
5c2e41 |
+ if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*devnode \"\.\?\*\"" ; then
|
|
|
5c2e41 |
+ HAVE_DISABLE=1
|
|
|
5c2e41 |
+ elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*devnode \"\.\?\*\"" ; then
|
|
|
5c2e41 |
+ HAVE_DISABLE=0
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if [ "$HAVE_BLACKLIST" = "1" ]; then
|
|
|
5c2e41 |
+ if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*wwid \"\.\?\*\"" ; then
|
|
|
5c2e41 |
+ HAVE_WWID_DISABLE=1
|
|
|
5c2e41 |
+ elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*wwid \"\.\?\*\"" ; then
|
|
|
5c2e41 |
+ HAVE_WWID_DISABLE=0
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if [ "$HAVE_DEFAULTS" = "1" ]; then
|
|
|
5c2e41 |
+ if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)" ; then
|
|
|
5c2e41 |
+ HAVE_FIND=1
|
|
|
5c2e41 |
+ elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)" ; then
|
|
|
5c2e41 |
+ HAVE_FIND=0
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)" ; then
|
|
|
5c2e41 |
+ HAVE_FRIENDLY=1
|
|
|
5c2e41 |
+ elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(no\|0\)" ; then
|
|
|
5c2e41 |
+ HAVE_FRIENDLY=0
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if [ -n "$SHOW_STATUS" ]; then
|
|
|
5c2e41 |
+ if [ -z "$HAVE_DISABLE" -o "$HAVE_DISABLE" = 0 ]; then
|
|
|
5c2e41 |
+ echo "multipath is enabled"
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ echo "multipath is disabled"
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ -z "$HAVE_FIND" -o "$HAVE_FIND" = 0 ]; then
|
|
|
5c2e41 |
+ echo "find_multipaths is disabled"
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ echo "find_multipaths is enabled"
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ -z "$HAVE_FRIENDLY" -o "$HAVE_FRIENDLY" = 0 ]; then
|
|
|
5c2e41 |
+ echo "user_friendly_names is disabled"
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ echo "user_friendly_names is enabled"
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ -n "$HAVE_MODULE" ]; then
|
|
|
5c2e41 |
+ if [ "$HAVE_MODULE" = 1 ]; then
|
|
|
5c2e41 |
+ echo "dm_multipath module is loaded"
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ echo "dm_multipath module is not loaded"
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ -z "$HAVE_MULTIPATHD" ]; then
|
|
|
5c2e41 |
+ if /bin/systemctl status multipathd.service > /dev/null 2>&1 ; then
|
|
|
5c2e41 |
+ HAVE_MULTIPATHD=1
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ HAVE_MULTIPATHD=0
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ "$HAVE_MULTIPATHD" = 1 ]; then
|
|
|
5c2e41 |
+ echo "multipathd is running"
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ echo "multipathd is not running"
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ exit 0
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if [ -z "$HAVE_BLACKLIST" ]; then
|
|
|
5c2e41 |
+ cat >> $TMPFILE <<- _EOF_
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+blacklist {
|
|
|
5c2e41 |
+}
|
|
|
5c2e41 |
+_EOF_
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if [ -z "$HAVE_DEFAULTS" ]; then
|
|
|
5c2e41 |
+ cat >> $TMPFILE <<- _EOF_
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+defaults {
|
|
|
5c2e41 |
+}
|
|
|
5c2e41 |
+_EOF_
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if [ "$ENABLE" = 2 ]; then
|
|
|
5c2e41 |
+ if [ "$HAVE_DISABLE" = 1 ]; then
|
|
|
5c2e41 |
+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode \"\.\?\*\"/# devnode ".*"/' $TMPFILE
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ -z "$HAVE_WWID_DISABLE" ]; then
|
|
|
5c2e41 |
+ sed -i '/^blacklist[[:space:]]*{/ a\
|
|
|
5c2e41 |
+ wwid ".*"
|
|
|
5c2e41 |
+' $TMPFILE
|
|
|
5c2e41 |
+ elif [ "$HAVE_WWID_DISABLE" = 0 ]; then
|
|
|
5c2e41 |
+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*wwid \"\.\?\*\"/ wwid ".*"/' $TMPFILE
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ "$HAVE_EXCEPTIONS" = 1 ]; then
|
|
|
5c2e41 |
+ sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/ {/^[[:space:]]*wwid/ d}' $TMPFILE
|
|
|
5c2e41 |
+ else
|
|
|
5c2e41 |
+ cat >> $TMPFILE <<- _EOF_
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+blacklist_exceptions {
|
|
|
5c2e41 |
+}
|
|
|
5c2e41 |
+_EOF_
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ add_blacklist_exceptions
|
|
|
5c2e41 |
+elif [ "$ENABLE" = 1 ]; then
|
|
|
5c2e41 |
+ if [ "$HAVE_DISABLE" = 1 ]; then
|
|
|
5c2e41 |
+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode \"\.\?\*\"/# devnode ".*"/' $TMPFILE
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+elif [ "$ENABLE" = 0 ]; then
|
|
|
5c2e41 |
+ if [ -z "$HAVE_DISABLE" ]; then
|
|
|
5c2e41 |
+ sed -i '/^blacklist[[:space:]]*{/ a\
|
|
|
5c2e41 |
+ devnode ".*"
|
|
|
5c2e41 |
+' $TMPFILE
|
|
|
5c2e41 |
+ elif [ "$HAVE_DISABLE" = 0 ]; then
|
|
|
5c2e41 |
+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*devnode \"\.\?\*\"/ devnode ".*"/' $TMPFILE
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if [ "$FIND" = "n" ]; then
|
|
|
5c2e41 |
+ if [ "$HAVE_FIND" = 1 ]; then
|
|
|
5c2e41 |
+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)/ find_multipaths no/' $TMPFILE
|
|
|
5c2e41 |
+ CHANGED_CONFIG=1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+elif [ "$FIND" = "y" ]; then
|
|
|
5c2e41 |
+ if [ -z "$HAVE_FIND" ]; then
|
|
|
5c2e41 |
+ sed -i '/^defaults[[:space:]]*{/ a\
|
|
|
5c2e41 |
+ find_multipaths yes
|
|
|
5c2e41 |
+' $TMPFILE
|
|
|
5c2e41 |
+ CHANGED_CONFIG=1
|
|
|
5c2e41 |
+ elif [ "$HAVE_FIND" = 0 ]; then
|
|
|
5c2e41 |
+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)/ find_multipaths yes/' $TMPFILE
|
|
|
5c2e41 |
+ CHANGED_CONFIG=1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if [ "$FRIENDLY" = "n" ]; then
|
|
|
5c2e41 |
+ if [ "$HAVE_FRIENDLY" = 1 ]; then
|
|
|
5c2e41 |
+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)/ user_friendly_names no/' $TMPFILE
|
|
|
5c2e41 |
+ CHANGED_CONFIG=1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+elif [ "$FRIENDLY" = "y" ]; then
|
|
|
5c2e41 |
+ if [ -z "$HAVE_FRIENDLY" ]; then
|
|
|
5c2e41 |
+ sed -i '/^defaults[[:space:]]*{/ a\
|
|
|
5c2e41 |
+ user_friendly_names yes
|
|
|
5c2e41 |
+' $TMPFILE
|
|
|
5c2e41 |
+ CHANGED_CONFIG=1
|
|
|
5c2e41 |
+ elif [ "$HAVE_FRIENDLY" = 0 ]; then
|
|
|
5c2e41 |
+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]]*\(no\|0\)/ user_friendly_names yes/' $TMPFILE
|
|
|
5c2e41 |
+ CHANGED_CONFIG=1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if [ -f "$OUTPUTFILE" ]; then
|
|
|
5c2e41 |
+ cp $OUTPUTFILE $OUTPUTFILE.old
|
|
|
5c2e41 |
+ if [ $? != 0 ]; then
|
|
|
5c2e41 |
+ echo "failed to backup old config file, $OUTPUTFILE not updated"
|
|
|
5c2e41 |
+ exit 1
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+cp $TMPFILE $OUTPUTFILE
|
|
|
5c2e41 |
+if [ $? != 0 ]; then
|
|
|
5c2e41 |
+ echo "failed to copy new config file into place, check $OUTPUTFILE is still OK"
|
|
|
5c2e41 |
+ exit 1
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+rm -f $TMPFILE
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+if [ "$ENABLE" = 1 ]; then
|
|
|
5c2e41 |
+ if [ "$HAVE_MODULE" = 0 ]; then
|
|
|
5c2e41 |
+ modprobe dm_multipath
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+ if [ "$HAVE_MULTIPATHD" = 0 ]; then
|
|
|
5c2e41 |
+ systemctl start multipathd.service
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+elif [ "$ENABLE" = 0 ]; then
|
|
|
5c2e41 |
+ if [ "$HAVE_MULTIPATHD" = 1 ]; then
|
|
|
5c2e41 |
+ systemctl stop multipathd.service
|
|
|
5c2e41 |
+ fi
|
|
|
5c2e41 |
+elif [ -n "$CHANGED_CONFIG" -a "$HAVE_MULTIPATHD" = 1 ]; then
|
|
|
5c2e41 |
+ systemctl reload multipathd.service
|
|
|
5c2e41 |
+fi
|
|
|
5c2e41 |
diff --git a/multipath/mpathconf.8 b/multipath/mpathconf.8
|
|
|
5c2e41 |
new file mode 100644
|
|
|
5c2e41 |
index 0000000..5b7ae0c
|
|
|
5c2e41 |
--- /dev/null
|
|
|
5c2e41 |
+++ b/multipath/mpathconf.8
|
|
|
5c2e41 |
@@ -0,0 +1,119 @@
|
|
|
5c2e41 |
+.TH MPATHCONF 8 "June 2010" "" "Linux Administrator's Manual"
|
|
|
5c2e41 |
+.SH NAME
|
|
|
5c2e41 |
+mpathconf - A tool for configuring device-mapper-multipath
|
|
|
5c2e41 |
+.SH SYNOPSIS
|
|
|
5c2e41 |
+.B mpathconf
|
|
|
5c2e41 |
+.RB [\| commands \|]
|
|
|
5c2e41 |
+.RB [\| options \|]
|
|
|
5c2e41 |
+.SH DESCRIPTION
|
|
|
5c2e41 |
+.B mpathconf
|
|
|
5c2e41 |
+is a utility that creates or modifies
|
|
|
5c2e41 |
+.B /etc/multipath.conf.
|
|
|
5c2e41 |
+It can enable or disable multipathing and configure some common options.
|
|
|
5c2e41 |
+.B mpathconf
|
|
|
5c2e41 |
+can also load the
|
|
|
5c2e41 |
+.B dm_multipath
|
|
|
5c2e41 |
+module, start and stop the
|
|
|
5c2e41 |
+.B multipathd
|
|
|
5c2e41 |
+daemon, and configure the
|
|
|
5c2e41 |
+.B multipathd
|
|
|
5c2e41 |
+service to start automatically or not. If
|
|
|
5c2e41 |
+.B mpathconf
|
|
|
5c2e41 |
+is called with no commands, it will display the current configuration, but
|
|
|
5c2e41 |
+will not create of modify
|
|
|
5c2e41 |
+.B /etc/multipath.conf
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+The default options for mpathconf are
|
|
|
5c2e41 |
+.B --with_module
|
|
|
5c2e41 |
+The
|
|
|
5c2e41 |
+.B --with_multipathd
|
|
|
5c2e41 |
+option is not set by default. Enabling multipathing will load the
|
|
|
5c2e41 |
+.B dm_multipath
|
|
|
5c2e41 |
+module but it will not immediately start it. This is so
|
|
|
5c2e41 |
+that users can manually edit their config file if necessary, before starting
|
|
|
5c2e41 |
+.B multipathd.
|
|
|
5c2e41 |
+
|
|
|
5c2e41 |
+If
|
|
|
5c2e41 |
+.B /etc/multipath.conf
|
|
|
5c2e41 |
+already exists, mpathconf will edit it. If it does not exist, mpathconf will
|
|
|
5c2e41 |
+create a default file with
|
|
|
5c2e41 |
+.B user_friendly_names
|
|
|
5c2e41 |
+and
|
|
|
5c2e41 |
+.B find_multipaths
|
|
|
5c2e41 |
+set. To disable these, use the
|
|
|
5c2e41 |
+.B --user_friendly_names n
|
|
|
5c2e41 |
+and
|
|
|
5c2e41 |
+.B --find_multipaths n
|
|
|
5c2e41 |
+options
|
|
|
5c2e41 |
+.SH COMMANDS
|
|
|
5c2e41 |
+.TP
|
|
|
5c2e41 |
+.B --enable
|
|
|
5c2e41 |
+Removes any line that blacklists all device nodes from the
|
|
|
5c2e41 |
+.B /etc/multipath.conf
|
|
|
5c2e41 |
+blacklist section. Also, creates
|
|
|
5c2e41 |
+.B /etc/multipath.conf
|
|
|
5c2e41 |
+if it doesn't exist.
|
|
|
5c2e41 |
+.TP
|
|
|
5c2e41 |
+.B --disable
|
|
|
5c2e41 |
+Adds a line that blacklists all device nodes to the
|
|
|
5c2e41 |
+.B /etc/multipath.conf
|
|
|
5c2e41 |
+blacklist section. If no blacklist section exists, it will create one.
|
|
|
5c2e41 |
+.TP
|
|
|
5c2e41 |
+.B --allow \fB<device>\fP
|
|
|
5c2e41 |
+Modifies the \fB/etc/multipath/conf\fP blacklist to blacklist all
|
|
|
5c2e41 |
+wwids and the blacklist_exceptions to whitelist \fB<device>\fP. \fB<device>\fP
|
|
|
5c2e41 |
+can be in the form of MAJOR:MINOR, a wwid, or the name of a device-mapper
|
|
|
5c2e41 |
+device, either a multipath device, or any device on stacked on top of one or
|
|
|
5c2e41 |
+more multipath devices. This command can be used multiple times to allow
|
|
|
5c2e41 |
+multiple devices. \fBNOTE:\fP This action will create a configuration file that
|
|
|
5c2e41 |
+mpathconf will not be able to revert back to its previous state. Because
|
|
|
5c2e41 |
+of this, \fB--outfile\fP is required when using \fB--allow\fP.
|
|
|
5c2e41 |
+.TP
|
|
|
5c2e41 |
+.B --user_friendly_name \fP { \fBy\fP | \fBn\fP }
|
|
|
5c2e41 |
+If set to \fBy\fP, this adds the line
|
|
|
5c2e41 |
+.B user_friendly_names yes
|
|
|
5c2e41 |
+to the
|
|
|
5c2e41 |
+.B /etc/multipath.conf
|
|
|
5c2e41 |
+defaults section. If set to \fBn\fP, this removes the line, if present. This
|
|
|
5c2e41 |
+command can be used along with any other command.
|
|
|
5c2e41 |
+.TP
|
|
|
5c2e41 |
+.B --find_multipaths\fP { \fBy\fP | \fBn\fP }
|
|
|
5c2e41 |
+If set to \fBy\fP, this adds the line
|
|
|
5c2e41 |
+.B find_multipaths yes
|
|
|
5c2e41 |
+to the
|
|
|
5c2e41 |
+.B /etc/multipath.conf
|
|
|
5c2e41 |
+defaults section. If set to \fBn\fP, this removes the line, if present. This
|
|
|
5c2e41 |
+command can be used aldong with any other command.
|
|
|
5c2e41 |
+.TP
|
|
|
5c2e41 |
+.B --outfile \fB<filename>\fP
|
|
|
5c2e41 |
+Write the resulting multipath configuration to \fB<filename>\fP instead of
|
|
|
5c2e41 |
+\fB/etc/multipath.conf\fP.
|
|
|
5c2e41 |
+.SH OPTIONS
|
|
|
5c2e41 |
+.TP
|
|
|
5c2e41 |
+.B --with_module\fP { \fBy\fP | \fBn\fP }
|
|
|
5c2e41 |
+If set to \fBy\fP, this runs
|
|
|
5c2e41 |
+.B modprobe dm_multipath
|
|
|
5c2e41 |
+to install the multipath modules. This option only works with the
|
|
|
5c2e41 |
+.B --enable
|
|
|
5c2e41 |
+command. This option is set to \fBy\fP by default.
|
|
|
5c2e41 |
+.TP
|
|
|
5c2e41 |
+.B --with_multipathd { \fBy\fP | \fBn\fP }
|
|
|
5c2e41 |
+If set to \fBy\fP, this runs
|
|
|
5c2e41 |
+.B service multipathd start
|
|
|
5c2e41 |
+to start the multipathd daemon on \fB--enable\fP,
|
|
|
5c2e41 |
+.B service multipathd stop
|
|
|
5c2e41 |
+to stop the multipathd daemon on \fB--disable\fP, and
|
|
|
5c2e41 |
+.B service multipathd reload
|
|
|
5c2e41 |
+to reconfigure multipathd on \fB--user_frindly_names\fP and
|
|
|
5c2e41 |
+\fB--find_multipaths\fP.
|
|
|
5c2e41 |
+This option is set to \fBn\fP by default.
|
|
|
5c2e41 |
+.SH FILES
|
|
|
5c2e41 |
+.BR /etc/multipath.conf
|
|
|
5c2e41 |
+.SH "SEE ALSO"
|
|
|
5c2e41 |
+.BR multipath.conf (5),
|
|
|
5c2e41 |
+.BR modprobe (8),
|
|
|
5c2e41 |
+.BR multipath (8),
|
|
|
5c2e41 |
+.BR multipathd (8),
|
|
|
5c2e41 |
+.BR service (8),
|
|
|
5c2e41 |
+.SH AUTHOR
|
|
|
5c2e41 |
+Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
5c2e41 |
--
|
|
|
a1c519 |
2.17.2
|
|
|
5c2e41 |
|