[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

partman-auto-lvm patches



Hi,

in a previous message to this list from Colin Watson
(http://lists.debian.org/debian-boot/2005/09/msg00209.html) a set of patches
were made available to make partman-auto-lvm (pal from now) more complete
and somehow working.

Unfortunatly i did delete the sequencial patches by mistakes. I am sorry about
it but i have prepared again a full diff with explanations of why stuff has
been implemented in a certain way.

Please note that there is a lot of polish that can/must be done. When I started
hacking on pal, i didn't realize how much code duplication was pulled in and
definetely there are several bits that can be designed better.

The patch in attachment is quite self explanatory but i will go trough the
details as deep as possible. Note that i did strip the branding part out of it,
since i doubt Debian cares to have Ubuntu named volume groups ;)

Also note that this patch depends on a very simple and non-intrusive change
to partman-auto to avoid a bit of code duplication (patch in attachment).

The target of the implementation was to be able to scratch a disk and install
using LVM as underlaying format.

The first step was to create such target for "Guided Partitioning" (sorry if i
don't recall all the exact names in the menus but it should be pretty clear) and
this was achieved adding a "40 some_device_lvm" target (similar to partman-auto).

This adds:
- automatically_partition/some_device_lvm/choices:
  * Make a copy of the partman-auto equivalent.
  * Use the correct template.
  * Skip powerpc since parted doesn't understand LVM on that arch yet.
    NOTE that this should be fixed more recent versions of parted afaik.
- automatically_partition/some_device_lvm/do_option:
  * We will look deep into this when describing the logic later.
and modifies:
- automatically_partition/_numbers:
  * Add "40 some_device_lvm".
- debian/partman-auto-lvm.templates:
  * Add partman-auto-lvm/text/use_device template similar to partman-auto
    equivalent.

lvm_tools.sh has basically been rewritten to make it more consistent in the
name space and use lvm2 specific functions to reduce a lot of loops/grep/sed
operations, since lvm2 supports a better formatting output and can give us
exactly (or almost) what we need.

This modifies:
- lvm_tools.sh:
  * Use vgs to simplify VG_list.
  * Rename new_VG to VG_create (name more similare to vgcreate).
  * Avoid useless loop in VG_create.
  * Use pvs to simplify VG_of_PV.
  * Rename detach_PV to VG_reduce.
  * Simplify VG_reduce.
  * Rename attach_PV to VG_extend.
  * Rename new_LV to LV_create.
  * Implement the "full" option in LV_create.
  * Rename delete_LV to LV_remove.
  * Cleanup LV_list.
- automatically_partition/vg_all_free/do_option:
  * Use VG_create instead of new_VG.
- perform_recipe_by_lvm:
  * Use renamed functions from lvm_tools

Make perform_recipe_by_lvm more simple and generic:
  * Remove code that belongs to do_option.
  * Add progress bar support.
  * Add support for "last partition can take the rest of the free space".
  * Better naming after partitions that are not mounted. For example in the old
    code a swap partition would be called _1, now it is called swap_1.
  * Deal with 2.6 device mapper name.
  * Restart partman at the end of the process (as lvmcgf does) to reload all the
    nice visuals properly.
  * Add rounding M->K hack that definetely must be rewritten (see below together
    with automatically_partition/some_device_lvm/do_option details).

Do a few fixups in automatically_partition/vg_all_free/do_option:
  * Make sure devices are there by calling udevstart and flush pending changes
    to /dev.
  * Use real path to the device.

Let's dig into automatically_partition/some_device_lvm/do_option logic:

Input:
 device name
 recipe
Output:
 a bootable installation with as much as possible on the lvm device with
 partition scheme as offered to the user.

Problems:
 partitions/lvm roundings
 presence and location of /boot
 special partitions required on some architectures (not fully addressed yet)

The first step is to verify that we can perform a certain recipe.
The 2 major issues here are roundings and /boot. At this point in time
we don't know if a recipe has allocared space for /boot, so we arbitrary
assume that 200MB will be allocated for such task and pass free_size - 200
to choose_recipe.

If we can perform the recipe, than scratch the disk. This code has been copied
almost pristine from partman-auto and it is a good target for a shell lib.

Reload the free size from the device after the scratch of the table, to ensure
proper values (roundings).

Now we have a recipe to work on.
This operation is tricky for several reasons.
We need to make sure /boot is not on LVM. None of the bootloaders are capable to
boot from a LVM2 device yet.
The recipe might contain a definition for /boot or not. In the latter case
we need to add it.
At the end of /boot mangling, we will have 2 recipes. One that contains /boot +
the rest of the disk assigned as pv, and one that contains the rest of the
partitions.
This step will require a rewrite sooner or later (see below future plans and
ideas) to handle special partitions required on some architectures.

Another big chunk of code has been copied pristine (afair) from
partman-auto/perform_recipe to write the recipe to disk. this is clearly another
target for a shell lib.

Update /dev

At this point the disk layout will look like:

partition 1 - /boot (between 128 to 512M)
partition 2 - pv

and we have a list of pv that can be used to create the vg.

Next step is to assign the name to the vg and create it. The code is almost a
pristine copy from lvmcfg.

Call perform_recipe_by_lvm to do the rest of the job with the second recipe
stripped of /boot that will take care of /, swap and whatever else is defined in
the recipe.

zumzumzumz... install and boot.. it works :)

Now the only major issue to see pal truely integrated in Debian and that must be
addressed in the next versions is (as mentioned above) special partitions
required on some architectures.
The problem is that pal has no such knowledge of what can go in LVM and what not.
The ideal solution would be to ingrate this information into partman-auto
recipes adding a tag to each partition inside each recipe that can tell pal
if the partition can be moved to LVM or not.

Let see for example powerpc-prep (from partman-auto):

8 1 1 boot-prep
        $primary{ }
        $bootable{ }
        method{ prep } .

it requires a special boot partition. This clearly cannot go into an LVM volume
(for what is my knowledge of ppc at least.. yes.. i ordered one and won't be
delivered till end of this month ;)) and it is not covered by the code above.

