2015-02-27 00:58:55 +00:00
|
|
|
#!/sbin/runscript
|
2015-07-31 00:55:23 +00:00
|
|
|
# Copyright 1999-2014 Gentoo Foundation
|
2015-02-27 00:58:55 +00:00
|
|
|
# Distributed under the terms of the GNU General Public License v2
|
2015-07-31 00:55:23 +00:00
|
|
|
# $Header: /var/cvsroot/gentoo-x86/sys-fs/lvm2/files/lvm.rc-2.02.105-r2,v 1.1 2014/02/02 19:52:34 robbat2 Exp $
|
2015-02-27 00:58:55 +00:00
|
|
|
|
|
|
|
depend() {
|
|
|
|
before checkfs fsck
|
2015-07-31 00:55:23 +00:00
|
|
|
after modules device-mapper
|
|
|
|
need lvmetad sysfs
|
2015-02-27 00:58:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config='global { locking_dir = "/run/lock/lvm" }'
|
|
|
|
|
|
|
|
dm_in_proc() {
|
|
|
|
local retval=0
|
|
|
|
for x in devices misc ; do
|
|
|
|
grep -qs 'device-mapper' /proc/${x}
|
|
|
|
retval=$((${retval} + $?))
|
|
|
|
done
|
|
|
|
return ${retval}
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
|
|
|
# LVM support for /usr, /home, /opt ....
|
|
|
|
# This should be done *before* checking local
|
|
|
|
# volumes, or they never get checked.
|
|
|
|
|
|
|
|
# NOTE: Add needed modules for LVM or RAID, etc
|
|
|
|
# to /etc/modules.autoload if needed
|
|
|
|
for lvm_path in /bin/lvm /sbin/lvm ; do
|
|
|
|
[ -x "$lvm_path" ] && break
|
|
|
|
done
|
|
|
|
if [ ! -x "$lvm_path" ]; then
|
|
|
|
eerror "Cannot find lvm binary in /sbin or /bin!"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
if [ -z "${CDBOOT}" ] ; then
|
|
|
|
if [ -e /proc/modules ] && ! dm_in_proc ; then
|
|
|
|
modprobe dm-mod 2>/dev/null
|
|
|
|
fi
|
|
|
|
if [ -d /proc/lvm ] || dm_in_proc ; then
|
|
|
|
ebegin "Setting up the Logical Volume Manager"
|
|
|
|
#still echo stderr for debugging
|
|
|
|
lvm_commands="#! ${lvm_path} --config '${config}'\n"
|
|
|
|
# Extra PV find pass because some devices might not have been available until very recently
|
|
|
|
lvm_commands="${lvm_commands}pvscan\n"
|
|
|
|
# Now make the nodes
|
|
|
|
lvm_commands="${lvm_commands}vgscan --mknodes\n"
|
|
|
|
# And turn them on!
|
|
|
|
lvm_commands="${lvm_commands}vgchange --sysinit -a ly\n"
|
|
|
|
# Order of this is important, have to work around dash and LVM readline
|
|
|
|
printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
|
|
|
|
eend $? "Failed to setup the LVM"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
for lvm_path in /bin/lvm /sbin/lvm ; do
|
|
|
|
[ -x "$lvm_path" ] && break
|
|
|
|
done
|
|
|
|
if [ ! -x "$lvm_path" ]; then
|
|
|
|
eerror "Cannot find lvm binary in /sbin or /bin!"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
# Stop LVM2
|
|
|
|
if [ -x /sbin/vgs ] && \
|
|
|
|
[ -x /sbin/vgchange ] && \
|
|
|
|
[ -x /sbin/lvchange ] && \
|
|
|
|
[ -f /etc/lvmtab -o -d /etc/lvm ] && \
|
|
|
|
[ -d /proc/lvm -o "`grep device-mapper /proc/misc 2>/dev/null`" ]
|
|
|
|
then
|
|
|
|
einfo "Shutting down the Logical Volume Manager"
|
|
|
|
|
|
|
|
|
2015-07-31 00:55:23 +00:00
|
|
|
VGS=$($lvm_path vgs --config "${config}" -o vg_name --noheadings --nosuffix --rows 2> /dev/null)
|
2015-02-27 00:58:55 +00:00
|
|
|
|
|
|
|
if [ "$VGS" ]
|
|
|
|
then
|
|
|
|
ebegin " Shutting Down LVs & VGs"
|
|
|
|
#still echo stderr for debugging
|
|
|
|
lvm_commands="#! ${lvm_path} --config '${config}'\n"
|
|
|
|
# Extra PV find pass because some devices might not have been available until very recently
|
|
|
|
lvm_commands="${lvm_commands}lvchange --sysinit -a ln ${VGS}\n"
|
|
|
|
# Now make the nodes
|
2015-07-31 00:55:23 +00:00
|
|
|
lvm_commands="${lvm_commands}vgchange --sysinit -a ln ${VGS}\n"
|
2015-02-27 00:58:55 +00:00
|
|
|
# Order of this is important, have to work around dash and LVM readline
|
|
|
|
printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
|
2015-07-31 00:55:23 +00:00
|
|
|
eend $? "Failed (possibly some LVs still needed for /usr or root)"
|
2015-02-27 00:58:55 +00:00
|
|
|
fi
|
|
|
|
|
2015-07-31 00:55:23 +00:00
|
|
|
einfo "Finished shutting down the Logical Volume Manager"
|
|
|
|
return 0
|
2015-02-27 00:58:55 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# vim:ts=4
|