All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-lvm] '/etc/init.d/lvm' script in debian package
@ 2000-12-20  9:29 Gergely Tamas
  2000-12-20 21:40 ` Russell Coker
  0 siblings, 1 reply; 18+ messages in thread
From: Gergely Tamas @ 2000-12-20  9:29 UTC (permalink / raw)
  To: linux-lvm

Hi!

Some notes to the /etc/init.d/lvm script in the debian packages ...

1] --- it would be better to add '-a ! -d /proc/lvm' as shown bellow,
       becouse in in the newer versions '/proc/lvm' is a directory
       (but what if compiled without /proc/lvm info...)

if [ ! -f /proc/lvm -a ! -d /proc/lvm ]; then
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ was: '[ ! -f /proc/lvm ]; then'

	if [ ! -f /lib/modules/`uname -r`/block/lvm.o -a ! -f /lib/modules/`uname -r`/block/lvm-mod.o ]; then
		exit 0
	fi
fi
---

2] --- I still think that an init.d script should display a usage help as
       default

case "$1" in
	start)
        ^^^^^^ was: 'start|"")'

		echo "Setting up LVM Volume Groups..."
		#/sbin/vgscan
		/sbin/vgchange -a y
		;;

Thanks,
Gergely

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] '/etc/init.d/lvm' script in debian package
  2000-12-20  9:29 [linux-lvm] '/etc/init.d/lvm' script in debian package Gergely Tamas
@ 2000-12-20 21:40 ` Russell Coker
  2000-12-20 22:21   ` Claudio Matsuoka
  2000-12-21  8:37   ` [linux-lvm] '/etc/init.d/lvm' script in debian package Gergely Tamas
  0 siblings, 2 replies; 18+ messages in thread
From: Russell Coker @ 2000-12-20 21:40 UTC (permalink / raw)
  To: linux-lvm, Gergely Tamas

On Wednesday 20 December 2000 20:29, Gergely Tamas wrote:
> Hi!
>
> Some notes to the /etc/init.d/lvm script in the debian packages ...
>
> 1] --- it would be better to add '-a ! -d /proc/lvm' as shown bellow,
>        becouse in in the newer versions '/proc/lvm' is a directory
>        (but what if compiled without /proc/lvm info...)
>
> if [ ! -f /proc/lvm -a ! -d /proc/lvm ]; then
>    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ was: '[ ! -f /proc/lvm ]; then'
>
> 	if [ ! -f /lib/modules/`uname -r`/block/lvm.o -a ! -f /lib/modules/`uname
> -r`/block/lvm-mod.o ]; then exit 0
> 	fi
> fi

Thanks for the suggestion about checking for a directory.  But how will I 
determine what version of LVM if it's a directory?  Will there be 
/proc/lvm/version?

As for the checking for the module file.  With the way module management is 
being changed in recent kernels I'm not about to do such checking as it's too 
likely that things will get broken.

I'll just assume that if the LVM module isn't loaded then the administrator 
doesn't want it to start.

LVM isn't something that you want to be automatically loading on demand, 
either you need it or you don't.  If you need it then you will probably want 
to compile it in or put it in /etc/modules for loading on boot.

> 2] --- I still think that an init.d script should display a usage help as
>        default
>
> case "$1" in
> 	start)
>         ^^^^^^ was: 'start|"")'

Done.

-- 
http://www.coker.com.au/bonnie++/     Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/       Postal SMTP/POP benchmark
http://www.coker.com.au/projects.html Projects I am working on
http://www.coker.com.au/~russell/     My home page

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] '/etc/init.d/lvm' script in debian package
  2000-12-20 21:40 ` Russell Coker
@ 2000-12-20 22:21   ` Claudio Matsuoka
  2000-12-20 23:08     ` Andreas Dilger
  2000-12-21  8:37   ` [linux-lvm] '/etc/init.d/lvm' script in debian package Gergely Tamas
  1 sibling, 1 reply; 18+ messages in thread