The easiest would be to add a flag that will make that recipe looks like:

8 1 1 boot-prep
        $primary{ }
        $bootable{ }
        method{ prep } .
	$nolvm{ }.

(flag is just an idea and name up for discussion... so please don't take this as
absolute statement, as well it can be the other way around.. canbelvm{ } flag on
the other partitions ;))

at that point we can easily make pal recipe parsing code generic enough when
stripping the recipe and calculating the 2 recipes. The $bootable{ } information
inside that specific bit will tell pal not to create a /boot given that there is
one in the recipe and that's special cased via $nolvm{ }.

In order to achieve such collection of information, we will need to collect info
from people using certain arches. I personally have no knowledge of all arches
in debian and i don't want to assume.

Once the concept has been proved and known to work, the next step will be to
remove as much duplicated code as possible.

As last note about the patch automatically_partition/vg_all_free/choices has
been disabled because of http://bugzilla.ubuntu.com/show_bug.cgi?id=15017
but perhaps there might be work arounds for it that i am not aware of.
Mostlikely one you d-i guru's will have an answer.

Thanks
Fabio

PS CC me on reply! i am not subscribed to this mailing list. Don't expect an
answer from me if you don't CC ;)

-- 
I'm going to make him an offer he can't refuse.
diff -Naurd partman-auto-lvm-2/automatically_partition/_numbers partman-auto-lvm-2ubuntu8/automatically_partition/_numbers
--- partman-auto-lvm-2/automatically_partition/_numbers	2004-10-19 13:23:03.000000000 +0200
+++ partman-auto-lvm-2ubuntu8/automatically_partition/_numbers	2005-10-06 11:44:04.000000000 +0200
@@ -1 +1,2 @@
+40 some_device_lvm
 60 vg_all_free
diff -Naurd partman-auto-lvm-2/automatically_partition/some_device_lvm/choices partman-auto-lvm-2ubuntu8/automatically_partition/some_device_lvm/choices
--- partman-auto-lvm-2/automatically_partition/some_device_lvm/choices	1970-01-01 01:00:00.000000000 +0100
+++ partman-auto-lvm-2ubuntu8/automatically_partition/some_device_lvm/choices	2005-09-12 19:44:33.000000000 +0200
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+. /lib/partman/definitions.sh
+
+SUBARCH="$(archdetect)"
+case $SUBARCH in
+    powerpc/*)
+	exit
+	;;
+esac
+
+mypart=''
+mysize=0
+
+for dev in $DEVICES/*; do
+    [ -d "$dev" ] || continue
+    db_subst partman-auto-lvm/text/use_device DEVICE $(device_name $dev)
+    db_metaget partman-auto-lvm/text/use_device description
+    printf "$dev\t$RET\n"
+done
diff -Naurd partman-auto-lvm-2/automatically_partition/some_device_lvm/do_option partman-auto-lvm-2ubuntu8/automatically_partition/some_device_lvm/do_option
--- partman-auto-lvm-2/automatically_partition/some_device_lvm/do_option	1970-01-01 01:00:00.000000000 +0100
+++ partman-auto-lvm-2ubuntu8/automatically_partition/some_device_lvm/do_option	2005-07-07 09:11:21.000000000 +0200
@@ -0,0 +1,257 @@
+#!/bin/sh
+
+. /lib/partman/definitions.sh
+. /lib/partman/recipes.sh
+. /lib/partman/lvm_tools.sh
+
+dev=$1
+
+# copy/paste from partman-auto/autopartition to scratch the disk
+
+[ -f $dev/size ] || exit 1
+free_size=$(cat $dev/size)
+free_size=$(expr 0000000"$free_size" : '0*\(..*\)......$') # convert to megabytes
+
+# we need to be sure we can perform the selected receipe and be able to add /boot.
+# virtually remove 200Mb from the free space. Perhaps a reiteration over the recipe
+# would be more accurate, but for now this is more than fine.
+free_size=$(expr $free_size - 200)
+
+choose_recipe "$free_size" || exit $?
+
+cd $dev
+
+open_dialog LABEL_TYPES
+types=$(read_list)
+close_dialog
+
+label_type=$(default_disk_label)
+
+if ! expr "$types" : ".*${label_type}.*" >/dev/null; then
+        label_type=msdos # most widely used
+fi
+
+if [ "$label_type" = sun ]; then
+        db_input critical partman/confirm_write_new_label
+        db_go || exit 0
+        db_get partman/confirm_write_new_label
+        if [ "$RET" = false ]; then
+                db_reset partman/confirm_write_new_label
+                exit 1
+        fi
+        db_reset partman/confirm_write_new_label
+fi
+
+open_dialog NEW_LABEL "$label_type"
+close_dialog
+
+if [ "$label_type" = sun ]; then
+        # write the partition table to the disk
+        disable_swap
+        open_dialog COMMIT
+        close_dialog
+        sync
+        # reread it from there
+        open_dialog UNDO
+        close_dialog
+        enable_swap
+fi
+
+# Different types partition tables support different visuals.  Some
+# have partition names other don't have, some have extended and
+# logical partitions, others don't.  Hence we have to regenerate the
+# list of the visuals
+if [ -f visuals ]; then
+        rm visuals
+fi
+
+modprobe dm-mod  >>/var/log/messages 2>&1 || true
+modprobe lvm-mod  >>/var/log/messages 2>&1 || true
+
+### now we need to create the /boot + lvm envelope
+
+# just to be sure
+update_all
+
+decode_recipe $recipe
+
+# get the free_size free_space infos from the device again
+
+cd $dev
+open_dialog PARTITIONS
+read_line num id size type fs path name
+close_dialog
+free_space="$id"
+open_dialog PARTITION_INFO $free_space
+read_line x1 x2 free_size free_type x3 x4 x5
+close_dialog
+
+free_size=$(expr 0000000"$free_size" : '0*\(..*\)......$') # convert to megabytes
+
+# make a backup of the original scheme that we will use inside the VG
+# this operation is tricky because it should consider some special arches like ppc
+# that needs some extra partitions to work properly. For now let's make it simple
+# and generic.
+backupscheme="$scheme"
+
+# now we need to create the /boot and the pv/vg scheme
+
+# if the original scheme has /boot, let's use that instead of a fake otherwise we add it to a 256Mb default.
+if echo $scheme | grep -eq "[[:space:]]/boot[[:space:]]"; then
+    backupscheme=$(echo "$backupscheme" | grep -v "[[:space:]]/boot[[:space:]]")
+    bootscheme=$(echo "$backupscheme" | grep "[[:space:]]/boot[[:space:]]")
+    # we need to create a new recipe here, stripped of /boot
+else
+    bootscheme="128 512 256 ext3 \$primary{ } \$bootable{ } method{ format } format{ } use_filesystem{ } filesystem{ ext3 } mountpoint{ /boot }"
+    # original recipe needs no changing. Only proper recalculation in perform_recipe_by_lvm that's done automatically.
+fi
+# creating envelope
+scheme="$bootscheme${NL}100 1000 1000000000 ext3 method { lvm }"
+
+expand_scheme
+
+clean_method
+
+### here we need to create /boot and the partition that will become our pv/vg ###
+
+## copy/paste from partman-auto/perform_recipe
+
+# the while is supposed to create all the primary partitions. We only have one but
+# for the sake of avoiding mistakes the entire block of code is copied.
+
+cd $dev
+while
+    [ "$free_type" = pri/log ] \
+    && echo $scheme | grep '\$primary{' >/dev/null
+ do  
+    pull_primary
+    set -- $primary
+    open_dialog NEW_PARTITION primary $4 $free_space beginning ${1}000001
+    read_line num id size type fs path name
+    close_dialog
+    if [ -z "$id" ]; then
+        autopartitioning_failed
+    fi
+    neighbour=$(partition_after $id)
+    if [ "$neighbour" ]; then
+        open_dialog PARTITION_INFO $neighbour
+        read_line x1 new_free_space x2 new_free_type fs x3 x4
+        close_dialog
+    fi
+    if
+        [ -z "$neighbour" -o "$fs" != free \
+          -o "$new_free_type" = primary -o "$new_free_type" = unusable ]
+    then
+        open_dialog DELETE_PARTITION $id
+        close_dialog
+        open_dialog NEW_PARTITION primary $4 $free_space end ${1}000001
+        read_line num id size type fs path name
+        close_dialog
+        if [ -z "$id" ]; then
+            autopartitioning_failed
+        fi
+        neighbour=$(partition_before $id)
+        if [ "$neighbour" ]; then
+            open_dialog PARTITION_INFO $neighbour
+            read_line x1 new_free_space x2 new_free_type fs x3 x4
+            close_dialog
+        fi
+        if
+            [ -z "$neighbour" -o "$fs" != free -o "$new_free_type" = unusable ]
+        then
+            open_dialog DELETE_PARTITION $id
+            close_dialog
+            break
+        fi
+    fi
+    shift; shift; shift; shift
+    setup_partition $id $*
+    primary=''
+    scheme="$logical"
+    free_space=$new_free_space
+    free_type="$new_free_type"
+ done
+
+### this one creates all the logical partitions and adds them to the vg
+
+devfspv_devices=''
+foreach_partition '
+    if [ -z "$free_space" ]; then
+        autopartitioning_failed
+    fi
+    open_dialog PARTITION_INFO $free_space
+    read_line x1 free_space x2 free_type fs x3 x4
+    close_dialog
+    if [ "$fs" != free ]; then
+        free_type=unusable
+    fi
+    case "$free_type" in
+        primary|logical)
+            type="$free_type"
+            ;;
+        pri/log)
+            type=logical
+            ;;
+        unusable)
+            autopartitioning_failed
+            ;;
+    esac
+    if [ "$last" = yes ]; then
+        open_dialog NEW_PARTITION $type $4 $free_space full ${1}000001
+    else
+        open_dialog NEW_PARTITION $type $4 $free_space beginning ${1}000001
+    fi
+    read_line num id size type fs path name
+    close_dialog
+    if [ -z "$id" ]; then
+        autopartitioning_failed
+    fi
+    devfspv_devices="$devfspv_devices $path"
+    # make the partition LVM
+    open_dialog GET_FLAGS $id
+    flags=$(read_paragraph)
+    close_dialog
+    open_dialog SET_FLAGS $id
+    write_line "$flags"
+    write_line lvm
+    write_line NO_MORE
+    close_dialog
+    shift; shift; shift; shift
+    setup_partition $id $*
+    free_space=$(partition_after $id)'
+
+# write the partition tables
+disable_swap
+cd $dev
+open_dialog COMMIT
+close_dialog
+
+update_all
+
+#### now we have the container! yeppa!!! ####
+
+if type udevstart >/dev/null 2>&1; then
+    udevstart
+fi
+
+for pv in $devfspv_devices; do
+    realpath="$(mapdevfs "$pv")"
+    pv_devices="$pv_devices $realpath"
+done
+
+# Choose name, create VG and attach each partition as a physical volume
+noninteractive=true
+while true; do
+    db_input medium partman-auto-lvm/new_vg_name || eval $noninteractive
+    db_go || exit 1
+    db_get partman-auto-lvm/new_vg_name
+    VG_name="$RET"
+
+    if VG_create "$VG_name" $pv_devices; then break; fi
+    noninteractive="exit 1"
+done
+
+perform_recipe_by_lvm $VG_name $recipe
+
+# default to accepting the autopartitioning
+menudir_default_choice /lib/partman/choose_partition finish finish || true
diff -Naurd partman-auto-lvm-2/automatically_partition/vg_all_free/choices partman-auto-lvm-2ubuntu8/automatically_partition/vg_all_free/choices
--- partman-auto-lvm-2/automatically_partition/vg_all_free/choices	2004-10-19 13:23:03.000000000 +0200
+++ partman-auto-lvm-2ubuntu8/automatically_partition/vg_all_free/choices	2005-10-06 11:43:51.000000000 +0200
@@ -2,6 +2,16 @@
 
 . /lib/partman/definitions.sh
 
+#### feature is bugged
+exit
+
+SUBARCH="$(archdetect)"
+case $SUBARCH in
+    powerpc/*)
+	exit
+	;;
+esac
+
 totalsize=0
 
 for dev in $DEVICES/*; do
diff -Naurd partman-auto-lvm-2/automatically_partition/vg_all_free/do_option partman-auto-lvm-2ubuntu8/automatically_partition/vg_all_free/do_option
--- partman-auto-lvm-2/automatically_partition/vg_all_free/do_option	2005-04-19 10:08:52.000000000 +0200
+++ partman-auto-lvm-2ubuntu8/automatically_partition/vg_all_free/do_option	2005-07-07 09:11:21.000000000 +0200
@@ -71,6 +71,12 @@
     close_dialog
 done
 
+# we need to flush udev device creation queue or the next
+# loop will run without devices and fail miserably.
+if type udevstart >/dev/null 2>&1; then
+    udevstart
+fi
+
 # Reread device names as some of them may have changed
 pv_devices=''
 for part in $pv_list; do
@@ -81,7 +87,10 @@
     read_line x1 id size type x2 path x4
     close_dialog
     [ "$id" ] || continue
-    pv_devices="$pv_devices $path"
+    # we need to map from devfs to real path
+    # (vgcreate/pvscan don't like devfs)
+    realpath="$(mapdevfs "$path")"
+    pv_devices="$pv_devices $realpath"
 done
 
 modprobe dm-mod  >>/var/log/messages 2>&1 || true
@@ -95,7 +104,7 @@
     db_get partman-auto-lvm/new_vg_name
     VG_name="$RET"
 
-    if new_VG "$VG_name" $pv_devices; then break; fi
+    if VG_create "$VG_name" $pv_devices; then break; fi
     noninteractive="exit 1"
 done
 
diff -Naurd partman-auto-lvm-2/debian/changelog partman-auto-lvm-2ubuntu8/debian/changelog
--- partman-auto-lvm-2/debian/changelog	2005-07-06 12:57:45.000000000 +0200
+++ partman-auto-lvm-2ubuntu8/debian/changelog	2005-10-06 11:29:39.000000000 +0200
@@ -1,3 +1,108 @@
+partman-auto-lvm (2ubuntu8) breezy; urgency=low
+
+  The "Release Notes" aren't enough release.
+
+  * Remove "Use free space option".
+
+ -- Fabio M. Di Nitto <fabbione@ubuntu.com>  Thu, 06 Oct 2005 11:29:35 +0200
+
+partman-auto-lvm (2ubuntu7) breezy; urgency=low
+
+  * Update French translation (thanks, Sebastien Bacher).
+  * Update Ubuntu-specific translations from Rosetta: Greek, Spanish,
+    Finnish, Hungarian, Slovak, Swedish.
+
+ -- Colin Watson <cjwatson@ubuntu.com>  Tue,  4 Oct 2005 18:07:14 +0100
+
+partman-auto-lvm (2ubuntu6) breezy; urgency=low
+
+  * Update Brazilian Portuguese translation (thanks, André Moraes; closes:
+    Ubuntu #15089).
+
+ -- Colin Watson <cjwatson@ubuntu.com>  Wed, 14 Sep 2005 09:07:22 +0100
+
+partman-auto-lvm (2ubuntu5) breezy; urgency=low
+
+  * Disable ourselves on powerpc in a slightly more effective way.
+
+ -- Colin Watson <cjwatson@ubuntu.com>  Mon, 12 Sep 2005 18:45:06 +0100
+
+partman-auto-lvm (2ubuntu4) breezy; urgency=low
+
+  * Disable ourselves on powerpc (closes: Ubuntu #14438).
+
+ -- Colin Watson <cjwatson@ubuntu.com>  Mon,  5 Sep 2005 17:05:54 +0100
+
+partman-auto-lvm (2ubuntu3) breezy; urgency=low
+
+  * Fabio M. Di Nitto
+    - brownpaper bag.. it's ok to switch to kbytes.. but not everything can
+      handle so big numbers.
+
+ -- Fabio M. Di Nitto <fabbione@ubuntu.com>  Fri, 08 Jul 2005 11:15:28 +0200
+
+partman-auto-lvm (2ubuntu2) breezy; urgency=low
+
+  * Fabio M. Di Nitto
+    - Try to give more sensible names to partitions that are not mounted.
+    - Add db_progress info to perform_recipe_by_lvm.
+    - Fix partition size calculation using kbytes instead of Mbytes.
+      This operation removes any weird hack in calculating the partitions.
+
+ -- Fabio M. Di Nitto <fabbione@ubuntu.com>  Fri, 08 Jul 2005 08:44:25 +0200
+
+partman-auto-lvm (2ubuntu1) breezy; urgency=low
+
+  * Fabio M. Di Nitto
+
+    ***********************************************************
+    *                                                         *
+    *    EXTREMELY EXPERIMENTAL CHANGES! HANDLE WITH CARE!    *
+    *                                                         *
+    ***********************************************************
+
+    - Ubuntu branding for the master template file.
+    - Add 40 some_device_lvm based on partman-auto counterpart.
+    NOTE: all the next changes will make partman-auto-lvm useful only with
+    lvm2 and the lvm_tools.sh API rename is done to keep a bit of consistency
+    with what real lvm2 tools actually do.
+    - Use vgs to simplify VG_list (lvm_tools.sh).
+    - Rename new_VG to VG_create (name more similare to vgcreate).
+    - Avoid useless loop in VG_create.
+    - Use pvs to simplify VG_of_PV.
+    - Rename detach_PV to VG_reduce.
+    - Simplify VG_reduce.
+    - Rename attach_PV to VG_extend.
+    - Rename new_LV to LV_create.
+    - Implement the "full" option in LV_create.
+    - Rename delete_LV to LV_remove.
+    - Cleanup LV_list.
+    NOTE: the following change requires partman-auto-41ubuntu3 or higher.
+    - Use expand_scheme and clean_method from recipe.sh to remove duplicate
+      code.
+    - expand_scheme needs a valid free_size value to return a proper $scheme
+      back. Also note the size hack in perform_recipe_by_lvm due to lvm
+      rounding issues. In order to fill up the space, the last partition will
+      be created using all the free_size and a 3% of the overall space is
+      reserved to ensure that the last partition is big enough.
+      There might be better methods to calculate, but right now this one seems
+      to fullfil its task.
+    - Flush udev queue in vg_all_free/do_option otherwise the devices might
+      not be there yet.
+    - Map devfs names to real devices in vg_all_free/do_option since lvm2
+      tools don't like devfs names.
+    - Create a separate /boot and a vg on the selected device.
+    - Allign vg creation between vg_all_free and some_device_lvm.
+    - Add notes on scheme manipulation.
+    - Remove wrong call to clean_method in perform_recipe_by_lvm.
+    - Fix device mapper naming.
+    - Restart partman at the end of the process. This is required to get some
+      LVM info right.
+    - Add missing noheadings to LV_create.
+    - Strip the decimal in LV_create.
+
+ -- Fabio M. Di Nitto <fabbione@ubuntu.com>  Thu, 07 Jul 2005 08:53:36 +0200
+
 partman-auto-lvm (2) unstable; urgency=low
 
   * Colin Watson
diff -Naurd partman-auto-lvm-2/debian/partman-auto-lvm.templates partman-auto-lvm-2ubuntu8/debian/partman-auto-lvm.templates
--- partman-auto-lvm-2/debian/partman-auto-lvm.templates	2005-06-01 00:26:13.000000000 +0200
+++ partman-auto-lvm-2ubuntu8/debian/partman-auto-lvm.templates	2005-10-18 09:18:41.000000000 +0200
@@ -2,6 +2,11 @@
 Type: text
 _Description: Use free space for the Logical Volume Manager
 
+Template: partman-auto-lvm/text/use_device
+Type: text
+# for example "Erase entire disk: IDE0 master - Maxtor 46L489"
+_Description: Erase entire disk and use LVM: ${DEVICE}
+
 Template: partman-auto-lvm/new_vg_name
 Type: string
 Default: Debian
diff -Naurd partman-auto-lvm-2/debian/po/ar.po partman-auto-lvm-2ubuntu8/debian/po/ar.po
diff -Naurd partman-auto-lvm-2/debian/po/bg.po partman-auto-lvm-2ubuntu8/debian/po/bg.po
diff -Naurd partman-auto-lvm-2/debian/po/bs.po partman-auto-lvm-2ubuntu8/debian/po/bs.po
diff -Naurd partman-auto-lvm-2/debian/po/ca.po partman-auto-lvm-2ubuntu8/debian/po/ca.po
diff -Naurd partman-auto-lvm-2/debian/po/cs.po partman-auto-lvm-2ubuntu8/debian/po/cs.po
diff -Naurd partman-auto-lvm-2/debian/po/cy.po partman-auto-lvm-2ubuntu8/debian/po/cy.po
diff -Naurd partman-auto-lvm-2/debian/po/da.po partman-auto-lvm-2ubuntu8/debian/po/da.po
diff -Naurd partman-auto-lvm-2/debian/po/de.po partman-auto-lvm-2ubuntu8/debian/po/de.po
diff -Naurd partman-auto-lvm-2/debian/po/el.po partman-auto-lvm-2ubuntu8/debian/po/el.po
diff -Naurd partman-auto-lvm-2/debian/po/es.po partman-auto-lvm-2ubuntu8/debian/po/es.po
diff -Naurd partman-auto-lvm-2/debian/po/eu.po partman-auto-lvm-2ubuntu8/debian/po/eu.po
diff -Naurd partman-auto-lvm-2/debian/po/fa.po partman-auto-lvm-2ubuntu8/debian/po/fa.po
diff -Naurd partman-auto-lvm-2/debian/po/fi.po partman-auto-lvm-2ubuntu8/debian/po/fi.po
diff -Naurd partman-auto-lvm-2/debian/po/fr.po partman-auto-lvm-2ubuntu8/debian/po/fr.po
diff -Naurd partman-auto-lvm-2/debian/po/gl.po partman-auto-lvm-2ubuntu8/debian/po/gl.po
diff -Naurd partman-auto-lvm-2/debian/po/he.po partman-auto-lvm-2ubuntu8/debian/po/he.po
diff -Naurd partman-auto-lvm-2/debian/po/hr.po partman-auto-lvm-2ubuntu8/debian/po/hr.po
diff -Naurd partman-auto-lvm-2/debian/po/hu.po partman-auto-lvm-2ubuntu8/debian/po/hu.po
diff -Naurd partman-auto-lvm-2/debian/po/id.po partman-auto-lvm-2ubuntu8/debian/po/id.po
diff -Naurd partman-auto-lvm-2/debian/po/it.po partman-auto-lvm-2ubuntu8/debian/po/it.po
diff -Naurd partman-auto-lvm-2/debian/po/ja.po partman-auto-lvm-2ubuntu8/debian/po/ja.po
diff -Naurd partman-auto-lvm-2/debian/po/ko.po partman-auto-lvm-2ubuntu8/debian/po/ko.po
diff -Naurd partman-auto-lvm-2/debian/po/lt.po partman-auto-lvm-2ubuntu8/debian/po/lt.po
diff -Naurd partman-auto-lvm-2/debian/po/lv.po partman-auto-lvm-2ubuntu8/debian/po/lv.po
diff -Naurd partman-auto-lvm-2/debian/po/nb.po partman-auto-lvm-2ubuntu8/debian/po/nb.po
diff -Naurd partman-auto-lvm-2/debian/po/nl.po partman-auto-lvm-2ubuntu8/debian/po/nl.po
diff -Naurd partman-auto-lvm-2/debian/po/nn.po partman-auto-lvm-2ubuntu8/debian/po/nn.po
diff -Naurd partman-auto-lvm-2/debian/po/pl.po partman-auto-lvm-2ubuntu8/debian/po/pl.po
diff -Naurd partman-auto-lvm-2/debian/po/pt_BR.po partman-auto-lvm-2ubuntu8/debian/po/pt_BR.po
diff -Naurd partman-auto-lvm-2/debian/po/pt.po partman-auto-lvm-2ubuntu8/debian/po/pt.po
diff -Naurd partman-auto-lvm-2/debian/po/ro.po partman-auto-lvm-2ubuntu8/debian/po/ro.po
diff -Naurd partman-auto-lvm-2/debian/po/ru.po partman-auto-lvm-2ubuntu8/debian/po/ru.po
diff -Naurd partman-auto-lvm-2/debian/po/sk.po partman-auto-lvm-2ubuntu8/debian/po/sk.po
diff -Naurd partman-auto-lvm-2/debian/po/sl.po partman-auto-lvm-2ubuntu8/debian/po/sl.po
diff -Naurd partman-auto-lvm-2/debian/po/sq.po partman-auto-lvm-2ubuntu8/debian/po/sq.po
diff -Naurd partman-auto-lvm-2/debian/po/sv.po partman-auto-lvm-2ubuntu8/debian/po/sv.po
diff -Naurd partman-auto-lvm-2/debian/po/templates.pot partman-auto-lvm-2ubuntu8/debian/po/templates.pot
diff -Naurd partman-auto-lvm-2/debian/po/tr.po partman-auto-lvm-2ubuntu8/debian/po/tr.po
diff -Naurd partman-auto-lvm-2/debian/po/uk.po partman-auto-lvm-2ubuntu8/debian/po/uk.po
diff -Naurd partman-auto-lvm-2/debian/po/vi.po partman-auto-lvm-2ubuntu8/debian/po/vi.po
diff -Naurd partman-auto-lvm-2/debian/po/zh_CN.po partman-auto-lvm-2ubuntu8/debian/po/zh_CN.po
diff -Naurd partman-auto-lvm-2/debian/po/zh_TW.po partman-auto-lvm-2ubuntu8/debian/po/zh_TW.po
diff -Naurd partman-auto-lvm-2/lvm_tools.sh partman-auto-lvm-2ubuntu8/lvm_tools.sh
--- partman-auto-lvm-2/lvm_tools.sh	2004-10-19 13:23:05.000000000 +0200
+++ partman-auto-lvm-2ubuntu8/lvm_tools.sh	2005-07-07 09:11:22.000000000 +0200
@@ -1,67 +1,39 @@
 
 TAB='	'
 
-# Print a list of the names of all volume groups, one per line
-# VG name<TAB>size
+# Print a list of the names of all volume groups and their size in M (including decimals!)
 VG_list () {
-    local name size
-    vgdisplay | grep '^[ ]*VG Name' | sed -e 's/.*[[:space:]]\+\(.*\)$/\1/' | sort | 
-    while read name; do
-	# TODO: the size is in B, KB or MB?
-	size=$(vgdisplay "$name" 2>&1 | grep '^[ ]*VG Size' | sed -e 's/^[ ]*VG Size \+//')
-	echo "${name}${TAB}${size}"
-    done
+    vgs -o vg_name,vg_size --nosuffix --units M --noheadings --sort vg_name --separator "${TAB}"
 }
 
 # Create a new VG from a list of PV.  The PV will be pvcreate-d
 # $1 = the name
 # $2,$3,$4,.. = a non-empty list of PV
-new_VG () {
-    local vg pv
+VG_create () {
+    local vg
     vg="$1"
     shift
-    for pv in $*; do
-	pvcreate -ff -y $pv >>/var/log/messages 2>&1
-    done
+    pvcreate -ff -y $* >>/var/log/messages 2>&1
     vgcreate "$vg" $* >>/var/log/messages 2>&1 || return 1
     return 0
 }
 
-# Print the name of the VG of a PV; exit 1 if this is not a phisical
-# volume or the information is not available
+# Print the name of the VG of which a PV belongs to.
 # $1 = the name of the PV
 VG_of_PV () {
-    local cmdout
-    cmdout=`pvdisplay "$1" 2>&1`
-    if echo "$cmdout" | grep -q 'is a new physical volume'; then
-	return 1
-    fi
-    
-    if echo "$cmdout" | grep -q '^pvdisplay'; then
-	return 1
-    fi
-    VG=`echo "$cmdout" | grep '^[ ]*VG Name' | \
-                sed -e 's/^[ ]*VG Name \+//'`
-    if [ "$VG" != "" ]; then
-	echo "$VG"
-	return 0
-    else
-	return 1
-    fi
+    pvs -o vg_name $1 --noheadings --separator "${TAB}" 2>/dev/null || return 1
 }
 
 # Make a PV not to be part of its VG
 # $1 = PV
-detach_PV () {
-    local vg
-    vg=`VG_of_PV $1` \
-	&& vgreduce $vg $1 >>/var/log/messages 2>&1
+VG_reduce () {
+    vgreduce $(VG_of_PV $1) $1 >>/var/log/messages 2>&1
 }
 
 # Add a new PV to a VG.  The PV will be pvcreate-d
 # $1 = PV
 # $2 = VG
-attach_PV () {
+VG_extend () {
     pvcreate -ff -y $1 >>/var/log/messages 2>&1 \
 	&& vgextend $2 $1 >>/var/log/messages 2>&1
 }
@@ -70,20 +42,23 @@
 # $1 = VG
 # $2 = size in bytes
 # $3 = name of the LV to create
-new_LV () {
-#    if [ "$2" = full ]; then
-# Using full VG not implemented until we have a way to get the free size of
-# a VG
-#	lvcreate -l$() -n $3 $1 >>/var/log/messages 2>&1
-#   else
-	lvcreate -L${2%???}k -n $3 $1 >>/var/log/messages 2>&1
-#    fi
+LV_create () {
+    local size
+    if [ "$2" = full ]; then
+        size=$(vgs -o vg_free --noheadings --nosuffix --units k $1 | sed -e 's/\..*//g')
+	if [ "$size" -le "0" ] || [ -z "$size" ]; then
+	    return 1
+	fi
+    else
+	size=${2%???}
+    fi
+    lvcreate -L${size}k -n $3 $1 >>/var/log/messages 2>&1
 }
 
 # Delete a LV
 # $1 = VG
 # $2 = LV
-delete_LV () {
+LV_remove () {
     lvremove -f /dev/$1/$2 >>/var/log/messages 2>&1
 }
 
@@ -91,15 +66,5 @@
 # VG name<TAB>size
 # $1 = VG
 LV_list () {
-    local i cmdout size
-    for i in \
-        $(vgdisplay -v $1 | grep '^[ ]*LV Name' |
-	    sed -e 's,.*/\(.*\),\1,' | sort)
-    do
-	cmdout=`lvdisplay "$1" 2>&1`
-        size=`echo "$cmdout" | grep '^[ ]*LV Size' | \
-                sed -e 's/^[ ]*LV Size \+\(.*\)/\1/'`
-	echo "${i}${TAB}${size}"
-    done
+    lvs $1 -o lv_name,lv_size --nosuffix --units M --noheadings --sort lv_name --separator "${TAB}"
 }
-
diff -Naurd partman-auto-lvm-2/perform_recipe_by_lvm partman-auto-lvm-2ubuntu8/perform_recipe_by_lvm
--- partman-auto-lvm-2/perform_recipe_by_lvm	2004-10-19 13:23:05.000000000 +0200
+++ partman-auto-lvm-2ubuntu8/perform_recipe_by_lvm	2005-07-08 12:02:29.000000000 +0200
@@ -9,67 +9,40 @@
 
 decode_recipe $recipe
 
-# The following had to be part of decode_recipe, but lets not make
-# changes in partman-auto and copy/past for now.
+partstep=$(echo "$scheme" | wc -l)
+partstep=$(expr $partstep + 3)
 
-# Make factors small numbers so we can multiply on them.
-# Also ensure that fact, max and fs are valid
-# (Ofcourse in valid recipes they must be valid.)
-factsum=$(($(factor_sum) - $(min_size)))
-scheme=$(
-    foreach_partition '
-        local min fact max fs
-        min=$1
-	fact=$((($2 - $min) * 100 / $factsum))
-	max=$3
-	fs=$4
-        case "$fs" in
-	    ext2|ext3|linux-swap|fat16|fat32)
-		true
-		;;
-	    *)
-		fs=ext2
-		;;
-        esac
-	shift; shift; shift; shift
-	echo $min $fact $max $fs $*'
-)
+db_progress START 0 $partstep partman-auto/text/automatically_partition
+db_progress INFO partman-auto/progress/info
 
