Alex Owen wrote: > Here is a patch to pass on the code I've been working on for this problem. > > Part is for lvmcfg and most for partman-lvm. > > I have no local udeb repositary so I have not tested this by building the > udebs. I have however patched the ramdisk in memory then run partman from > the "expert" menu... this seems to work! > > Anyway here is the diff... comments welcome!
Thanks for working on this. I took a look at your patch. > Index: partman/partman-lvm/choose_method/lvm/choices > =================================================================== > --- partman/partman-lvm/choose_method/lvm/choices (revision 22848) > +++ partman/partman-lvm/choose_method/lvm/choices (working copy) > @@ -8,6 +8,9 @@ > cd $dev > > lvm=no > +if cat $dev/model | grep "Software RAID device" >/dev/null ; then > + lvm=yes > +fi > open_dialog VALID_FLAGS $id > while { read_line flag; [ "$flag" ]; }; do > if [ "$flag" = lvm ]; then This is needed because there's no LVM flag set on a MD device, and probably no way to set it, as I understand it. I agree we seem to need this although the special case is disttasteful. Another option would be to not check for the valid flag at all. Since some architectures (powerpc) don't include lvm in the valid flags at all, that would perhaps support lvm on such arches. Yet another approach might be to fix parted to include the flag.. > --- partman/partman-lvm/init.d/lvm (revision 22848) > +++ partman/partman-lvm/init.d/lvm (working copy) > @@ -32,6 +34,9 @@ > > for id in $partitions; do > lvm=no > + if pvdisplay $(cat $dev/device) >/dev/null 2>&1 ; then > + lvm=yes > + fi > open_dialog GET_FLAGS $id > while { read_line flag; [ "$flag" ]; }; do > if [ "$flag" = lvm ]; then I don't understand the point of checking pvdisplay here. Presumably this is meant to make sure that any device that is in fact already being used for lvm is set to be used as a lvm device when partman starts. But the code doesn't seem to work; $dev/device will not include the partition name and pvdisplay doesn't display anything for a whole device if only a partition of it is used as a PV. I left this out in my tests and things seemed to work ok -- what is the problem this is supposed to fix? > Index: partman/partman-lvm/commit.d/store_lvm_markers I'm not convinced that we need the ugly hack of /tmp/lvm-marks, or that using it is entirely safe. So I tried instead to make lvcfg use partman directly to find devices that are flagged as being used for lvm. I made it do this only if it's run from partman, otherwise it retains its old behavior of using partconf-find-partitions. I've attached a diff of my changes. With this patch I have successfully installed a system that has /usr a lvm volume over software raid 0. It seems to work pretty well, I do know of one bug: After setting up a md device and marking it to be used as for lvm, and going into lvmcfg and setting up the lvm, partman restarts. And at this point it loses track of the method field of the md device. This doesn't prevent anything from working, because the devices are already set up, but it is suprising. I doubt it's a new bug. -- see shy jo
Index: lvmcfg/debian/control =================================================================== --- lvmcfg/debian/control (revision 23089) +++ lvmcfg/debian/control (working copy) @@ -8,13 +8,13 @@ Package: lvmcfg Architecture: all -Depends: partitioned-harddrives +Depends: partitioned-harddrives, partconf-find-partitions XB-installer-menu-item: 44 XC-Package-Type: udeb Description: Configure the Logical Volume Manager Package: lvmcfg-utils Architecture: all -Depends: cdebconf-udeb, md-modules, lvm2-udeb, partconf-find-partitions, parted-udeb +Depends: cdebconf-udeb, md-modules, lvm2-udeb, parted-udeb XC-Package-Type: udeb Description: lvmcfg without the main menu item Index: lvmcfg/debian/changelog =================================================================== --- lvmcfg/debian/changelog (revision 23089) +++ lvmcfg/debian/changelog (working copy) @@ -1,3 +1,15 @@ +lvmcfg (1.05) UNRELEASED; urgency=low + + * Joey Hess + - Detect if running in partman, and if so, use partman functions to + enumerate partitions marked in partman to be used as pv's. + Closes: #245704 + - lvmcfg-utils no longer depends on partconf-find-partitions; the dep + is moved to lvmcfg, since it uses lvmcfg-utils in a way that needs that + package. + + -- Joey Hess <[EMAIL PROTECTED]> Fri, 15 Oct 2004 14:33:42 -0400 + lvmcfg (1.04) unstable; urgency=low * Updated translations: Index: lvmcfg/lvmcfg.sh =================================================================== --- lvmcfg/lvmcfg.sh (revision 23089) +++ lvmcfg/lvmcfg.sh (working copy) @@ -1,6 +1,13 @@ #!/bin/sh -. /usr/share/debconf/confmodule +if [ "$1" = partman ]; then + # Use partman if possible. + . /lib/partman/definitions.sh + partman_avail=1 +else + . /usr/share/debconf/confmodule + partman_avail=0 +fi # # convert the return values from "xx (yy)" => "xx" @@ -141,14 +148,41 @@ RET="${RET}/ Mount: ${cmdout}" } -# +# get all available physical volumes +enum_pvs() { + if [ ! "$partman_avail" ]; then + # Not in partman, so use partconf's find-partitions to find + # partitions marked as lvm volumes. + /usr/lib/partconf/find-partitions --ignore-fstype 2>/dev/null | grep "[[:space:]]LVM[[:space:]]" | cut -f1 + else + # In partman, so scan the partman devices and find + # partitions that have their method set to lvm. We don't + # rely on the partition flags since that does not work for + # raid partitions. + for dev in $DEVICES/*; do + [ -d "$dev" ] || continue + cd $dev + open_dialog PARTITIONS + while { read_line num id size type fs path name; [ "$id" ]; }; do + [ -f $id/method ] || continue + method=$(cat $id/method) + if [ "$method" = lvm ]; then + echo $path + fi + done + close_dialog + done + fi +} + + # get all unused available physical volumes # in this case all partitions with 0x8e, # or all other non-lvm devices from /proc/partitions # get_pvs() { PARTITIONS="" - for i in `/usr/lib/partconf/find-partitions --ignore-fstype 2>/dev/null | grep "[[:space:]]LVM[[:space:]]" | cut -f1`; do + for i in $(enum_pvs); do # skip already assigned found=no for pv in $(vgdisplay -v | grep "[ ]*PV Name" | sed -e "s/ \+PV Name \+//"); do @@ -771,4 +805,3 @@ [ $1 -gt 0 ] && apt-install lvm2 exit 0 - Index: partman/partman-lvm/choose_method/lvm/choices =================================================================== --- partman/partman-lvm/choose_method/lvm/choices (revision 23089) +++ partman/partman-lvm/choose_method/lvm/choices (working copy) @@ -8,6 +8,9 @@ cd $dev lvm=no +if grep -q "Software RAID device" $dev/model; then + lvm=yes +fi open_dialog VALID_FLAGS $id while { read_line flag; [ "$flag" ]; }; do if [ "$flag" = lvm ]; then Index: partman/partman-lvm/debian/changelog =================================================================== --- partman/partman-lvm/debian/changelog (revision 23089) +++ partman/partman-lvm/debian/changelog (working copy) @@ -1,3 +1,16 @@ +partman-lvm (27) UNRELEASED; urgency=low + + * Joey Hess + - Pass "partman" option to lvmcfg so it knowns it is running under + partman and can use partman to find devices for lvm. + - Don't restart parted_server until lvmcfg has run since lvmcfg now uses + it. + - Add special case into choose_method/lvm/choices to allow raid devices to + be used for lvm, despite not having lvm listed in VALID_FLAGS. + Closes: #275586 + + -- Joey Hess <[EMAIL PROTECTED]> Fri, 15 Oct 2004 14:19:07 -0400 + partman-lvm (26) unstable; urgency=low * Updated translations: Index: partman/partman-lvm/choose_partition/lvm/do_option =================================================================== --- partman/partman-lvm/choose_partition/lvm/do_option (revision 23089) +++ partman/partman-lvm/choose_partition/lvm/do_option (working copy) @@ -113,6 +113,8 @@ fi done +lvmcfg partman + # Restart partman. open_infifo @@ -121,8 +123,6 @@ rm /var/run/parted_server.pid -lvmcfg - initcount=`ls /lib/partman/init.d/* | wc -l` db_progress START 0 $initcount partman/progress/init/title for s in /lib/partman/init.d/*; do
signature.asc
Description: Digital signature