On Sat, Jul 19, 2008 at 07:48:37PM +0200, Jérémy Bobbio wrote: > If you are in favor of it, I think it would make more sense (at least to > me) to spend time testing and working on automatic activation of LVM > devices than to spend many hours debugging a new patch with different > assumptions.
Attached you will find a first shot trying to activate Volume Groups during partman init.d. It helped me to notice an interesting difference between MD devices and Volume Groups. In the current way we do things, activated MD devices always shows in the partition tree. This is different from activated VGs which only shows when they have at least one Logical Volume defined. Maybe we should display something for LVM Physical Volumes, like "active/inactive", similarily to what is done for crypto partitions. Same could probably be done for MD devices as well. Cheers, -- Jérémy Bobbio .''`. [EMAIL PROTECTED] : :Ⓐ : # apt-get install anarchism `. `'` `-
commit a6fa8d9aaf608a2cb9db8326ef1ba8bc6a0920db Author: Jérémy Bobbio <[EMAIL PROTECTED]> Date: Sat Jul 19 21:02:44 2008 +0000 Activate Volume Groups during partman init.d The initialization of LVM devices follows what is currently done for MD devices. There is now 2 different init.d scripts: - lvm-devices, run before parted, is responsible for scanning and activating Volume Groups, - lvm, run later, will ensure that Physical Volumes have "lvm" as method, and create free space for Logical Volumes if needed. diff --git a/packages/partman/partman-lvm/choose_partition/lvm/do_option b/packages/partman/partman-lvm/choose_partition/lvm/do_option index 92688c9..8fba4dc 100755 --- a/packages/partman/partman-lvm/choose_partition/lvm/do_option +++ b/packages/partman/partman-lvm/choose_partition/lvm/do_option @@ -10,11 +10,6 @@ ##################################### do_initial_setup() { - # load required kernel modules - depmod -a >/dev/null 2>&1 - modprobe dm-mod >/dev/null 2>&1 - modprobe lvm-mod >/dev/null 2>&1 - # make sure that lvm is available if ! grep -q "[0-9] device-mapper$" /proc/misc ; then db_input critical partman-lvm/nolvm @@ -22,10 +17,6 @@ do_initial_setup() { exit 0 fi - # scan for logical volumes - log-output -t partman-lvm pvscan - log-output -t partman-lvm vgscan - # Commit the changes confirm_changes partman-lvm || exit 0 commit_changes partman-lvm/commit_failed || exit $? @@ -39,22 +30,6 @@ do_initial_setup() { exit 0 fi done - - if [ ! -f /var/cache/partman-lvm/first ]; then - # try to activate old volume groups - count=$(vg_list | wc -l) - if [ $count -gt 0 ]; then - db_subst partman-lvm/activevg COUNT $count - db_set partman-lvm/activevg false - db_input critical partman-lvm/activevg - db_go || true - db_get partman-lvm/activevg - [ "$RET" = true ] && log-output -t partman-lvm vgchange -a y - # TODO: We need to update and lock the devices that LVM just claimed - fi - # ask only the first time - mkdir -p /var/cache/partman-lvm && touch /var/cache/partman-lvm/first - fi } do_display() { diff --git a/packages/partman/partman-lvm/debian/changelog b/packages/partman/partman-lvm/debian/changelog index c803d76..3c30331 100644 --- a/packages/partman/partman-lvm/debian/changelog +++ b/packages/partman/partman-lvm/debian/changelog @@ -1,3 +1,15 @@ +partman-lvm (62) UNRELEASED; urgency=low + + [ Jérémy Bobbio ] + * Activate Volume Groups during partman initialization: like MD devices, + there is now 2 different init.d scripts: + - lvm-devices, run before parted, is responsible for scanning and + activating Volume Groups, + - lvm, run later, will ensure that Physical Volumes have "lvm" as + method, and create free space for Logical Volumes if needed. + + -- Jérémy Bobbio <[EMAIL PROTECTED]> Sat, 19 Jul 2008 19:02:55 +0000 + partman-lvm (61) unstable; urgency=low [ Updated translations ] diff --git a/packages/partman/partman-lvm/init.d/_numbers b/packages/partman/partman-lvm/init.d/_numbers index 40c63d5..27a8be2 100644 --- a/packages/partman/partman-lvm/init.d/_numbers +++ b/packages/partman/partman-lvm/init.d/_numbers @@ -1 +1,2 @@ -50 lvm \ No newline at end of file +26 lvm-devices +50 lvm diff --git a/packages/partman/partman-lvm/init.d/lvm b/packages/partman/partman-lvm/init.d/lvm index 02cf1cf..2249bef 100755 --- a/packages/partman/partman-lvm/init.d/lvm +++ b/packages/partman/partman-lvm/init.d/lvm @@ -5,13 +5,11 @@ # a loop partition table and partition. . /lib/partman/lib/base.sh +. /lib/partman/lib/lvm-base.sh # Avoid warnings from lvm2 tools about open file descriptors export LVM_SUPPRESS_FD_WARNINGS=1 -log-output -t partman pvscan -log-output -t partman vgscan - if [ -x /sbin/vgdisplay ]; then vgroups=$(/sbin/vgdisplay 2>/dev/null | grep '^[ ]*VG Name' | \ sed -e 's/.*[[:space:]]\(.*\)$/\1/' | sort) @@ -26,13 +24,16 @@ for dev in /var/lib/partman/devices/*; do open_dialog PARTITIONS while { read_line num id size type fs path name; [ "$id" ]; }; do if [ "$fs" != free ]; then - partitions="$partitions $id" + partitions="$partitions $id,$path" fi done close_dialog # Check if device/partitions are used for LVM (PV) - for id in $partitions; do + for part in $partitions; do + set -- $(IFS=, && echo $part) + id=$1 + path=$2 lvm= # If the device is in fact being used for lvm, mark it as such. @@ -53,6 +54,15 @@ for dev in /var/lib/partman/devices/*; do if [ "$lvm" ]; then mkdir -p $id echo lvm >$id/method + + if ! [ -e $id/locked ]; then + vg=$(pv_get_vg $path) + for vgs in $vgroups; do + if [ "$vg" = "$vgs" ]; then + vg_lock_pvs $vg $path + fi + done + fi fi done diff --git a/packages/partman/partman-lvm/init.d/lvm-devices b/packages/partman/partman-lvm/init.d/lvm-devices new file mode 100755 index 0000000..fefa05f --- /dev/null +++ b/packages/partman/partman-lvm/init.d/lvm-devices @@ -0,0 +1,26 @@ +#!/bin/sh + +# Avoid warnings from lvm2 tools about open file descriptors +export LVM_SUPPRESS_FD_WARNINGS=1 + +# Load modules and scan volume groups if it was not done before +if ! grep -q "[0-9] device-mapper$" /proc/misc ; then + # load required kernel modules + depmod -a >/dev/null 2>&1 + modprobe dm-mod >/dev/null 2>&1 + modprobe lvm-mod >/dev/null 2>&1 + + # make sure that lvm is available + if ! grep -q "[0-9] device-mapper$" /proc/misc ; then + db_input critical partman-lvm/nolvm + db_go + exit 0 + fi + + # scan for logical volumes + log-output -t partman pvscan + log-output -t partman vgscan + + # activate volume groups + log-output -t partman-lvm vgchange -a y +fi diff --git a/packages/partman/partman-lvm/lib/lvm-base.sh b/packages/partman/partman-lvm/lib/lvm-base.sh index 7b60805..5adc657 100644 --- a/packages/partman/partman-lvm/lib/lvm-base.sh +++ b/packages/partman/partman-lvm/lib/lvm-base.sh @@ -211,6 +211,11 @@ pv_get_info() { return 0 } +# Get VG for a PV +pv_get_vg() { + lvm_get_info pvs vg_name "$1" +} + # Get all PVs pv_list() { # Scan the partman devices and find partitions that have lvm as method.
signature.asc
Description: Digital signature