growfs script: fix config-dependent errors

- awk sometimes formatted swapbase as floating point, which gpart
  does not accept; force int.

- Fix typo in code for checking vm.max_swap_pages.

- While here, do not set kernel env if "gpart add" fails.

- Add "gpart show" before modification to verbose output.

Reported by:	marklmi at yahoo dot com
Tested by:	marklmi at yahoo dot com
This commit is contained in:
Mike Karels 2023-01-04 12:25:54 -06:00
parent e5b9b5ee8c
commit 0e2fdab227

View File

@ -89,7 +89,7 @@ growfs_swap_max()
if [ $swapmax -gt $vm_swap_max ]
then
$swapmax=$vm_swap_max
swapmax=$vm_swap_max
fi
echo -n "$swapmax"
}
@ -260,9 +260,9 @@ growfs_start()
" sz ", size[i]
swapbase = (expand + size[i]) / sector
swapbase -= swapsize + align
swapcmd = "gpart add -t freebsd-swap -a " align " -b " swapbase " " pdev "; kenv growfs_swap_pdev=" pdev " >/dev/null; "
swapcmd = "gpart add -t freebsd-swap -a " align " -b " int(swapbase) " " pdev " && kenv growfs_swap_pdev=" pdev " >/dev/null; "
if (verbose)
swapcmd = "set -x; " swapcmd
swapcmd = "set -x; gpart show; " swapcmd
}
cmd[i] = swapcmd "gpart resize -i " idx[i] " " pdev
if (parttype[i] == "GPT")