From: Claudio Matsuoka @ 2000-12-20 22:21 UTC (permalink / raw)
  To: linux-lvm; +Cc: Gergely Tamas

On Thu, 21 Dec 2000, Russell Coker wrote:

> Thanks for the suggestion about checking for a directory.  But how will I 
> determine what version of LVM if it's a directory?  Will there be 
> /proc/lvm/version?

You can check the LVM and IOP version in /proc/lvm/global.

[claudio@pokey:/home/claudio] cat /proc/lvm/global
LVM module version 0.9 (13/11/2000)

Total:  1 VG  1 PV  5 LVs (5 LVs open 5 times)

Global: 15258 bytes malloced   IOP version: 10   14:55:25 active

VG:  vg00  [1 PV, 5 LV/5 open]  PE Size: 4096 KB
  Usage [KB/PE]: 7557120 /1845 total  2465792 /602 used  5091328 /1243 free
  PV:  [AA] hda3                   7557120 /1845     2465792 /602      5091328 /1243  
    LVs: [AWDL  ] lv_swap                     131072 /32       1x open
         [AWDL  ] lv_tmp                       32768 /8        1x open
         [AWDL  ] lv_share                    204800 /50       1x open
         [AWDL  ] lv_home                    1048576 /256      1x open
         [AWDL  ] lv_src                     1048576 /256      1x open


claudio

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] '/etc/init.d/lvm' script in debian package
  2000-12-20 22:21   ` Claudio Matsuoka
@ 2000-12-20 23:08     ` Andreas Dilger
  2000-12-20 23:29       ` [linux-lvm] IOP selection scripts (was: '/etc/init.d/lvm' script in debian package) Claudio Matsuoka
  0 siblings, 1 reply; 18+ messages in thread
From: Andreas Dilger @ 2000-12-20 23:08 UTC (permalink / raw)
  To: linux-lvm; +Cc: Gergely Tamas

Claudio writes:
> On Thu, 21 Dec 2000, Russell Coker wrote:
> 
> > Thanks for the suggestion about checking for a directory.  But how will I 
> > determine what version of LVM if it's a directory?  Will there be 
> > /proc/lvm/version?
> 
> You can check the LVM and IOP version in /proc/lvm/global.
> 
> [claudio@pokey:/home/claudio] cat /proc/lvm/global
> LVM module version 0.9 (13/11/2000)
> 
> Total:  1 VG  1 PV  5 LVs (5 LVs open 5 times)
> 
> Global: 15258 bytes malloced   IOP version: 10   14:55:25 active
> 

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 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.

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.
This will leave me with the following in rc.sysinit/.bashrc:

if [ -f /etc/lvmtab ]; then
	IOP=`lvmiopversion 2> /dev/null`
	rc=$?
	if [ $rc -eq 0 ]; then
		[ -d /sbin/lvm-$IOP ] && PATH=/sbin/lvm-$IOP:$PATH
		vgchange -a y
		rc=$?
	fi

	# error handling
	if [ $rc -ne 0 ]; then
		# blah
	fi
fi

Heinz, can you consider adding the lvmiopversion.c file to the LVM CVS?
No matter which way we go it will probably be a useful command to have.

Cheers, Andreas
========================== lvmiopversion.c ===================================
/*
 * tools/lvmiopversion.c
 *
 * Copyright (C) 2000  Andreas Dilger <adilger@turbolinux.com>
 *
 * LVM is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * LVM is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with LVM; see the file COPYING.  If not, write to
 * the Free Software Foundation, 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <stdio.h>
#include <lvm_user.h>

#ifdef DEBUG
int opt_d;
#endif

char *cmd = "lvmiopversion";

int main(int argc, char *argv[])
{
	int ver = lvm_get_iop_version();

	if (ver < 0) {
		fprintf(stderr, "%s -- LVM driver/module not loaded?\n\n", cmd);
		return LVM_EDRIVER;
	}

	printf("%d\n", ver);
	return 0;
}

-- 
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [linux-lvm] IOP selection scripts (was: '/etc/init.d/lvm' script in debian package)
  2000-12-20 23:08     ` Andreas Dilger
