summaryrefslogtreecommitdiff
path: root/scripts/local-top/lvm
blob: 4cf48ad0ef1356996e16ad783fad3eee772d1edc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh

PREREQ="mdadm mdrun lvm2"

prereqs()
{
	echo "$PREREQ"
}

case $1 in
# get pre-requisites
prereqs)
	prereqs
	exit 0
	;;
esac

activate_vg()
{
	local vg="$1"

	# Make sure that we have a non-empty argument
	if [ -z "${vg}" ]; then
		return 1
	fi

	# Take care of lilo boot arg, risky activating of all vg
	case $vg in
	fe[0-9]*)
		vgchange -ay
		exit 0
		;;
	# FIXME: check major
	/dev/root)
		vgchange -ay
		exit 0
		;;
	esac

	# Make sure that we have a d-m path
	vg=${vg#/dev/mapper/}
	if [ "$vg" = "$1" ]; then
		return 1
	fi

	# Make sure that the device includes at least one dash
	if [ "$(echo -n "$vg" | tr -d -)" = "$vg" ]; then
		return 1
	fi

	# Split volume group from logical volume.
	vg=$(echo ${vg} | sed -e 's#\(.*\)\([^-]\)-[^-].*#\1\2#')
	# Reduce padded --'s to -'s
	vg=$(echo ${vg} | sed -e 's#--#-#g')

	vgchange -ay ${vg}
}

if [ -e /scripts/local-top/lvm2 ]; then
	exit 0
fi

if [ ! -e /sbin/vgchange ]; then
	exit 0
fi

modprobe dm-mod
modprobe dm-snapshot
modprobe dm-mirror

activate_vg "$ROOT"
activate_vg "$resume"

exit 0