[blfs-dev] LVM2 bootscript

Qrux qrux.qed at gmail.com
Mon Feb 13 14:50:47 PST 2012


LVM2 should have a bootscript and a link in /etc/rc.d/rcS.d; if that hasn't been done yet, feel free to include the one I use (which I've kept in the LFS/BLFS template).

The meat of it is doing:

	vgscan --mknodes
	vgchange -a y

to create the DM entries and then to make each of the discovered volumes "available".

* * *

And, regarding an earlier issue...*sigh*...Yes, I know that RAID and LVM are different subjects.  I was simply suggesting that an LVM tutorial might be warranted if a RAID tutorial is to be included, and they might go in the same section particularly because LVM has RAID-like modes--striped and mirrored--which might be better explained in the context--or near to the context--of talking about RAID.

If we're being pedantic, we might change that section to "Filesystems and Disk Management", since LVM and md RAID aren't filesystems.

However, on the subject of "tutorials"--despite my personal interest in including just such a tutorial for Xen--I think they are a bad direction for the book.  There are plenty of resources online; it seems like the focus of the book should be to get packages current (e.g., as has been done for mdadm, LVM2), and to leave the explanations to some other venue like the user-wiki for tutorial-like docs.

	Q



#! /bin/bash
################################################################
# Begin lvm2
#
# Description : Initiates LVM2 on reboot
#
# Author      : Qrux - qrux dot qed @ gmail.com
#
################################################################

### BEGIN INIT INFO
# Provides:            lvm2
# Required-Start:
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start:       S
# Default-Stop:
# Short-Description:   Initiates LVM2.
# Description:         Initiates LVM2 logical volumes.
### END INIT INFO

. /lib/lsb/init-functions

unset totime
totime() { date '+%Y%m%d_%H%M%S'; }

#
# This is an unfortunate state of affairs.  We really want LVM volumes
# to be available on boot (not have to have the necessary executables in /usr.
#
LVM_VGSCAN=/usr/sbin/vgscan
LVM_VGCHANGE=/usr/sbin/vgchange
LVM_RUN_DIR=/var/run/lvm2

if [ ! -x $LVM_VGSCAN ] ; then
	log_info_msg "LVM2 command 'vgscan' not found; exiting.\n"
	exit
fi

if [ ! -x $LVM_VGCHANGE ] ; then
	log_info_msg "LVM2 command 'vgchange' not found; exiting.\n"
	exit
fi

/bin/mkdir -p $LVM_RUN_DIR

case "${1}" in
    start)
	# Make necessary paths in /dev, and
	# set "available" status of detected Logical Volumes to "yes"
	log_info_msg "Enabling LVM volumes..."
	$LVM_VGSCAN --mknodes > ${LVM_RUN_DIR}/start-status 2>&1 && \
	  $LVM_VGCHANGE -a y  >> ${LVM_RUN_DIR}/start-status 2>&1
	evaluate_retval
	;;

    *)
	echo "Usage: ${0} {start}"
	exit 1
	;;
esac

exit 0

# End lvm2




More information about the blfs-dev mailing list