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

Bug#515607: partman-auto-lvm: ask how much VG space to use



Package: partman-auto-lvm
Version: 32
Severity: wishlist
Tags: patch
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch jaunty

Something I've consistently heard from users of guided LVM partitioning
in Ubuntu is that they don't want to go through the full manual
partitioning palaver, but nevertheless they don't want to use up all the
space in the volume group right away. Growing filesystems online is
typically easier than shrinking them, and growing the volume is of
course particularly easy with LVM, but I've come to believe that just
using up all the space at installation time is a bit too crude. I think
we should offer a level of control in between "just use it all
automatically" and "full manual partitioning", namely "how much of this
VG would you like to use?".

The attached patch (against the Ubuntu package, but it doesn't make much
difference) implements this. I've tested it and it seems to be working
rather well. However, I'm interested in other people's thoughts before
going ahead and committing it to d-i proper.

Thanks,

-- 
Colin Watson                                       [cjwatson@ubuntu.com]
=== modified file 'debian/partman-auto-lvm.templates'
--- debian/partman-auto-lvm.templates	2008-11-15 00:18:10 +0000
+++ debian/partman-auto-lvm.templates	2009-02-13 10:13:18 +0000
@@ -73,3 +73,41 @@ _Description: No physical volume defined
  volume group that does not contain any physical volume.
  .
  Please check the automatic partitioning recipe.
+
+Template: partman-auto-lvm/guided_size
+Type: string
+Default: some number
+# :sl3:
+_Description: Amount of disk space to use for guided partitioning:
+ You may use the whole disk for guided partitioning, or part of it. If you
+ use only part of it, or if you add more disks later, then you will be able
+ to grow logical volumes later using the LVM tools, so using a smaller
+ amount of disk at installation time may offer more flexibility.
+ .
+ The minimum size of the selected partitioning recipe is ${MINSIZE} (or
+ ${PERCENT}); please note that the packages you choose to install may
+ require more space than this. The maximum available size is ${MAXSIZE}.
+ .
+ Hint: "max" can be used as a shortcut to specify the maximum size, or
+ enter a percentage (e.g. "20%") to use that percentage of the maximum size.
+
+Template: partman-auto-lvm/bad_guided_size
+Type: error
+# :sl3:
+_Description: Invalid input
+ You entered "${INPUT}", which was not recognized as a valid size. Please
+ try again.
+
+Template: partman-auto-lvm/big_guided_size
+Type: error
+# :sl3:
+_Description: ${SIZE} is too big
+ You asked for ${SIZE} to be used for guided partitioning, but the available
+ space is only ${MAXSIZE}. Please try again.
+
+Template: partman-auto-lvm/small_guided_size
+Type: error
+# :sl3:
+_Description: ${SIZE} is too small
+ You asked for ${SIZE} to be used for guided partitioning, but the selected
+ partitioning recipe requires at least ${MINSIZE}. Please try again.

=== modified file 'perform_recipe_by_lvm'
--- perform_recipe_by_lvm	2009-02-11 13:39:31 +0000
+++ perform_recipe_by_lvm	2009-02-13 10:13:18 +0000
@@ -52,6 +52,75 @@ scheme="$newscheme"
 
 db_progress STEP 1
 
+# free_size and everything in the scheme are now in (decimal) kilobytes. For
+# conversion to human numbers, we need another multiple of 1000.
+minsize="$(min_size)"
+hminsize="$(longint2human "$minsize"000)"
+hmaxsize="$(longint2human "$free_size"000)"
+minpercent="$(expr 100 \* "$minsize" / "$free_size")"
+
+guided_size=
+while [ -z "$guided_size" ]; do
+	db_set partman-auto-lvm/guided_size "$hmaxsize"
+	db_subst partman-auto-lvm/guided_size MINSIZE "$hminsize"
+	db_subst partman-auto-lvm/guided_size MAXSIZE "$hmaxsize"
+	db_subst partman-auto-lvm/guided_size PERCENT "$minpercent%"
+	db_input high partman-auto-lvm/guided_size || true
+	db_go || return 255
+
+	db_get partman-auto-lvm/guided_size
+	case $RET in
+	    max)
+		guided_size="$free_size"000
+		;;
+	    *%)
+		digits="$(expr "$RET" : '\([1-9][0-9]*\) *%$')"
+		if [ "$digits" ]; then
+			maxmb="$(convert_to_megabytes "$free_size"000)"
+			guided_size="$(($digits * $maxmb / 100))000000"
+		fi
+		;;
+	    *)
+		if valid_human "$RET"; then
+			guided_size="$(human2longint "$RET")"
+		fi
+		;;
+	esac
+
+	if [ -z "$guided_size" ]; then
+		db_subst partman-auto-lvm/bad_guided_size INPUT "$RET"
+		db_input high partman-auto-lvm/bad_guided_size || true
+		db_go || true
+	elif ! longint_le "$guided_size" "$free_size"000; then
+		db_subst partman-auto-lvm/big_guided_size SIZE \
+			"$(longint2human "$guided_size")"
+		db_subst partman-auto-lvm/big_guided_size MAXSIZE "$hmaxsize"
+		db_input high partman-auto-lvm/big_guided_size || true
+		db_go || true
+		guided_size=
+	elif ! longint_le "$minsize"000 "$guided_size"; then
+		db_subst partman-auto-lvm/small_guided_size SIZE \
+			"$(longint2human "$guided_size")"
+		db_subst partman-auto-lvm/small_guided_size MINSIZE "$hminsize"
+		db_input high partman-auto-lvm/small_guided_size || true
+		db_go || true
+		guided_size=
+	fi
+
+	if [ "$guided_size" ]; then
+		# We have a figure in (decimal) megabytes. Convert back to
+		# (decimal) kilobytes, which is what the rest of this is
+		# expecting.
+		guided_size="$(expr 0000"$guided_size" : '0*\(..*\)...$')"
+	fi
+done
+
+use_all=
+if [ "$guided_size" -ge "$free_size" ]; then
+	use_all=1
+fi
+free_size="$guided_size"
+
 expand_scheme
 
 db_progress STEP 1
@@ -86,7 +155,7 @@ foreach_partition '
 		name_number=$(($name_number + 1))
 	fi
 
-	if [ "$last" = yes ]; then
+	if [ "$last" = yes ] && [ "$use_all" ]; then
 		vg_get_info "$VG_name"
 		lv_create $VG_name "$lvname" $FREEPE || autopartitioning_failed
 	else


Reply to: