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

Bug#510544: Installer/partition guide tried to use 500GB as swap



On Sunday 11 January 2009, Frans Pop wrote:
> > short: the maximal size of the unlimited partition is specified as
> > 1,000,000,000 in the recipes, and the numbers there mean MBs, so
> > that's 1000 TB.
>
> OK, but IMO this is more a structural flaw in partman-auto's recipe
> specification than a bug in partman-auto-lvm. Unlimited should be
> defined in some other way than "$random very high number which in
> practice will always turn out to be not high enough".
> Although with higher numbers we'll also run into overflow problems at
> some point (and we should probably test for that somehow).
>
> I think it would be more logical to specify unlimited as 0 or -1. Or
> even some string like "none".

A patch to change this turns out to be fairly trivial. Comments?
Successfully tested for both regular and LVM partitioning (though not with 
>1TB disk).

Ferenc: care to test this for >1TB?
Making the changes at runtime is trivial enough that custom debs should 
not be needed.

Note: I've only included the change for the default recipes, but of course 
they are all changed in the actual patch. partman-auto-lvm will need an 
updated versioned dependency on partman-auto which is not yet included in 
the patch. The installation guide will need to be updated as well, but 
the change is backwards compatible.

diff --git a/installer/doc/devel/partman-auto-recipe.txt b/installer/doc/devel/partman-auto-recipe.txt
index 18519a6..d941858 100644
--- a/installer/doc/devel/partman-auto-recipe.txt
+++ b/installer/doc/devel/partman-auto-recipe.txt
@@ -66,6 +66,7 @@ recommended to give small partitions a <priority> larger than their
 
 <maximal size> is the maximal size for the partition, i.e. a limit
 size such that there is no sense to make this partition larger.
+The special value "-1" is used to indicate unlimited partition size.
 
 <parted fs> is the file system as known to parted of this partition.
 
diff --git a/packages/partman/partman-auto-lvm/lib/auto-lvm.sh b/packages/partman/partman-auto-lvm/lib/auto-lvm.sh
index 4116080..30a94ae 100644
--- a/packages/partman/partman-auto-lvm/lib/auto-lvm.sh
+++ b/packages/partman/partman-auto-lvm/lib/auto-lvm.sh
@@ -14,7 +14,7 @@ bail_out() {
 # (Need $method in scope.)
 add_envelope() {
 	local scheme="$1"
-	echo "$scheme${NL}100 1000 1000000000 ext3 \$primary{ } method{ $method }"
+	echo "$scheme${NL}100 1000 -1 ext3 \$primary{ } method{ $method }"
 }
 
 # Create the partitions needed by a recipe to hold all PVs
diff --git a/packages/partman/partman-auto-lvm/perform_recipe_by_lvm b/packages/partman/partman-auto-lvm/perform_recipe_by_lvm
index 4278bfc..f3ee4fc 100755
--- a/packages/partman/partman-auto-lvm/perform_recipe_by_lvm
+++ b/packages/partman/partman-auto-lvm/perform_recipe_by_lvm
@@ -38,7 +38,8 @@ newscheme=''
 foreach_partition '
 	newmin="${1}000"
 	newmed="${2}000"
-	if [ "$3" != "1000000000" ]; then
+	# Second test is for backwards compatibility
+	if [ "$3" != "-1" ] && [ "$3" != "1000000000" ]; then
 		newmax="${3}000"
 	else
 		newmax="$3"
diff --git a/packages/partman/partman-auto/lib/recipes.sh b/packages/partman/partman-auto/lib/recipes.sh
index cf63fdc..3a6337d 100644
--- a/packages/partman/partman-auto/lib/recipes.sh
+++ b/packages/partman/partman-auto/lib/recipes.sh
@@ -69,14 +69,15 @@ decode_recipe () {
 			if [ $factor -lt $min ]; then
 				factor=$min
 			fi
-			if expr "$3" : '[0-9][0-9]*$' >/dev/null; then
+			if [ "$3" = "-1" ] || \
+			   expr "$3" : '[0-9][0-9]*$' >/dev/null; then
 				max=$3
 			elif expr "$3" : '[0-9][0-9]*%$' >/dev/null; then
 				max=$(($ram * ${3%?} / 100))
 			else # error
 				max=$min # do not enlarge the partition
 			fi
-			if [ $max -lt $min ]; then
+			if [ $max -ne -1 ] && [ $max -lt $min ]; then
 				max=$min
 			fi
 			case "$4" in # allow only valid file systems
@@ -370,7 +371,7 @@ expand_scheme() {
 			else
 				newmin=$(($min + $unallocated * $fact / $factsum))
 			fi
-			if [ $newmin -gt $max ]; then
+			if [ $max -ne -1 ] && [ $newmin -gt $max ]; then
 				echo $max 0 $max $*
 			elif [ $newmin -lt $min ]; then
 				echo $min 0 $min $*
commit 57a68e421774d5232379e5f248e2acfd622e4f49
Author: Frans Pop <fjp@debian.org>
Date:   Sun Jan 11 06:52:17 2009 +0100

    Use "-1" in partman recipes to indicate unlimited partition size

diff --git a/packages/partman/partman-auto/recipes/atomic b/packages/partman/partman-auto/recipes/atomic
index bd5edf9..ebd59d5 100644
--- a/packages/partman/partman-auto/recipes/atomic
+++ b/packages/partman/partman-auto/recipes/atomic
@@ -10,7 +10,7 @@ partman-auto/text/atomic_scheme ::
 	filesystem{ ext2 }
 	mountpoint{ /boot } .
 
-500 10000 1000000000 ext3
+500 10000 -1 ext3
 	$lvmok{ }
 	$primary{ }
 	$bootable{ }
diff --git a/packages/partman/partman-auto/recipes/home b/packages/partman/partman-auto/recipes/home
index 92018c9..a7a1793 100644
--- a/packages/partman/partman-auto/recipes/home
+++ b/packages/partman/partman-auto/recipes/home
@@ -25,7 +25,7 @@ partman-auto/text/home_scheme ::
 	method{ swap }
 	format{ } .
 
-100 10000 1000000000 ext3
+100 10000 -1 ext3
 	$lvmok{ }
 	method{ format }
 	format{ }
diff --git a/packages/partman/partman-auto/recipes/multi b/packages/partman/partman-auto/recipes/multi
index c26adf3..3aa7b56 100644
--- a/packages/partman/partman-auto/recipes/multi
+++ b/packages/partman/partman-auto/recipes/multi
@@ -49,7 +49,7 @@ partman-auto/text/multi_scheme ::
 	filesystem{ ext3 }
 	mountpoint{ /tmp } .
 
-300 3000 1000000000 ext3
+300 3000 -1 ext3
 	$lvmok{ }
 	method{ format }
 	format{ }

Reply to: