head	1.8;
access;
symbols
	netbsd-11-0-RC4:1.8
	netbsd-11-0-RC3:1.8
	netbsd-11-0-RC2:1.8
	netbsd-11-0-RC1:1.8
	perseant-exfatfs-base-20250801:1.8
	netbsd-11:1.8.0.6
	netbsd-11-base:1.8
	netbsd-10-1-RELEASE:1.8
	perseant-exfatfs-base-20240630:1.8
	perseant-exfatfs:1.8.0.4
	perseant-exfatfs-base:1.8
	netbsd-8-3-RELEASE:1.5
	netbsd-9-4-RELEASE:1.5
	netbsd-10-0-RELEASE:1.8
	netbsd-10-0-RC6:1.8
	netbsd-10-0-RC5:1.8
	netbsd-10-0-RC4:1.8
	netbsd-10-0-RC3:1.8
	netbsd-10-0-RC2:1.8
	netbsd-10-0-RC1:1.8
	netbsd-10:1.8.0.2
	netbsd-10-base:1.8
	netbsd-9-3-RELEASE:1.5
	cjep_sun2x-base1:1.6
	cjep_sun2x:1.6.0.4
	cjep_sun2x-base:1.6
	cjep_staticlib_x-base1:1.6
	netbsd-9-2-RELEASE:1.5
	cjep_staticlib_x:1.6.0.2
	cjep_staticlib_x-base:1.6
	netbsd-9-1-RELEASE:1.5
	phil-wifi-20200421:1.5
	phil-wifi-20200411:1.5
	is-mlppp:1.5.0.52
	is-mlppp-base:1.5
	phil-wifi-20200406:1.5
	netbsd-8-2-RELEASE:1.5
	netbsd-9-0-RELEASE:1.5
	netbsd-9-0-RC2:1.5
	netbsd-9-0-RC1:1.5
	phil-wifi-20191119:1.5
	netbsd-9:1.5.0.50
	netbsd-9-base:1.5
	phil-wifi-20190609:1.5
	netbsd-8-1-RELEASE:1.5
	netbsd-8-1-RC1:1.5
	pgoyette-compat-merge-20190127:1.5
	pgoyette-compat-20190127:1.5
	pgoyette-compat-20190118:1.5
	pgoyette-compat-1226:1.5
	pgoyette-compat-1126:1.5
	pgoyette-compat-1020:1.5
	pgoyette-compat-0930:1.5
	pgoyette-compat-0906:1.5
	netbsd-7-2-RELEASE:1.5
	pgoyette-compat-0728:1.5
	netbsd-8-0-RELEASE:1.5
	phil-wifi:1.5.0.48
	phil-wifi-base:1.5
	pgoyette-compat-0625:1.5
	netbsd-8-0-RC2:1.5
	pgoyette-compat-0521:1.5
	pgoyette-compat-0502:1.5
	pgoyette-compat-0422:1.5
	netbsd-8-0-RC1:1.5
	pgoyette-compat-0415:1.5
	pgoyette-compat-0407:1.5
	pgoyette-compat-0330:1.5
	pgoyette-compat-0322:1.5
	pgoyette-compat-0315:1.5
	netbsd-7-1-2-RELEASE:1.5
	pgoyette-compat:1.5.0.46
	pgoyette-compat-base:1.5
	netbsd-7-1-1-RELEASE:1.5
	matt-nb8-mediatek:1.5.0.44
	matt-nb8-mediatek-base:1.5
	perseant-stdc-iso10646:1.5.0.42
	perseant-stdc-iso10646-base:1.5
	netbsd-8:1.5.0.40
	netbsd-8-base:1.5
	prg-localcount2-base3:1.5
	prg-localcount2-base2:1.5
	prg-localcount2-base1:1.5
	prg-localcount2:1.5.0.38
	prg-localcount2-base:1.5
	pgoyette-localcount-20170426:1.5
	bouyer-socketcan-base1:1.5
	pgoyette-localcount-20170320:1.5
	netbsd-7-1:1.5.0.36
	netbsd-7-1-RELEASE:1.5
	netbsd-7-1-RC2:1.5
	netbsd-7-nhusb-base-20170116:1.5
	bouyer-socketcan:1.5.0.34
	bouyer-socketcan-base:1.5
	pgoyette-localcount-20170107:1.5
	netbsd-7-1-RC1:1.5
	pgoyette-localcount-20161104:1.5
	netbsd-7-0-2-RELEASE:1.5
	localcount-20160914:1.5
	netbsd-7-nhusb:1.5.0.32
	netbsd-7-nhusb-base:1.5
	pgoyette-localcount-20160806:1.5
	pgoyette-localcount-20160726:1.5
	pgoyette-localcount:1.5.0.30
	pgoyette-localcount-base:1.5
	netbsd-7-0-1-RELEASE:1.5
	netbsd-7-0:1.5.0.28
	netbsd-7-0-RELEASE:1.5
	netbsd-7-0-RC3:1.5
	netbsd-7-0-RC2:1.5
	netbsd-7-0-RC1:1.5
	netbsd-6-0-6-RELEASE:1.5
	netbsd-6-1-5-RELEASE:1.5
	netbsd-7:1.5.0.26
	netbsd-7-base:1.5
	yamt-pagecache-base9:1.5
	yamt-pagecache-tag8:1.5
	netbsd-6-1-4-RELEASE:1.5
	netbsd-6-0-5-RELEASE:1.5
	tls-earlyentropy:1.5.0.24
	tls-earlyentropy-base:1.5
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.5
	riastradh-drm2-base3:1.5
	netbsd-6-1-3-RELEASE:1.5
	netbsd-6-0-4-RELEASE:1.5
	netbsd-6-1-2-RELEASE:1.5
	netbsd-6-0-3-RELEASE:1.5
	netbsd-6-1-1-RELEASE:1.5
	riastradh-drm2-base2:1.5
	riastradh-drm2-base1:1.5
	riastradh-drm2:1.5.0.16
	riastradh-drm2-base:1.5
	netbsd-6-1:1.5.0.22
	netbsd-6-0-2-RELEASE:1.5
	netbsd-6-1-RELEASE:1.5
	khorben-n900:1.5.0.20
	netbsd-6-1-RC4:1.5
	netbsd-6-1-RC3:1.5
	agc-symver:1.5.0.18
	agc-symver-base:1.5
	netbsd-6-1-RC2:1.5
	netbsd-6-1-RC1:1.5
	yamt-pagecache-base8:1.5
	netbsd-6-0-1-RELEASE:1.5
	yamt-pagecache-base7:1.5
	matt-nb6-plus-nbase:1.5
	yamt-pagecache-base6:1.5
	netbsd-6-0:1.5.0.14
	netbsd-6-0-RELEASE:1.5
	netbsd-6-0-RC2:1.5
	tls-maxphys:1.5.0.12
	tls-maxphys-base:1.5
	matt-nb6-plus:1.5.0.10
	matt-nb6-plus-base:1.5
	netbsd-6-0-RC1:1.5
	yamt-pagecache-base5:1.5
	yamt-pagecache-base4:1.5
	netbsd-6:1.5.0.8
	netbsd-6-base:1.5
	yamt-pagecache-base3:1.5
	yamt-pagecache-base2:1.5
	yamt-pagecache:1.5.0.6
	yamt-pagecache-base:1.5
	cherry-xenmp:1.5.0.4
	cherry-xenmp-base:1.5
	bouyer-quota2-nbase:1.5
	bouyer-quota2:1.5.0.2
	bouyer-quota2-base:1.5
	matt-mips64-premerge-20101231:1.5
	matt-premerge-20091211:1.5
	jym-xensuspend-nbase:1.5
	jym-xensuspend:1.2.0.2
	jym-xensuspend-base:1.5
	mjf-devfs2:1.1.0.2
	mjf-devfs2-base2:1.1;
locks; strict;
comment	@# @;


1.8
date	2021.08.21.23.00.30;	author andvar;	state Exp;
branches;
next	1.7;
commitid	2FURiQpIj3RAmT5D;

1.7
date	2021.08.03.05.15.20;	author mlelstv;	state Exp;
branches;
next	1.6;
commitid	pSecJrkajnyj5u3D;

1.6
date	2020.07.04.06.24.53;	author skrll;	state Exp;
branches;
next	1.5;
commitid	hRPK9EPvuxkZaJeC;

1.5
date	2009.04.21.16.08.57;	author joerg;	state Exp;
branches;
next	1.4;

1.4
date	2009.04.13.18.48.14;	author haad;	state Exp;
branches;
next	1.3;

1.3
date	2009.03.05.10.35.43;	author haad;	state Exp;
branches;
next	1.2;

1.2
date	2009.01.20.00.40.59;	author haad;	state Exp;
branches
	1.2.2.1;
next	1.1;

1.1
date	2009.01.14.22.07.55;	author haad;	state Exp;
branches
	1.1.2.1;
next	;

1.2.2.1
date	2009.05.13.19.18.03;	author jym;	state Exp;
branches;
next	;

1.1.2.1
date	2009.01.14.22.07.55;	author mjf;	state dead;
branches;
next	1.1.2.2;

