kernel - support dummy reallocblks in devfs
[dragonfly.git] / etc / rc.d / lvm
blob12f2c9801b4b0aa3d117cb4213818fc3c89133aa
1 #!/bin/sh
3 # $NetBSD: lvm,v 1.4 2009/04/13 18:48:14 haad Exp $
6 # PROVIDE: lvm
7 # REQUIRE: udevd_early
8 # BEFORE: mountcritlocal cryptdisks
10 $_rc_subr_loaded . /etc/rc.subr
12 name="lvm"
13 rcvar=$name
14 start_cmd="lvm_start"
15 stop_cmd="lvm_stop"
17 ifs_restore="$IFS";
19 lvm_start()
21 if [ -x /sbin/dmsetup ]; then
22 /sbin/dmsetup version >/dev/null
23 if [ $? -ne 0 ]; then
24 warn "Device-mapper not present in kernel"
25 return 1;
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
42 lvm_stop()
44 if [ -x /sbin/dmsetup ]; then
45 /sbin/dmsetup version >/dev/null
46 if [ $? -ne 0 ]; then
47 warn "Device-mapper not present in kernel"
48 return 1;
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 \
62 -o lv_attr $lv)
63 case $LV_IS_ACTIVE in
64 *a*)
65 echo " Shutting Down logical volume: ${lv}"
66 /sbin/lvm lvchange -an --ignorelockingfailure \
67 -P ${lv} >/dev/null
69 esac
70 done
72 for vg in ${VOLUME_GROUPS}; do
73 # Set IFS to field separator
74 IFS=":"
75 set -- $(/sbin/lvm vgdisplay -cA ${vg} 2>/dev/null)
76 # The seventh parameter is number of opened LVs in a Volume Group
77 VG_HAS_ACTIVE_LV=$7
78 IFS="$ifs_restore";
80 if [ "${VG_HAS_ACTIVE_LV}" = 0 ]; then
81 echo " Shutting Down volume group: ${vg}"
82 /sbin/lvm vgchange -an --ignorelockingfailure \
83 -P ${vg} >/dev/null
85 done
89 load_rc_config $name
90 run_rc_command "$1"