@ 2000-12-20 23:29       ` Claudio Matsuoka
  2000-12-21  0:34         ` Andreas Dilger
  0 siblings, 1 reply; 18+ messages in thread
From: Claudio Matsuoka @ 2000-12-20 23:29 UTC (permalink / raw)
  To: linux-lvm; +Cc: Gergely Tamas

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:

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

ver_str="IOP version: "
proclvm=/proc/lvm
util=`basename $0`

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

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/"`
else
    echo "$util: $proclvm not found (can't determine IOP version)" 1>&2
    exit -1
fi

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.


claudio

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] IOP selection scripts (was: '/etc/init.d/lvm' script in debian package)
  2000-12-20 23:29       ` [linux-lvm] IOP selection scripts (was: '/etc/init.d/lvm' script in debian package) Claudio Matsuoka
@ 2000-12-21  0:34         ` Andreas Dilger
  2000-12-21 10:28           ` Claudio Matsuoka
  0 siblings, 1 reply; 18+ messages in thread
From: Andreas Dilger @ 2000-12-21  0:34 UTC (permalink / raw)
  To: linux-lvm; +Cc: Gergely Tamas

Claudio writes:
> if [ "$util" = "lvm-wrapper" ]; then
>     echo "$util: you don't want to call the wrapper directly" 1>&2
>     exit -2
           ^^ I don't think this is legal...
> fi

Is there ever a reason why you would want to install this program as
"lvm-wrapper" anywhere?

> 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/"`
> else
>     echo "$util: $proclvm not found (can't determine IOP version)" 1>&2
>     exit -1
> fi
> 
> exec /lib/lvm-iop${IOP}/$util $*

Probably some simple checks for the existence of /lib/lvm-iop$iop and
/lib/lvm-iop$iop/$util and printing a nice message would be helpful, like:

LIBLVM=/lib/lvm-iop${IOP}
LVMPKG=lvm-iop${IOP}

if [ ! -d $LIBLVM ]; then
	echo "$util: $LIBLVM not found.  Is $LVMPKG installed?" 1>&2
	exit 3
fi
exec $LIBLVM/$util "$@"	# this will print out a localized error message for us


I think I will go with an approach like this as well, since it still keeps
/sbin/<lvmcommand> in place (for scripts that have this hard-coded).

Cheers, Andreas
-- 
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] '/etc/init.d/lvm' script in debian package
  2000-12-20 21:40 ` Russell Coker
  2000-12-20 22:21   ` Claudio Matsuoka
@ 2000-12-21  8:37   ` Gergely Tamas
  2000-12-21  9:04     ` Patrick Caulfield
  2000-12-21  9:44     ` Claudio Matsuoka
  1 sibling, 2 replies; 18+ messages in thread
From: Gergely Tamas @ 2000-12-21  8:37 UTC (permalink / raw)
  To: Russell Coker; +Cc: linux-lvm

Hi!

> Thanks for the suggestion about checking for a directory.  But how will I
> determine what version of LVM if it's a directory?  Will there be
> /proc/lvm/version?
$ head -n 1 /proc/lvm/global
LVM driver version 0.9 (13/11/2000)

> LVM isn't something that you want to be automatically loading on demand,
> either you need it or you don't.  If you need it then you will probably want
> to compile it in or put it in /etc/modules for loading on boot.
Yes.

A few ideas ...
1) if LVM is compiled into the kernel and /boot/System.map is reachable,
than it could be detected using e.g. 'grep lvm System.map'

2) if /usr/src/kernel/.config is reachable, than it could be detected
using e.g. 'grep -i lvm .config'

3) maybe doing a check for directories countaining 'group' in /dev would
be a usable idea...

Maybe it would be a good idea to put a /proc/lvmstat (similar to mdstat)
as default (not (un)selectable) into proc FS. This would solve most of our
problems.

Gergely

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] '/etc/init.d/lvm' script in debian package
  2000-12-21  8:37   ` [linux-lvm] '/etc/init.d/lvm' script in debian package Gergely Tamas
@ 2000-12-21  9:04     ` Patrick Caulfield
  2000-12-21  9:43       ` Gergely Tamas
  2000-12-21  9:44     ` Claudio Matsuoka
  1 sibling, 1 reply; 18+ messages in thread
From: Patrick Caulfield @ 2000-12-21  9:04 UTC (permalink / raw)
  To: linux-lvm; +Cc: Russell Coker

On Thu, Dec 21, 2000 at 09:37:58AM +0100, Gergely Tamas wrote:
> 
> A few ideas ...
> 1) if LVM is compiled into the kernel and /boot/System.map is reachable,
> than it could be detected using e.g. 'grep lvm System.map'
> 
> 2) if /usr/src/kernel/.config is reachable, than it could be detected
> using e.g. 'grep -i lvm .config'
> 
> 3) maybe doing a check for directories countaining 'group' in /dev would
> be a usable idea...

How about looking in /proc/devices for the lvm block & char devices ?

patrick

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] '/etc/init.d/lvm' script in debian package
  2000-12-21  9:04     ` Patrick Caulfield
@ 2000-12-21  9:43       ` Gergely Tamas
  2000-12-22 18:23         ` Russell Coker
  0 siblings, 1 reply; 18+ messages in thread
From: Gergely Tamas @ 2000-12-21  9:43 UTC (permalink / raw)
  To: Patrick Caulfield; +Cc: linux-lvm, Russell Coker

Hi!

> On Thu, Dec 21, 2000 at 09:37:58AM +0100, Gergely Tamas wrote:
> >
> > A few ideas ...
> > 1) if LVM is compiled into the kernel and /boot/System.map is reachable,
> > than it could be detected using e.g. 'grep lvm System.map'
> >
> > 2) if /usr/src/kernel/.config is reachable, than it could be detected
> > using e.g. 'grep -i lvm .config'
> >
> > 3) maybe doing a check for directories countaining 'group' in /dev would
> > be a usable idea...
>
> How about looking in /proc/devices for the lvm block & char devices ?

This is a good idea too.

But I noticed, that looking in /etc for lvmtab is usable too.

But your idea seems to be the most usable. It would be good to change the
init.d/lvm script to something using this.

Gergely

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] '/etc/init.d/lvm' script in debian package
  2000-12-21  8:37   ` [linux-lvm] '/etc/init.d/lvm' script in debian package Gergely Tamas
  2000-12-21  9:04     ` Patrick Caulfield
@ 2000-12-21  9:44     ` Claudio Matsuoka
  1 sibling, 0 replies; 18+ messages in thread
From: Claudio Matsuoka @ 2000-12-21  9:44 UTC (permalink / raw)
  To: linux-lvm

On Thu, 21 Dec 2000, Gergely Tamas wrote:

> A few ideas ...
> 1) if LVM is compiled into the kernel and /boot/System.map is reachable,
> than it could be detected using e.g. 'grep lvm System.map'
> 
> 2) if /usr/src/kernel/.config is reachable, than it could be detected
> using e.g. 'grep -i lvm .config'

Doesn't work. If you're booting different kernels, /boot/System.map
will be incorrect at some point, and you can build different kernels
without actually installing them.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] IOP selection scripts (was: '/etc/init.d/lvm' script in debian package)
  2000-12-21  0:34         ` Andreas Dilger
@ 2000-12-21 10:28           ` Claudio Matsuoka
  2000-12-21 22:06             ` Andreas Dilger
  0 siblings, 1 reply; 18+ messages in thread
From: Claudio Matsuoka @ 2000-12-21 10:28 UTC (permalink / raw)
  To: linux-lvm; +Cc: Gergely Tamas

On Wed, 20 Dec 2000, Andreas Dilger wrote:

> Claudio writes:
> > if [ "$util" = "lvm-wrapper" ]; then
> >     echo "$util: you don't want to call the wrapper directly" 1>&2
> >     exit -2
>            ^^ I don't think this is legal...
> > fi

Oops. C-ism, I think.


