Codebase list partman-auto / 315e4f3
Add support for writing sizes as a number plus a percentage of RAM, e.g. "2000+50%". This is useful when doing automatic partitioning with the expectation of creating swap files. r59001 Colin Watson 14 years ago
2 changed file(s) with 21 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
0 partman-auto (87) UNRELEASED; urgency=low
1
2 * Add support for writing sizes as a number plus a percentage of RAM, e.g.
3 "2000+50%". This is useful when doing automatic partitioning with the
4 expectation of creating swap files.
5
6 -- Colin Watson <[email protected]> Tue, 16 Jun 2009 13:07:21 +0100
7
08 partman-auto (86) unstable; urgency=low
19
210 [ Colin Watson ]
5353 set -- $line
5454 if expr "$1" : '[0-9][0-9]*$' >/dev/null; then
5555 min=$1
56 elif expr "$1" : '[0-9][0-9]*+[0-9][0-9]*%$' >/dev/null; then
57 ram_percent="${1#*+}"
58 ram_percent="${ram_percent%?}"
59 min=$((${1%%+*} + $ram * $ram_percent / 100))
5660 elif expr "$1" : '[0-9][0-9]*%$' >/dev/null; then
5761 min=$(($ram * ${1%?} / 100))
5862 else # error
5963 min=2200000000 # there is no so big storage device jet
6064 fi
61 if expr "$2" : '[0-9][0-9]*%$' >/dev/null; then
65 if expr "$2" : '[0-9][0-9]*+[0-9][0-9]*%$' >/dev/null; then
66 ram_percent="${2#*+}"
67 ram_percent="${ram_percent%?}"
68 factor=$((${2%%+*} + $ram * $ram_percent / 100))
69 elif expr "$2" : '[0-9][0-9]*%$' >/dev/null; then
6270 factor=$(($ram * ${2%?} / 100))
6371 elif expr "$2" : '[0-9][0-9]*$' >/dev/null; then
6472 factor=$2
7179 if [ "$3" = "-1" ] || \
7280 expr "$3" : '[0-9][0-9]*$' >/dev/null; then
7381 max=$3
82 elif expr "$3" : '[0-9][0-9]*+[0-9][0-9]*%$' >/dev/null; then
83 ram_percent="${3#*+}"
84 ram_percent="${ram_percent%?}"
85 max=$((${3%%+*} + $ram * $ram_percent / 100))
7486 elif expr "$3" : '[0-9][0-9]*%$' >/dev/null; then
7587 max=$(($ram * ${3%?} / 100))
7688 else # error