-oldscheme=''
-while [ "$scheme" != "$oldscheme" ]; do
-    oldscheme="$scheme"
-    factsum=$(factor_sum)
-    unallocated=$(($free_size - $(min_size)))
-    if [ $unallocated -lt 0 ]; then
-	unallocated=0
-    fi
-    scheme=$(
-	foreach_partition '
-	    local min fact max newmin
-	    min=$1
-	    fact=$2
-	    max=$3
-	    shift; shift; shift
-	    newmin=$(($min + $unallocated * $fact / $factsum))
-	    if [ $newmin -le $max ]; then
-		echo $newmin $fact $max $*
-	    else
-		echo $max 0 $max $*
-	    fi'
-    )
-done
+db_progress STEP 1
 
-for device in $DEVICES/*; do
-    [ -d "$device" ] || continue
-    cd $device
-    open_dialog PARTITIONS
-    while { read_line num id size type fs path name; [ "$id" ]; }; do
-        if [ -f $id/method ]; then
-            rm $id/method
-        fi
-    done
-    close_dialog
-done
+# expand_scheme can't cope with decimal and lvm overhead.
+# lvm overhead gets calculated properly only using kbytes.
+# Switch to that. The worst scenario is that the last partition will be one PE smaller,
+# but in the big numbers it's nothing (4MB).
+free_size=$(vgs -o vg_free --units k --noheading --nosuffix $VG_name | sed -e 's/\..*//g')
+
+newscheme=''
+foreach_partition '
+	newmin="${1}000"
+	newmed="${2}000"
+	if [ "$3" != "1000000000" ]; then
+           newmax="${3}000"
+	else
+	   newmax="$3"
+	fi
+	shift; shift; shift
+	newscheme="$newscheme${NL}$newmin $newmed $newmax $*"
+'
+
+scheme="$newscheme"
+
+db_progress STEP 1
+
+expand_scheme
+
+db_progress STEP 1
 
 name_number=1
 foreach_partition '
