3 # $NetBSD: lvm,v 1.4 2009/04/13 18:48:14 haad Exp $
8 # BEFORE: mountcritlocal cryptdisks
10 $_rc_subr_loaded .
/etc
/rc.subr
21 if [ -x /sbin
/dmsetup
]; then
22 /sbin
/dmsetup version
>/dev
/null
24 warn
"Device-mapper not present in kernel"
29 if [ -x /sbin
/lvm
]; then
30 echo "Configuring lvm devices."
32 # Scan for all available VG's
33 /sbin
/lvm vgscan
--mknodes --ignorelockingfailure >/dev
/null
35 # Activate all LV's and create appropriate nodes in /dev
36 /sbin
/lvm vgchange
--ignorelockingfailure -a y
>/dev
/null
37 LV_LIST
=$
(/sbin
/lvm vgdisplay
-C -o vg_name
--noheadings 2>/dev
/null
)
38 echo " Activated Volume Groups:" $LV_LIST
44 if [ -x /sbin
/dmsetup
]; then
45 /sbin
/dmsetup version
>/dev
/null
47 warn
"Device-mapper not present in kernel"
52 if [ -x /sbin
/lvm
]; then
53 echo "Unconfiguring lvm devices."
55 LOGICAL_VOLUMES
=$
(/sbin
/lvm lvdisplay
-C -o vg_name
,lv_name \
56 -O vg_name
--separator \
/ --noheadings 2>/dev
/null
)
57 VOLUME_GROUPS
=$
(/sbin
/lvm vgdisplay
-C -o vg_name \
58 --separator " " --noheadings 2>/dev
/null
)
60 for lv
in ${LOGICAL_VOLUMES}; do
61 LV_IS_ACTIVE
=$
(/sbin
/lvm lvdisplay
-C --noheadings \
65 echo " Shutting Down logical volume: ${lv}"
66 /sbin
/lvm lvchange
-an --ignorelockingfailure \
72 for vg
in ${VOLUME_GROUPS}; do
73 # Set IFS to field separator
75 set -- $
(/sbin
/lvm vgdisplay
-cA ${vg} 2>/dev
/null
)
76 # The seventh parameter is number of opened LVs in a Volume Group
80 if [ "${VG_HAS_ACTIVE_LV}" = 0 ]; then
81 echo " Shutting Down volume group: ${vg}"
82 /sbin
/lvm vgchange
-an --ignorelockingfailure \