dhcpcd: update README.DRAGONFLY
[dragonfly.git] / etc / rc.d / lvm
blobbb678e2c7cf10796b39c0e63a313c2c7c6a9f7b6
1 #!/bin/sh
3 # $NetBSD: lvm,v 1.4 2009/04/13 18:48:14 haad Exp $
6 # PROVIDE: lvm
7 # REQUIRE: udevd_early
9 . /etc/rc.subr
11 name="lvm"
12 rcvar=$name
13 start_cmd="lvm_start"
14 stop_cmd="lvm_stop"
16 ifs_restore="$IFS"
18 lvm_start()
20 if [ -x /sbin/dmsetup ]; then
21 /sbin/dmsetup version >/dev/null
22 if [ $? -ne 0 ]; then
23 warn "Device-mapper not present in kernel"
24 return 1;
28 if [ -x /sbin/lvm ]; then
29 echo "Configuring lvm devices."
31 # Scan for all available VG's
32 /sbin/lvm vgscan --mknodes --ignorelockingfailure >/dev/null
34 # Activate all LV's and create appropriate nodes in /dev
35 /sbin/lvm vgchange --ignorelockingfailure -a y >/dev/null
36 LV_LIST=$(/sbin/lvm vgdisplay -C -o vg_name --noheadings 2>/dev/null)
37 echo " Activated Volume Groups:" $LV_LIST
41 lvm_stop()
43 if [ -x /sbin/dmsetup ]; then
44 /sbin/dmsetup version >/dev/null
45 if [ $? -ne 0 ]; then
46 warn "Device-mapper not present in kernel"
47 return 1;
51 if [ -x /sbin/lvm ]; then
52 echo "Unconfiguring lvm devices."
54 LOGICAL_VOLUMES=$(/sbin/lvm lvdisplay -C -o vg_name,lv_name \
55 -O vg_name --separator \/ --noheadings 2>/dev/null)
56 VOLUME_GROUPS=$(/sbin/lvm vgdisplay -C -o vg_name \
57 --separator " " --noheadings 2>/dev/null)
59 for lv in ${LOGICAL_VOLUMES}; do
60 LV_IS_ACTIVE=$(/sbin/lvm lvdisplay -C --noheadings \
61 -o lv_attr $lv)
62 case $LV_IS_ACTIVE in
63 *a*)
64 echo " Shutting Down logical volume: ${lv}"
65 /sbin/lvm lvchange -an --ignorelockingfailure \
66 -P ${lv} >/dev/null
68 esac
69 done
71 for vg in ${VOLUME_GROUPS}; do
72 # Set IFS to field separator
73 IFS=":"
74 set -- $(/sbin/lvm vgdisplay -cA ${vg} 2>/dev/null)
75 # The seventh parameter is number of opened LVs in a Volume Group
76 VG_HAS_ACTIVE_LV=$7
77 IFS="$ifs_restore";
79 if [ "${VG_HAS_ACTIVE_LV}" = 0 ]; then
80 echo " Shutting Down volume group: ${vg}"
81 /sbin/lvm vgchange -an --ignorelockingfailure \
82 -P ${vg} >/dev/null
84 done
88 load_rc_config $name
89 run_rc_command "$1"