@@ -88,14 +61,23 @@
 	    -e "s!^/!!" \
 	    -e "s!/!+!g"
 	)
+    elif echo $* | grep -q "method{"; then
+	lvname=$(echo $* | sed \
+	   -e "s/.*method{  *\([^ }]*\) *}.*/\1/g")
+	lvname="${lvname}_$name_number"
+	name_number=$(($name_number + 1))
     else
 	lvname=_$name_number
 	name_number=$(($name_number + 1))
     fi
 
-    new_LV $VG_name "$1"000000 "$lvname" || autopartitioning_failed
+    if [ "$last" = "yes" ]; then
+	LV_create $VG_name full  "$lvname" || autopartitioning_failed
+    else
+	LV_create $VG_name "$1"000 "$lvname" || autopartitioning_failed
+    fi
 
-    device=/dev/"$VG_name"/"$lvname" # is this true?
+    device=/dev/mapper/"$VG_name"-"$lvname" # is this true?
 
     dirname=$(echo "$device" | sed "s:/:=:g")
     dev=$DEVICES/$dirname
@@ -136,6 +118,33 @@
     
     shift; shift; shift; shift
     setup_partition $id $*
+    db_progress STEP 1
 '
 
-update_all
+db_progress STOP
+
+# Restart partman.
+
+open_infifo
+write_line "QUIT"
+close_infifo
+
+rm /var/run/parted_server.pid
+
+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
+    if [ -x $s ]; then
+        base=$(basename $s | sed 's/[0-9]*//')
+        if ! db_progress INFO partman/progress/init/$base; then
+            db_progress INFO partman/progress/init/fallback
+        fi
+        if ! $s; then
+            db_progress STOP
+            exit 255
+        fi
+    fi
+    db_progress STEP 1
+done
+db_progress STOP
+
diff -Naurd partman-auto-44.ORIG/debian/changelog partman-auto-44/debian/changelog
--- partman-auto-44.ORIG/debian/changelog	2005-09-26 17:28:07.000000000 +0200
+++ partman-auto-44/debian/changelog	2005-10-18 07:39:13.000000000 +0200
@@ -1,3 +1,11 @@
+partman-auto (XX) UNRELEASED; urgency=low
+
+  * Move 2 chunks of code from perform_recipe into recipes.sh and make them
+    functions. This code is shared with partman-auto-lvm so there is very
+    little point in duplicating it.
+
+ -- Fabio M. Di Nitto <fabbione@ubuntu.com>  Tue, 18 Oct 2005 07:38:49 +0200
+
 partman-auto (44) unstable; urgency=low
 
   [ Updated translations ]