> Is there ever a reason why you would want to install this program as
> "lvm-wrapper" anywhere?

I'm installing it as /sbin/lvm-wrapper and symlinking all utilities to it
(seems better than using one wrapper per tool).


> Probably some simple checks for the existence of /lib/lvm-iop$iop and
> /lib/lvm-iop$iop/$util and printing a nice message would be helpful, like:
> 
> if [ ! -d $LIBLVM ]; then
> 	echo "$util: $LIBLVM not found.  Is $LVMPKG installed?" 1>&2
> 	exit 3
> fi
> exec $LIBLVM/$util "$@"	# this will print out a localized error message for us

Indeed, it's better. Thanks.

Regarding lvmiopversion, is it supposed to be statically linked? Otherwise,
it wouldn't know what liblvm link to, assuming that we have liblvm-iopX.so.


claudio

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] IOP selection scripts (was: '/etc/init.d/lvm' script in debian package)
  2000-12-21 10:28           ` Claudio Matsuoka
@ 2000-12-21 22:06             ` Andreas Dilger
  2000-12-21 23:06               ` Claudio Matsuoka
  0 siblings, 1 reply; 18+ messages in thread
From: Andreas Dilger @ 2000-12-21 22:06 UTC (permalink / raw)
  To: linux-lvm; +Cc: Gergely Tamas

Claudio writes:
> On Wed, 20 Dec 2000, Andreas Dilger wrote:
> > Is there ever a reason why you would want to install this program as
> > "lvm-wrapper" anywhere?
> 
> I'm installing it as /sbin/lvm-wrapper and symlinking all utilities to it
> (seems better than using one wrapper per tool).

Why not simply install it as one of the commands (e.g. vgscan) and make
hard links to it.  Hard links don't even take up inodes - only directory
entries.

> Regarding lvmiopversion, is it supposed to be statically linked? Otherwise,
> it wouldn't know what liblvm link to, assuming that we have liblvm-iopX.so.

Yes.  Basically, it is only a single ioctl call, so it is not dependent
on the LVM version at all.  Compiled in tools as:

gcc -I . -I lib -o lvmiopversion lvmiopversion.c lib/lvm_get_iop_version.c
	lib/lvm_check_special.c

and stripped it is only 4408 bytes on my system.

Cheers, Andreas
-- 
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] IOP selection scripts (was: '/etc/init.d/lvm' script in debian package)
  2000-12-21 22:06             ` Andreas Dilger
@ 2000-12-21 23:06               ` Claudio Matsuoka
  2000-12-22  1:38                 ` Andreas Dilger
  0 siblings, 1 reply; 18+ messages in thread
From: Claudio Matsuoka @ 2000-12-21 23:06 UTC (permalink / raw)
  To: linux-lvm; +Cc: Gergely Tamas

On Thu, 21 Dec 2000, Andreas Dilger wrote:

> Why not simply install it as one of the commands (e.g. vgscan) and make
> hard links to it.  Hard links don't even take up inodes - only directory
> entries.

Uhm.. yes, why not?


> gcc -I . -I lib -o lvmiopversion lvmiopversion.c lib/lvm_get_iop_version.c
> 	lib/lvm_check_special.c
> and stripped it is only 4408 bytes on my system.

Ok, lvm-base SRPM updated and uploaded to
http://distro.conectiva.com.br/experimental/.

Using hardlinks and lvmiopversion the script becomes:

#!/bin/sh
#
# This is a wrapper to call the appropriate LVM userspace tools based
# on the IOP version in use.
#
# 20001221  Claudio Matsuoka <clausio@conectiva.com>
# - using lvmiopversion to get the IOP version
#
# 20001220  Andreas Dilger <adilger@turbolinux.com>
# - fixed return values
# - better error messages
#
# 20001217  Claudio Matsuoka <claudio@conectiva.com>
# - first version

util=`basename $0`
iopver=/sbin/lvmiopversion

if [ ! -x $iopver ]; then
    echo "$util: $iopver not found (can't determine IOP version)" 1>&2
    exit 1