1.1.2.2
date	2009.01.17.20.43.44;	author mjf;	state Exp;
branches;
next	;


desc
@@


1.8
log
@fix mainly same typos as in my previous commit but outside sys/dev/dm.
@
text
@#!/bin/sh
#
# $NetBSD: lvm,v 1.7 2021/08/03 05:15:20 mlelstv Exp $
#

# PROVIDE: lvm
# REQUIRE: root devpubd
# BEFORE:  DISKS

$_rc_subr_loaded . /etc/rc.subr

name="lvm"
rcvar=$name
start_cmd="lvm_start"
stop_cmd="lvm_stop"

ifs_restore="$IFS";

lvm_start()
{
	if [ -x /sbin/dmsetup ]; then
		/sbin/dmsetup version >/dev/null
		if [ $? -ne 0 ]; then
			warn "Device-mapper not present in kernel"
			return 1;
		fi
	fi

	if [ -x /sbin/lvm ]; then
		echo "Configuring lvm devices."

		# Scan for all available VG's
		/sbin/lvm vgscan --mknodes --ignorelockingfailure >/dev/null

		# Activate all LV's and create appropriate nodes in /dev
		/sbin/lvm vgchange --ignorelockingfailure -a y >/dev/null
		LV_LIST=$(/sbin/lvm vgdisplay -C -o vg_name --noheadings 2>/dev/null)
		echo " Activated Volume Groups:" $LV_LIST
	fi
}

lvm_stop()
{
	if [ -x /sbin/dmsetup ]; then
		/sbin/dmsetup version >/dev/null
		if [ $? -ne 0 ]; then
			warn "Device-mapper not present in kernel"
			return 1;
		fi
	fi

	if [ -x /sbin/lvm ]; then
		echo "Unconfiguring lvm devices."

		LOGICAL_VOLUMES=$(/sbin/lvm lvdisplay -C -o vg_name,lv_name \
			-O vg_name --separator \/ --noheadings 2>/dev/null)
		VOLUME_GROUPS=$(/sbin/lvm vgdisplay -C -o vg_name \
			--separator " " --noheadings 2>/dev/null)

		for lv in ${LOGICAL_VOLUMES}; do
			LV_IS_ACTIVE=$(/sbin/lvm lvdisplay -C --noheadings \
				-o lv_attr $lv)
			case $LV_IS_ACTIVE in
			*a*)
				echo "  Shutting Down logical volume: ${lv}"
				/sbin/lvm lvchange -an --ignorelockingfailure \
					-P ${lv} >/dev/null
				;;
			esac
		done

		for vg in ${VOLUME_GROUPS}; do
			# Set IFS to field separator
			IFS=":"
			set -- $(/sbin/lvm vgdisplay -cA ${vg} 2>/dev/null)
			# The seventh parameter is number of opened LVs in a Volume Group
			VG_HAS_ACTIVE_LV=$7
			IFS="$ifs_restore";

			if [ "${VG_HAS_ACTIVE_LV}" = 0 ]; then
				echo "  Shutting Down volume group: ${vg}"
				/sbin/lvm vgchange -an --ignorelockingfailure \
					-P ${vg} >/dev/null
			fi
		done
	fi
}

load_rc_config $name
run_rc_command "$1"
@


1.7
log
@Reverse devpubd dependeny to avoid dangling reference to zfs which is
an optional part of the build.
@
text
@d3 1
a3 1
# $NetBSD: lvm,v 1.6 2020/07/04 06:24:53 skrll Exp $
d35 1
a35 1
		# Activate all LV's and create apropriate nodes in /dev
@


1.6
log
@Trailing whitespace
@
text
@d3 1
a3 1
# $NetBSD: lvm,v 1.5 2009/04/21 16:08:57 joerg Exp $
d7 1
a7 1
# REQUIRE: root
@


1.5
log
@Split fsck during boot into two phases. Check the root file system
first, mount root and run the various disk providers. Add swap and
check the remaining file systems after that.
This breaks the dependency cycle for lvm, which needs writeable /dev.
Depend on rndctl in cgd.
@
text
@d3 1
a3 1
# $NetBSD: lvm,v 1.4 2009/04/13 18:48:14 haad Exp $
d23 1
a23 1
		if [ $? -ne 0 ]; then 
d34 1
a34 1
	
d46 1
a46 1
		if [ $? -ne 0 ]; then 
d54 1
a54 1
	
d71 1
a71 1
	
d79 1
a79 1
    
@


1.4
log
@We need writable /dev to get lvm working otherwise lvm devices can't be created.
@
text
@d3 1
a3 1
# $NetBSD: lvm,v 1.3 2009/03/05 10:35:43 haad Exp $
d6 1
a6 1
# PROVIDE: disks
d8 1
@


1.3
log
@When setting LV_LIST variable do not use $LV_LIST.
@
text
@d3 1
a3 1
# $NetBSD: lvm,v 1.2 2009/01/20 00:40:59 haad Exp $
d7 1
@


1.2
log
@Rework lvm rc.d script. Check active flag for selected LV not for the first
one. Remove dmtest function.

Most changes are based on feedback from salo@@.
@
text
@d3 1
a3 1
# $NetBSD: lvm,v 1.1 2009/01/14 22:07:55 haad Exp $
d35 1
a35 1
		$LV_LIST = $(/sbin/lvm vgdisplay -C -o vg_name --noheadings 2>/dev/null)
@


1.2.2.1
log
@Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
@
text
@d3 1
a3 1
# $NetBSD: lvm,v 1.5 2009/04/21 16:08:57 joerg Exp $
d6 1
a6 3
# PROVIDE: lvm
# REQUIRE: root
# BEFORE:  DISKS
d35 1
a35 1
		LV_LIST=$(/sbin/lvm vgdisplay -C -o vg_name --noheadings 2>/dev/null)
@


1.1
log
@Add lvm rc script for starting LV's during boot. starting lvm is turn off
by default, until MKLVM is enabled by default. This script can be used
without /usr/bin.
@
text
@d3 1
a3 1
# $NetBSD$
d15 1
a15 11
dm_test()
{
    if [ -x /sbin/dmsetup ]; then
	/sbin/dmsetup version >/dev/null
	
	if [ $? -ne 0 ]; then 
	    echo "Device-mapper not present in kernel"
	    exit;
	fi
    fi
}
d19 7
a25 1
        dm_test;
d27 2
a28 2
        if [ -x /sbin/lvm ]; then
                echo "Configuring lvm devices."
d31 2
a32 2
	        /sbin/lvm vgscan --mknodes --ignorelockingfailure >/dev/null
		
d35 3
a37 3
		
		echo "   Activated Volume Groups:"`/sbin/lvm vgdisplay -C -o vg_name --noheadings 2>/dev/null`
        fi
d42 7
a48 1
      dm_test;
d50 18
a67 17
      if [ -x /sbin/lvm ]; then
                echo "Deconfiguring lvm devices."

		LOGICAL_VOLUMES=`/sbin/lvm lvdisplay -C -o vg_name,lv_name -O vg_name --separator \/ --noheadings 2>/dev/null`
		VOLUME_GROUPS=`/sbin/lvm vgdisplay -C -o vg_name --separator " " --noheadings 2>/dev/null`

		for x in ${LOGICAL_VOLUMES}; do
		    IFS=":"
		    set -- `/sbin/lvm lvdisplay -c`
		    # The fourth argument in the column LV display is inkernel flag
		    LV_IS_ACTIVE=$4;
		    unset IFS

		    if [ ${LV_IS_ACTIVE} -eq 1 ]; then
			echo "  Shutting Down logical volume: ${x} "
			/sbin/lvm lvchange -an --ignorelockingfailure -P ${x} >/dev/null
		    fi
d69 14
a82 15

		for x in ${VOLUME_GROUPS}; do
		    echo "VG -> |${x}|"
		    # Set IFS to field separator
		    IFS=":"
		    set -- `/sbin/lvm vgdisplay -cA ${x} 2>/dev/null`
		    # The seventh parameter is number of opened LVs in a Volume Group
		    VG_HAS_ACTIVE_LV=$7
		    unset IFS

		    if [ "${VG_HAS_ACTIVE_LV}" = 0 ]
		    then
			echo "  Shutting Down volume group: ${x}"
			/sbin/lvm vgchange -an --ignorelockingfailure -P ${x} >/dev/null
		    fi
d84 1
a84 1
        fi
a88 1

@


1.1.2.1
log
@file lvm was added on branch mjf-devfs2 on 2009-01-17 20:43:44 +0000
@
text
@d1 87
@


1.1.2.2
log
@Sync with HEAD.
@
text
@a0 87
#!/bin/sh
#
# $NetBSD$
#

# PROVIDE: disks

$_rc_subr_loaded . /etc/rc.subr

name="lvm"
rcvar=$name
start_cmd="lvm_start"
stop_cmd="lvm_stop"

dm_test()
{
    if [ -x /sbin/dmsetup ]; then
	/sbin/dmsetup version >/dev/null
	
	if [ $? -ne 0 ]; then 
	    echo "Device-mapper not present in kernel"
	    exit;
	fi
    fi
}

lvm_start()
{
        dm_test;

        if [ -x /sbin/lvm ]; then
                echo "Configuring lvm devices."

		# Scan for all available VG's
	        /sbin/lvm vgscan --mknodes --ignorelockingfailure >/dev/null
		
		# Activate all LV's and create apropriate nodes in /dev
		/sbin/lvm vgchange --ignorelockingfailure -a y >/dev/null
		
		echo "   Activated Volume Groups:"`/sbin/lvm vgdisplay -C -o vg_name --noheadings 2>/dev/null`
        fi
}

lvm_stop()
{
      dm_test;

      if [ -x /sbin/lvm ]; then
                echo "Deconfiguring lvm devices."

		LOGICAL_VOLUMES=`/sbin/lvm lvdisplay -C -o vg_name,lv_name -O vg_name --separator \/ --noheadings 2>/dev/null`
		VOLUME_GROUPS=`/sbin/lvm vgdisplay -C -o vg_name --separator " " --noheadings 2>/dev/null`

		for x in ${LOGICAL_VOLUMES}; do
		    IFS=":"
		    set -- `/sbin/lvm lvdisplay -c`
		    # The fourth argument in the column LV display is inkernel flag
		    LV_IS_ACTIVE=$4;
		    unset IFS

		    if [ ${LV_IS_ACTIVE} -eq 1 ]; then
			echo "  Shutting Down logical volume: ${x} "
			/sbin/lvm lvchange -an --ignorelockingfailure -P ${x} >/dev/null
		    fi
		done

		for x in ${VOLUME_GROUPS}; do
		    echo "VG -> |${x}|"
		    # Set IFS to field separator
		    IFS=":"
		    set -- `/sbin/lvm vgdisplay -cA ${x} 2>/dev/null`
		    # The seventh parameter is number of opened LVs in a Volume Group
		    VG_HAS_ACTIVE_LV=$7
		    unset IFS

		    if [ "${VG_HAS_ACTIVE_LV}" = 0 ]
		    then
			echo "  Shutting Down volume group: ${x}"
			/sbin/lvm vgchange -an --ignorelockingfailure -P ${x} >/dev/null
		    fi
		done
        fi
}

load_rc_config $name
run_rc_command "$1"

@