diff -Naurd partman-auto-44.ORIG/perform_recipe partman-auto-44/perform_recipe
--- partman-auto-44.ORIG/perform_recipe	2005-05-13 22:55:25.000000000 +0200
+++ partman-auto-44/perform_recipe	2005-10-18 07:37:13.000000000 +0200
@@ -23,75 +23,18 @@
     exit 1
 fi
 
-db_progress START 0 6 partman-auto/text/automatically_partition
+db_progress START 0 5 partman-auto/text/automatically_partition
 db_progress INFO partman-auto/progress/info
 
 decode_recipe $recipe
 
 db_progress STEP 1
 
-# Make factors small numbers so we can multiply on them.
-# Also ensure that fact, max and fs are valid
-# (Ofcourse in valid recipes they must be valid.)
-factsum=$(($(factor_sum) - $(min_size)))
-scheme=$(
-    foreach_partition '
-        local min fact max fs
-        min=$1
-	fact=$((($2 - $min) * 100 / $factsum))
-	max=$3
-	fs=$4
-        case "$fs" in
-	    ext2|ext3|linux-swap|fat16|fat32|hfs)
-		true
-		;;
-	    *)
-		fs=ext2
-		;;
-        esac
-	shift; shift; shift; shift
-	echo $min $fact $max $fs $*'
-)
-
-db_progress STEP 1
-
-oldscheme=''
-while [ "$scheme" != "$oldscheme" ]; do
-    oldscheme="$scheme"
-    factsum=$(factor_sum)
-    unallocated=$(($free_size - $(min_size)))
-    if [ $unallocated -lt 0 ]; then
-	unallocated=0
-    fi
-    scheme=$(
-	foreach_partition '
-	    local min fact max newmin
-	    min=$1
-	    fact=$2
-	    max=$3
-	    shift; shift; shift
-	    newmin=$(($min + $unallocated * $fact / $factsum))
-	    if [ $newmin -le $max ]; then
-		echo $newmin $fact $max $*
-	    else
-		echo $max 0 $max $*
-	    fi'
-    )
-done
+expand_scheme
 
 db_progress STEP 1
 