fi

IOP=`/sbin/lvmiopversion`
liblvm=/lib/lvm-iop${IOP}
lvmpkg=lvm-iop${IOP}

if [ ! -d $liblvm ]; then
    echo "$util: $liblvm not found.  Is $lvmpkg installed?" 1>&2
    exit 3
fi

exec $liblvm/$util "$@" # this will print out a localized error message for us

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] IOP selection scripts (was: '/etc/init.d/lvm' script in debian package)
  2000-12-21 23:06               ` Claudio Matsuoka
@ 2000-12-22  1:38                 ` Andreas Dilger
  2000-12-22 10:13                   ` Claudio Matsuoka
  0 siblings, 1 reply; 18+ messages in thread
From: Andreas Dilger @ 2000-12-22  1:38 UTC (permalink / raw)
  To: linux-lvm; +Cc: Gergely Tamas

Claudio writes:
> On Thu, 21 Dec 2000, Andreas Dilger wrote:
> > Why not simply install it as one of the commands (e.g. vgscan) and make
> > hard links to it.  Hard links don't even take up inodes - only directory
> > entries.
> 
> Uhm.. yes, why not?

If you have a symlink with a short path (e.g. vgscan -> lvm-wrapper)
the string "lvm-wrapper" gets stored directly in the inode (for ext2 at
least), and is called a "fast symlink".  For longer targets (> 56 bytes I
think), the inode allocates a filesystem block to store the new string.
There is a directory entry for the symlink (in this case "vgscan")
which points to the symlink inode.

If you have a hard link to a file, what happens is that there is a
directory entry created (same as with any file), but it only points to the
inode of the existing file, and the refcount on the inode is increased.
That's why hard links always have the same owner/permissions/contents -
because it is reall only one "file" (inode) and just multiple directory
entries pointing to it.  This is also the reason why you can't have hard
links across filesystem boundaries.

Cheers, Andreas
-- 
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] IOP selection scripts (was: '/etc/init.d/lvm' script in debian package)
  2000-12-22  1:38                 ` Andreas Dilger
@ 2000-12-22 10:13                   ` Claudio Matsuoka
  2000-12-22 18:12                     ` [linux-lvm] IOP selection scripts Andreas Dilger
  0 siblings, 1 reply; 18+ messages in thread
From: Claudio Matsuoka @ 2000-12-22 10:13 UTC (permalink / raw)
  To: linux-lvm; +Cc: Gergely Tamas

On Thu, 21 Dec 2000, Andreas Dilger wrote:

> Claudio writes:
> > On Thu, 21 Dec 2000, Andreas Dilger wrote:
> > > Why not simply install it as one of the commands (e.g. vgscan) and make
> > > hard links to it.  Hard links don't even take up inodes - only directory
> > > entries.
> > 
> > Uhm.. yes, why not?
> 
> If you have a symlink with a short path (e.g. vgscan -> lvm-wrapper)
> the string "lvm-wrapper" gets stored directly in the inode (for ext2 at
> least), and is called a "fast symlink".  For longer targets (> 56 bytes I
> think), the inode allocates a filesystem block to store the new string.
> There is a directory entry for the symlink (in this case "vgscan")
> which points to the symlink inode.

Yes, I know, I was just wondering why I didn't use hardlinks at the first
time ;) I believe the size limit is 60 bytes, IIRC.

BTW -- I'm using 0.9's manpages in lvm-base. Is it safe to assume that 
the tools interfaces won't change in future releases?

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] IOP selection scripts
  2000-12-22 10:13                   ` Claudio Matsuoka
@ 2000-12-22 18:12                     ` Andreas Dilger
  0 siblings, 0 replies; 18+ messages in thread
From: Andreas Dilger @ 2000-12-22 18:12 UTC (permalink / raw)
  To: linux-lvm; +Cc: Gergely Tamas

Claudio writes:
> BTW -- I'm using 0.9's manpages in lvm-base. Is it safe to assume that 
> the tools interfaces won't change in future releases?

Probably not much, but if they do you can simply update the common man
pages to say "this feature added with LVM 10" or whatever.

Cheers, Andreas
-- 
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] '/etc/init.d/lvm' script in debian package
  2000-12-21  9:43       ` Gergely Tamas
@ 2000-12-22 18:23         ` Russell Coker
  2000-12-24  5:12           ` Andreas Dilger
  0 siblings, 1 reply; 18+ messages in thread
From: Russell Coker @ 2000-12-22 18:23 UTC (permalink / raw)
  To: linux-lvm

Here's my current effort:

#!/bin/sh
#
# lvm		This script handles the LVM startup/shutdown
#		so that LVMs are properly configured and available.
#

if [ "0" = `grep -c lvm /proc/devices` ]; then
  exit 0
fi
[ -f /etc/lvmtab ] || exit 0
[ -x /sbin/vgscan ] || exit 0

case "$1" in
	start)
		echo "Setting up LVM Volume Groups..."
		#/sbin/vgscan
		/sbin/vgchange -a y
		;;
	
	stop)
		echo "Shutting down LVM Volume Groups... "
		/sbin/vgchange -a n
		;;

	restart|force-reload)
		echo "Does not make sense to restart."
		exit 1
		;;
	*)
		echo "Usage: lvm {start|stop}" >&2
		exit 1
		;;
esac


-- 
http://www.coker.com.au/bonnie++/     Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/       Postal SMTP/POP benchmark
http://www.coker.com.au/projects.html Projects I am working on
http://www.coker.com.au/~russell/     My home page

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [linux-lvm] '/etc/init.d/lvm' script in debian package
  2000-12-22 18:23         ` Russell Coker
@ 2000-12-24  5:12           ` Andreas Dilger
  0 siblings, 0 replies; 18+ messages in thread
From: Andreas Dilger @ 2000-12-24  5:12 UTC (permalink / raw)
  To: linux-lvm

Russel Coker writes:
> #!/bin/sh
> #
> # lvm		This script handles the LVM startup/shutdown
> #		so that LVMs are properly configured and available.
> #
> 
> if [ "0" = `grep -c lvm /proc/devices` ]; then
>   exit 0
> fi
> [ -f /etc/lvmtab ] || exit 0
> [ -x /sbin/vgscan ] || exit 0
This         ^^^^^^ should probably be "vgchange" looking at your script.

> case "$1" in
> 	start)
> 		echo "Setting up LVM Volume Groups..."
> 		#/sbin/vgscan
> 		/sbin/vgchange -a y
> 		;;
> 	
> 	stop)
> 		echo "Shutting down LVM Volume Groups... "
> 		/sbin/vgchange -a n
> 		;;

Cheers, Andreas
-- 
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2000-12-24  5:12 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-12-20  9:29 [linux-lvm] '/etc/init.d/lvm' script in debian package Gergely Tamas
2000-12-20 21:40 ` Russell Coker
2000-12-20 22:21   ` Claudio Matsuoka
2000-12-20 23:08     ` Andreas Dilger
2000-12-20 23:29       ` [linux-lvm] IOP selection scripts (was: '/etc/init.d/lvm' script in debian package) Claudio Matsuoka
2000-12-21  0:34         ` Andreas Dilger
2000-12-21 10:28           ` Claudio Matsuoka
2000-12-21 22:06             ` Andreas Dilger
2000-12-21 23:06               ` Claudio Matsuoka
2000-12-22  1:38                 ` Andreas Dilger
2000-12-22 10:13                   ` Claudio Matsuoka
2000-12-22 18:12                     ` [linux-lvm] IOP selection scripts Andreas Dilger
2000-12-21  8:37   ` [linux-lvm] '/etc/init.d/lvm' script in debian package Gergely Tamas
2000-12-21  9:04     ` Patrick Caulfield
2000-12-21  9:43       ` Gergely Tamas
2000-12-22 18:23         ` Russell Coker
2000-12-24  5:12           ` Andreas Dilger
2000-12-21  9:44     ` Claudio Matsuoka

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.