2002-02-20 13:28:49 +03:00
# ! / bin / sh
#
# lvm2 This script handles LVM2 initialization / shutdown .
#
# Written by Andres Salomon < dilinger @mp3revolution.net > .
#
PATH = / sbin : / bin : / usr / sbin : / usr / bin
NAME = lvm2
DESC = LVM
2002-03-04 14:12:57 +03:00
test - x / sbin / vgchange | | exit 0
modprobe dm - mod > / dev / null 2 > & 1
# Create necessary files in / dev for device - mapper
create_devfiles ( ) {
2002-09-02 03:08:17 +04:00
DIR = "/dev/mapper"
2002-03-04 14:12:57 +03:00
FILE = "$DIR/control"
2002-05-14 07:56:40 +04:00
major = $ ( grep "[0-9] misc$" / proc / devices | sed ' s / [ ] \ + misc //')
minor = $ ( grep "[0-9] device-mapper$" / proc / misc | sed ' s / [ ] \ + device - mapper //')
2002-03-04 14:12:57 +03:00
if test ! - d $DIR ; then
mkdir - - mode = 755 $DIR > / dev / null 2 > & 1
fi
if test ! - c $FILE - a ! - z "$minor" ; then
mknod - - mode = 600 $FILE c $major $minor > / dev / null 2 > & 1
fi
}
2002-02-20 13:28:49 +03:00
case "$1" in
start )
echo - n "Initializing $DESC: "
2002-03-04 14:12:57 +03:00
create_devfiles
vgchange - a y
2002-09-02 03:08:17 +04:00
# # Mount all LVM devices
# for vg in $ ( vgchange - a y 2 > / dev / null | grep active | awk - F \ " ' { print $2 } ' ) ; do
# MTPT = $ ( grep $vg / etc / fstab | awk ' { print $2 } ' )
# mount $MTPT
# done
2002-02-21 11:52:36 +03:00
echo "$NAME."
2002-02-20 13:28:49 +03:00
; ;
stop )
echo - n "Shutting down $DESC: "
2002-03-04 14:12:57 +03:00
# We don ' t really try all that hard to shut it down ; far too many
# things that can keep it from successfully shutting down .
vgchange - a n
2002-02-20 13:28:49 +03:00
echo "$NAME."
; ;
restart | force - reload )
echo - n "Restarting $DESC: "
2002-03-04 14:12:57 +03:00
vgchange - a n
2002-02-21 11:52:36 +03:00
sleep 1
2002-03-04 14:12:57 +03:00
vgchange - a y
2002-02-20 13:28:49 +03:00
echo "$NAME."
; ;
* )
2002-05-03 08:43:46 +04:00
echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" > & 2
2002-02-20 13:28:49 +03:00
exit 1
; ;
esac
exit 0