-for device in $DEVICES/*; do
-    [ -d "$device" ] || continue
-    cd $device
-    open_dialog PARTITIONS
-    while { read_line num id size type fs path name; [ "$id" ]; }; do
-	if [ -f $id/method ]; then
-	    rm $id/method
-	fi
-    done
-    close_dialog
-done
+clean_method
 
 db_progress STEP 1
 
diff -Naurd partman-auto-44.ORIG/recipes.sh partman-auto-44/recipes.sh
--- partman-auto-44.ORIG/recipes.sh	2005-05-13 22:55:25.000000000 +0200
+++ partman-auto-44/recipes.sh	2005-10-18 07:36:22.000000000 +0200
@@ -320,3 +320,66 @@
     fi
     recipe="$RET"
 }
+
+expand_scheme() {
+    # Make factors small numbers so we can multiply on them.
+    # Also ensure that fact, max and fs are valid
+    # (Ofcourse in valid recipes they must be valid.)
+    factsum=$(($(factor_sum) - $(min_size)))
+    scheme=$(
+        foreach_partition '
+            local min fact max fs
+            min=$1
+            fact=$((($2 - $min) * 100 / $factsum))
+            max=$3
+            fs=$4
+            case "$fs" in
+                ext2|ext3|linux-swap|fat16|fat32|hfs)
+                    true
+                    ;;
+                *)
+                    fs=ext2
+                    ;;
+            esac
+           shift; shift; shift; shift
+           echo $min $fact $max $fs $*'
+    )
+
+    oldscheme=''
+    while [ "$scheme" != "$oldscheme" ]; do
+        oldscheme="$scheme"
+        factsum=$(factor_sum)
+        unallocated=$(($free_size - $(min_size)))
+        if [ $unallocated -lt 0 ]; then
+            unallocated=0
+        fi
+        scheme=$(
+            foreach_partition '
+                local min fact max newmin
+                min=$1
+                fact=$2
+                max=$3
+                shift; shift; shift
+                newmin=$(($min + $unallocated * $fact / $factsum))
+                if [ $newmin -le $max ]; then
+                    echo $newmin $fact $max $*
+                else
+                    echo $max 0 $max $*
+                fi'
+        )
+    done
+}
+
+clean_method() {
+    for device in $DEVICES/*; do
+        [ -d "$device" ] || continue
+        cd $device
+        open_dialog PARTITIONS
+        while { read_line num id size type fs path name; [ "$id" ]; }; do
+            if [ -f $id/method ]; then
+                rm $id/method
+            fi
+        done
+       close_dialog
+    done
+}

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: