[linux-lvm] IOP selection scripts (was: '/etc/init.d/lvm' script in debian package)

Claudio Matsuoka claudio at conectiva.com
Wed Dec 20 23:29:38 UTC 2000

On Wed, 20 Dec 2000, Andreas Dilger wrote:

> My current (path-based) LVM startup (rc.sysinit) looks like:
> # Try to load LVM module first in case it isn't compiled in or already loaded
> [ -f /etc/lvmtab -a ! -e /proc/lvm ] && modprobe lvm 2> /dev/null
> if [ -f /etc/lvmtab -a -e /proc/lvm ]; then
> 	[ -f /proc/lvm ] && IOP=`awk '/IOP/ { print $7 }' /proc/lvm`
> 	[ -d /proc/lvm ] && IOP=`awk '/IOP/ { print $7 }' /proc/lvm/global`
> 	[ "$IOP" -a -d /sbin/lvm-$IOP ] && PATH=/sbin/lvm-$IOP:$PATH
> 	vgchange -a y
> 	rc=$?
> 	# error handling
> 	if [ $rc -ne 0 ]; then
> 		# blah
> 	fi
> fi

I have lvm activation in /etc/rc.d/rc.sysinit (using an explicit modprobe
too, since just expecting the module to be auto-loaded fails in some
machines). I've placed it just after /proc mounting and before everything
else. Using the wrapper approach, the wrapper script looks like:

# This is a wrapper to call the appropriate LVM userspace tools based
# on the IOP version in use.
# 20001217  Claudio Matsuoka <claudio at conectiva.com>
# - first version

ver_str="IOP version: "
util=`basename $0`

if [ "$util" = "lvm-wrapper" ]; then
    echo "$util: you don't want to call the wrapper directly" 1>&2
    exit -2

if [ -f $proclvm ]; then
    IOP=`grep "$ver_str" $proclvm|sed "s/.*$ver_str\([0-9]*\).*/\1/"`
elif [ -d $proclvm ]; then
    IOP=`grep "$ver_str" $proclvm/global|sed "s/.*$ver_str\([0-9]*\).*/\1/"`
    echo "$util: $proclvm not found (can't determine IOP version)" 1>&2
    exit -1

exec /lib/lvm-iop${IOP}/$util $*

> I also have the 3 lines of LVM path setting in the root .bashrc.
> This approach means that anyone who has old tools directly installed in
> /sbin can still survive the installation of new tools in /sbin/lvm-$IOP.

Hmm, that's an interesting point. The wrapper approach won't allow
real files to be installed in /sbin (but package management should take
care of that).

> My next change will to have an lvmiopversion command (see below).  This
> has the benefit of not needing extra parsing and such (like awk), and it
> won't care what /proc/lvm is, or even if /proc is mounted.  It will also
> have the side effect of loading the LVM module if it needs to be loaded.

Sounds good. I'll use it in my tests too.


More information about the linux-lvm mailing list